mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Fix form datatype (array of string) (#339)
* fix data type for array of form parameters * add test case to cover the form parameter issue
This commit is contained in:
parent
a56d2333a2
commit
b1eac05b2b
@ -4110,6 +4110,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.isContainer = true;
|
||||
codegenParameter.isListContainer = true;
|
||||
codegenParameter.description = s.getDescription();
|
||||
codegenParameter.dataType = getTypeDeclaration(s);
|
||||
|
||||
// recursively add import
|
||||
while (codegenProperty != null) {
|
||||
|
@ -17,11 +17,9 @@
|
||||
|
||||
package org.openapitools.codegen.ruby;
|
||||
|
||||
import org.openapitools.codegen.ClientOpts;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import io.swagger.models.parameters.FormParameter;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.languages.RubyClientCodegen;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
@ -145,4 +143,18 @@ public class RubyClientCodegenTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(description = "verify enum parameters (query, form, header)")
|
||||
public void enumParameterTest() {
|
||||
final OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
final DefaultCodegen codegen = new RubyClientCodegen();
|
||||
final String path = "/fake";
|
||||
final Operation p = openAPI.getPaths().get(path).getGet();
|
||||
final CodegenOperation op = codegen.fromOperation(path, "get", p, openAPI.getComponents().getSchemas());
|
||||
|
||||
Assert.assertEquals(op.formParams.size(), 2);
|
||||
CodegenParameter fp = op.formParams.get(0);
|
||||
|
||||
Assert.assertEquals(fp.dataType, "Array<String>");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ opts = {
|
||||
enum_query_string: '-efg', # String | Query parameter enum test (string)
|
||||
enum_query_integer: 56, # Integer | Query parameter enum test (double)
|
||||
enum_query_double: 3.4, # Float | Query parameter enum test (double)
|
||||
enum_form_string_array: nil, # Array<String> | Form parameter enum test (string array)
|
||||
enum_form_string_array: '$', # Array<String> | Form parameter enum test (string array)
|
||||
enum_form_string: '-efg' # String | Form parameter enum test (string)
|
||||
}
|
||||
|
||||
@ -408,7 +408,7 @@ Name | Type | Description | Notes
|
||||
**enum_query_string** | **String**| Query parameter enum test (string) | [optional] [default to '-efg']
|
||||
**enum_query_integer** | **Integer**| Query parameter enum test (double) | [optional]
|
||||
**enum_query_double** | **Float**| Query parameter enum test (double) | [optional]
|
||||
**enum_form_string_array** | [**Array<String>**](Array.md)| Form parameter enum test (string array) | [optional]
|
||||
**enum_form_string_array** | **Array<String>**| Form parameter enum test (string array) | [optional] [default to '$']
|
||||
**enum_form_string** | **String**| Form parameter enum test (string) | [optional] [default to '-efg']
|
||||
|
||||
### Return type
|
||||
|
@ -475,7 +475,7 @@ module Petstore
|
||||
# @option opts [String] :enum_query_string Query parameter enum test (string) (default to '-efg')
|
||||
# @option opts [Integer] :enum_query_integer Query parameter enum test (double)
|
||||
# @option opts [Float] :enum_query_double Query parameter enum test (double)
|
||||
# @option opts [Array<String>] :enum_form_string_array Form parameter enum test (string array)
|
||||
# @option opts [Array<String>] :enum_form_string_array Form parameter enum test (string array) (default to '$')
|
||||
# @option opts [String] :enum_form_string Form parameter enum test (string) (default to '-efg')
|
||||
# @return [nil]
|
||||
def test_enum_parameters(opts = {})
|
||||
|
Loading…
x
Reference in New Issue
Block a user