Skip to content

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

Closed
@jonschoning

Description

@jonschoning

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
        },

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions