lib/lhj/command/yapi.rb in lhj-tools-0.1.86 vs lib/lhj/command/yapi.rb in lhj-tools-0.1.87

- old
+ new

@@ -65,11 +65,11 @@ # 1.print request result res_models = print_res_body_model(res_body) # 2.print request json body req_models = print_req_body_model(res_body) if res_body['data']['req_body_is_json_schema'] # 3.print request param - print_req_query(res_body['data']) unless res_body['data']['req_body_is_json_schema'] + req_models ||= print_req_query(res_body['data']) unless res_body['data']['req_body_is_json_schema'] # 4.print request method service_code = print_http_method(res_body['data'], project_info) # print request mock data print_mock_request_data(req_models) if !req_models.nil? && !req_models.empty? # 5.save to file @@ -460,22 +460,20 @@ # @param [Object] data def print_req_query(data) return unless data && data['req_query'] - case @language - when 'oc' - param_model_name = gen_model_name(nil, :req) - puts_h "@interface #{param_model_name} : NSObject" - data['req_query'].each do |h| - des = h['desc'] - puts_h "///#{des} #{h['example']}" - puts_h "@property (nonatomic, copy) NSString *#{h['name']};" - end - puts_h '@end' - puts "\n\n" - when 'java' + properties = [] + data['req_query'].each do |h| + properties << { key: h['name'], type: 'string', description: h['desc'], default: '' } end + param_model_name = gen_model_name(nil, :req) + req_model = { name: param_model_name, properties: properties } + + models = [req_model] + print_models(models) + print_models_impl(models) + models end def print_http_method(data, project_info) return unless data