Skip to content

Multiple Content-Type body contents are not handled #3377

Closed

Description

Description

When an OpenAPI description defines endpoints with > 1 content types for the body content, only the first application/jsonish entry is handled by the SDK.

Repro

Given a minimal OpenAPI such as:

openapi: 3.0.0
info:
  title: Test
  version: 1.0.0
  description: something
paths:
  /api:
    post:
      requestBody:
        content:
          "*/*":
            schema:
              type: number
          "application/create.extended+json":
            schema:
              type: array
              items:
                type: integer
          "application/json":
            schema:
              type: array
              items:
                type: number
          "application/xml":
            schema:
              type: string
          "text/plain":
            schema:
              type: array
              items:
                type: string
      responses:
        "200":
          description: "something"
          content:
            application/json: {}

We can observe that the only generated PostRequestInformation contains this line (in Java but similar in other languages):

requestInfo.setContentFromScalarCollection(requestAdapter, "application/create.extended+json", body.toArray(new Integer[0]));

Questions

Is it a deliberate choice? I'm failing at finding references in the docs.
Would it be possible to generate multiple toPostRequestInformation methods to cover all of the Content-Types handled by the server? Cannot find another issue referring to this limitation.
Do you have an idiomatic way to work around the current behavior other than fixing the RequestInformation object before sending it through the adapter?
Should the(current) implementation give precedence to application/json and, only if not found, apply cleaning?

Thoughts?

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

Metadata

Assignees

Labels

WIPenhancementNew feature or requestgeneratorIssues or improvements relater to generation capabilities.

Type

No type

Projects

  • Status

    Done ✔️

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions