Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,22 @@ module {{moduleName}}
query_params = opts[:query_params] || {}
{{#queryParams}}
{{#required}}
{{#queryIsJsonMimeType}}
query_params[:'{{{baseName}}}'] = {{{paramName}}}.to_json
{{/queryIsJsonMimeType}}
{{^queryIsJsonMimeType}}
query_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
{{/queryIsJsonMimeType}}
{{/required}}
{{/queryParams}}
{{#queryParams}}
{{^required}}
{{#queryIsJsonMimeType}}
query_params[:'{{{baseName}}}'] = opts[:'{{{paramName}}}'].to_json if !opts[:'{{{paramName}}}'].nil?
{{/queryIsJsonMimeType}}
{{^queryIsJsonMimeType}}
query_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{{paramName}}}'].nil?
{{/queryIsJsonMimeType}}
{{/required}}
{{/queryParams}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,4 +749,17 @@ public void testRegularExpressionOpenAPISchemaVersion3() {
// patten_starts_ends_with_slash '/root/'
Assert.assertEquals(op.allParams.get(8).pattern, "/root/");
}

@Test
public void testQueryParamJsonSerializationSetsQueryIsJsonMimeType() {
RubyClientCodegen codegen = new RubyClientCodegen();
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/echo_api.yaml");
codegen.setOpenAPI(openAPI);
String path = "/query/style_jsonSerialization/object";
CodegenOperation op = codegen.fromOperation(path, "GET", openAPI.getPaths().get(path).getGet(), null);

Assert.assertEquals(op.queryParams.size(), 2);
assertTrue(op.queryParams.stream().allMatch(p -> p.queryIsJsonMimeType),
"All content:application/json query params should have queryIsJsonMimeType=true");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ def test_query_style_json_serialization_object_with_http_info(opts = {})

# query parameters
query_params = opts[:query_params] || {}
query_params[:'json_serialized_object_ref_string_query'] = opts[:'json_serialized_object_ref_string_query'] if !opts[:'json_serialized_object_ref_string_query'].nil?
query_params[:'json_serialized_object_array_ref_string_query'] = @api_client.build_collection_param(opts[:'json_serialized_object_array_ref_string_query'], :csv) if !opts[:'json_serialized_object_array_ref_string_query'].nil?
query_params[:'json_serialized_object_ref_string_query'] = opts[:'json_serialized_object_ref_string_query'].to_json if !opts[:'json_serialized_object_ref_string_query'].nil?
query_params[:'json_serialized_object_array_ref_string_query'] = opts[:'json_serialized_object_array_ref_string_query'].to_json if !opts[:'json_serialized_object_array_ref_string_query'].nil?

# header parameters
header_params = opts[:header_params] || {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ def test_query_style_json_serialization_object_with_http_info(opts = {})

# query parameters
query_params = opts[:query_params] || {}
query_params[:'json_serialized_object_ref_string_query'] = opts[:'json_serialized_object_ref_string_query'] if !opts[:'json_serialized_object_ref_string_query'].nil?
query_params[:'json_serialized_object_array_ref_string_query'] = @api_client.build_collection_param(opts[:'json_serialized_object_array_ref_string_query'], :csv) if !opts[:'json_serialized_object_array_ref_string_query'].nil?
query_params[:'json_serialized_object_ref_string_query'] = opts[:'json_serialized_object_ref_string_query'].to_json if !opts[:'json_serialized_object_ref_string_query'].nil?
query_params[:'json_serialized_object_array_ref_string_query'] = opts[:'json_serialized_object_array_ref_string_query'].to_json if !opts[:'json_serialized_object_array_ref_string_query'].nil?

# header parameters
header_params = opts[:header_params] || {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ def test_query_style_json_serialization_object_with_http_info(opts = {})

# query parameters
query_params = opts[:query_params] || {}
query_params[:'json_serialized_object_ref_string_query'] = opts[:'json_serialized_object_ref_string_query'] if !opts[:'json_serialized_object_ref_string_query'].nil?
query_params[:'json_serialized_object_array_ref_string_query'] = @api_client.build_collection_param(opts[:'json_serialized_object_array_ref_string_query'], :csv) if !opts[:'json_serialized_object_array_ref_string_query'].nil?
query_params[:'json_serialized_object_ref_string_query'] = opts[:'json_serialized_object_ref_string_query'].to_json if !opts[:'json_serialized_object_ref_string_query'].nil?
query_params[:'json_serialized_object_array_ref_string_query'] = opts[:'json_serialized_object_array_ref_string_query'].to_json if !opts[:'json_serialized_object_array_ref_string_query'].nil?

# header parameters
header_params = opts[:header_params] || {}
Expand Down
Loading