Skip to content

Question: RequestBody & Multiple Content-Types (OAS3) #6740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jonschoning opened this issue Oct 18, 2017 · 1 comment
Closed

Question: RequestBody & Multiple Content-Types (OAS3) #6740

jonschoning opened this issue Oct 18, 2017 · 1 comment

Comments

@jonschoning
Copy link
Contributor

jonschoning commented Oct 18, 2017

In 3.0.0_enhancements branch, I noticed this line:

protected String getContentType(RequestBody requestBody) {
if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) {
return null;
}
return new ArrayList<>(requestBody.getContent().keySet()).get(0);

This appears to select the only the first content-type for a RequestBody.

What can we expect will be the plan for code generation, for the RequestBody for cases 1) and 2) below?

1) Multiple content-types with the same Schema

        "requestBody": {
          "description": "Pet object that needs to be added to the store",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Pet"
              }
            },
            "application/xml": {
              "schema": {
                "$ref": "#/components/schemas/Pet"
              }
            }
          },
          "required": false
        },

2) Multiple content-types with different Schemas

Schemas can vary by media type.

https://swagger.io/docs/specification/describing-request-body/

        "requestBody": {
          "description": "Pet object that needs to be added to the store",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Cat"
              }
            },
            "application/xml": {
              "schema": {
                "$ref": "#/components/schemas/Dog"
              }
            }
          },
          "required": false
        },
@wing328
Copy link
Contributor

wing328 commented Oct 19, 2017

cc @HugoMario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants