mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
fix map type and collection format for form parameter (array) (#356)
This commit is contained in:
parent
e49e8ca169
commit
d74b4cdf8d
@ -27,8 +27,8 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaPlayFramework -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java-play-framework -o samples/server/petstore/java-play-framework-fake-endpoints -DhideGenerationTimestamp=true"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/JavaPlayFramework -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java-play-framework -o samples/server/petstore/java-play-framework-fake-endpoints -DhideGenerationTimestamp=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
cp samples.ci/server/petstore/java-play-framework-fake-endpoints/pom.xml samples/server/petstore/java-play-framework-fake-endpoints/pom.xml
|
||||
cp samples.ci/server/petstore/java-play-framework-fake-endpoints/pom.xml samples/server/petstore/java-play-framework-fake-endpoints/pom.xml
|
||||
|
@ -4097,12 +4097,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
arraySchema.setItems(inner);
|
||||
}
|
||||
|
||||
//TODO fix collectformat for form parameters
|
||||
//collectionFormat = getCollectionFormat(s);
|
||||
// default to csv:
|
||||
collectionFormat = StringUtils.isEmpty(collectionFormat) ? "csv" : collectionFormat;
|
||||
codegenParameter = fromFormProperty(entry.getKey(), inner, imports);
|
||||
|
||||
CodegenProperty codegenProperty = fromProperty("inner", inner);
|
||||
codegenParameter.items = codegenProperty;
|
||||
codegenParameter.baseType = codegenProperty.datatype;
|
||||
@ -4110,6 +4105,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.isListContainer = true;
|
||||
codegenParameter.description = s.getDescription();
|
||||
codegenParameter.dataType = getTypeDeclaration(s);
|
||||
//TODO fix collectformat for form parameters
|
||||
//collectionFormat = getCollectionFormat(s);
|
||||
// default to csv:
|
||||
codegenParameter.collectionFormat = StringUtils.isEmpty(collectionFormat) ? "csv" : collectionFormat;
|
||||
|
||||
// recursively add import
|
||||
while (codegenProperty != null) {
|
||||
@ -4253,7 +4252,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
||||
codegenParameter.items = codegenProperty.items;
|
||||
codegenParameter.dataType = getTypeDeclaration(inner);
|
||||
codegenParameter.dataType = getTypeDeclaration(schema);
|
||||
LOGGER.info("debugging inline map: " + codegenParameter.dataType);
|
||||
codegenParameter.baseType = getSchemaType(inner);
|
||||
codegenParameter.isContainer = Boolean.TRUE;
|
||||
codegenParameter.isMapContainer = Boolean.TRUE;
|
||||
|
@ -289,12 +289,14 @@ public class FakeApiController extends Controller {
|
||||
} else {
|
||||
enumQueryDouble = null;
|
||||
}
|
||||
String valueenumFormStringArray = (request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string_array"))[0];
|
||||
String enumFormStringArray;
|
||||
if (valueenumFormStringArray != null) {
|
||||
enumFormStringArray = valueenumFormStringArray;
|
||||
} else {
|
||||
enumFormStringArray = "$";
|
||||
String[] enumFormStringArrayArray = request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string_array");
|
||||
List<String> enumFormStringArrayList = OpenAPIUtils.parametersToList("csv", enumFormStringArrayArray);
|
||||
List<String> enumFormStringArray = new ArrayList<String>();
|
||||
for (String curParam : enumFormStringArrayList) {
|
||||
if (!curParam.isEmpty()) {
|
||||
//noinspection UseBulkOperation
|
||||
enumFormStringArray.add(curParam);
|
||||
}
|
||||
}
|
||||
String valueenumFormString = (request().body().asMultipartFormData().asFormUrlEncoded().get("enum_form_string"))[0];
|
||||
String enumFormString;
|
||||
@ -326,9 +328,9 @@ public class FakeApiController extends Controller {
|
||||
@ApiAction
|
||||
public Result testInlineAdditionalProperties() throws Exception {
|
||||
JsonNode noderequestBody = request().body().asJson();
|
||||
String requestBody;
|
||||
Map<String, String> requestBody;
|
||||
if (noderequestBody != null) {
|
||||
requestBody = mapper.readValue(noderequestBody.toString(), new TypeReference<String>(){});
|
||||
requestBody = mapper.readValue(noderequestBody.toString(), new TypeReference<Map<String, String>>(){});
|
||||
if (configuration.getBoolean("useInputBeanValidation")) {
|
||||
for (Map.Entry<String, String> entry : requestBody.entrySet()) {
|
||||
OpenAPIUtils.validate(entry.getValue());
|
||||
|
@ -58,12 +58,12 @@ public class FakeApiControllerImp implements FakeApiControllerImpInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testEnumParameters(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, String enumFormStringArray, String enumFormString) throws Exception {
|
||||
public void testEnumParameters(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<String> enumFormStringArray, String enumFormString) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testInlineAdditionalProperties(String requestBody) throws Exception {
|
||||
public void testInlineAdditionalProperties(Map<String, String> requestBody) throws Exception {
|
||||
//Do your magic!!!
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@ public interface FakeApiControllerImpInterface {
|
||||
|
||||
void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, Http.MultipartFormData.FilePart binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws Exception;
|
||||
|
||||
void testEnumParameters(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, String enumFormStringArray, String enumFormString) throws Exception;
|
||||
void testEnumParameters(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<String> enumFormStringArray, String enumFormString) throws Exception;
|
||||
|
||||
void testInlineAdditionalProperties(String requestBody) throws Exception;
|
||||
void testInlineAdditionalProperties(Map<String, String> requestBody) throws Exception;
|
||||
|
||||
void testJsonFormData(String param, String param2) throws Exception;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user