Skip to content

[BUG][JAVA] OpenAPI 3.x query parameters described with content vs schema don't generate - result is unknown parameter in generated code #2687

@darrellmay

Description

@darrellmay

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

In OpenAPI 3.0+ you can describe query parameters with a content: vs schema:
There's 2 issues

  1. The swagger core parser doesn't properly resolve query paramters specified with the content tag
  2. The openapi-generator doesn't have logic to generate the code even if the core parser did resolve the parameters
openapi-generator version

master

OpenAPI declaration file content or url

You can see the yample yaml in the issue I raised with swagger-parser
swagger-api/swagger-parser#1078

Command line used for generation

Take yaml from swagger-api/swagger-parser#1078

Command lline args: generate -g jaxrs-resteasy-eap -i example.yaml -o outputdir

Steps to reproduce

See Yaml from swagger-api/swagger-parser#1078, and attempt to generate client/server code for it.

Related issues/PRs

swagger-api/swagger-parser#1078

Suggest a fix

In org.openapitools.codegen.DefaultCodegen.fromParameter()
We need to do more than check for getSchema()!=null.

If it's null but there's a content specified (i.e. getContent()!=null, we need to pull the scema from the MediaType from the specified content.

Similar to how response bodies are generated with content specified.

But it still requires swagger-api/swagger-parser#1079 in order for the schema objects to be resolved under the specified content/media-type section.
Without that fix, there will be no schema objects in the openAPI context to be able to generate the proper code.

I'm testing a full patch with added unit tests.
I'll submit a PR when I'm done.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions