Skip to content

Commit

Permalink
Merge pull request #705 from swagger-api/issue-466
Browse files Browse the repository at this point in the history
handle content schema in parameter objects
  • Loading branch information
HugoMario authored Jun 24, 2020
2 parents d015254 + 0d284a0 commit 4302f0f
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2414,8 +2414,11 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports)
codegenParameter.vendorExtensions.putAll(parameter.getExtensions());
}

if (parameter.getSchema() != null) {
Schema parameterSchema = parameter.getSchema();
Schema parameterSchema = parameter.getSchema();
if (parameterSchema == null) {
parameterSchema = getSchemaFromParameter(parameter);
}
if (parameterSchema != null) {
String collectionFormat = null;
if (parameterSchema instanceof ArraySchema) { // for array parameter
final ArraySchema arraySchema = (ArraySchema) parameterSchema;
Expand Down Expand Up @@ -3983,6 +3986,21 @@ protected Schema getSchemaFromResponse(ApiResponse response) {
return schema;
}

protected Schema getSchemaFromParameter(Parameter parameter) {
if (parameter.getContent() == null || parameter.getContent().isEmpty()) {
return null;
}
Schema schema = null;
for (String contentType : parameter.getContent().keySet()) {
schema = parameter.getContent().get(contentType).getSchema();
if (schema != null) {
schema.addExtension("x-content-type", contentType);
}
break;
}
return schema;
}

protected Parameter getParameterFromRef(String ref, OpenAPI openAPI) {
String parameterName = ref.substring(ref.lastIndexOf('/') + 1);
Map<String, Parameter> parameterMap = openAPI.getComponents().getParameters();
Expand Down

0 comments on commit 4302f0f

Please sign in to comment.