[core] add support for model as query params (#2489)

* add support for model as query params

* add logging incase of multiple schemas are present
This commit is contained in:
Hemant Zope 2019-05-09 09:31:58 +02:00 committed by William Cheng
parent 70108b753e
commit 8e91b8c62a

View File

@ -2931,8 +2931,22 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.vendorExtensions.putAll(parameter.getExtensions()); codegenParameter.vendorExtensions.putAll(parameter.getExtensions());
} }
Schema s;
if(parameter.getSchema() != null) { if(parameter.getSchema() != null) {
Schema parameterSchema = ModelUtils.unaliasSchema(this.openAPI, parameter.getSchema()); s = parameter.getSchema();
} else if (parameter.getContent() != null) {
Content content = parameter.getContent();
if (content.size() > 1) {
LOGGER.warn("Multiple schemas found in content, returning only the first one");
}
MediaType mediaType = content.values().iterator().next();
s = mediaType.getSchema();
} else {
s = null;
}
if (s != null) {
Schema parameterSchema = ModelUtils.unaliasSchema(this.openAPI, s);
if (parameterSchema == null) { if (parameterSchema == null) {
LOGGER.warn("warning! Schema not found for parameter \"" + parameter.getName() + "\", using String"); LOGGER.warn("warning! Schema not found for parameter \"" + parameter.getName() + "\", using String");
parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition."); parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition.");