Solvedopenapi generator Investigate multiple schema case (different mime types) in ModelUtils

In ModelUtils those two methods return a single Schema for a RequestBody or a ApiResponse:

  • ModelUtils.getSchemaFromRequestBody(RequestBody)
  • ModelUtils.getSchemaFromResponse(ApiResponse)

This feels wrong because when multiple Mime types are defined (like application/json or application/xml) different Schemas can be returned.

With #74 an additional warning log was added:

[main] WARN org.openapitools.codegen.utils.ModelUtils - Multiple schemas found, returning only the first one

We should investigate on the impacts.

When multiple mime types are defined we might need to compare if the defined schema are different or not.

29 Answers

✔️Accepted Answer

Any status of this?

Other Answers:

Are there any plans to implement this in the near future? IMO this is a bug. Why can't the OpenAPI Generator handle multiple content types? Other generators handle this correctly.

I think having different content types in the requestBody is a common use case, e.g.:

/api/item:
    post:
      operationId: addItem
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Item'
          multipart/form-data:
            schema:
              type: object
              properties:
                item:
                  $ref: '#/components/schemas/Item'
                file:
                  $ref: '#/components/schemas/InputStream'

In my opinion, content negotiation is a very basic concept of HTTP / REST.
We are also facing similar problems and would love to see a solution for that.

More Issues: