OpenAPITools / OpenAPITools/openapi-generator

[REQ] OpenAPI shall handle multiple content types pro operation

Open
#20,871 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

Some of our company internal swagger files use multiple content types pro operation. It is allowed by REST-API and currently in use. But OpenAPI generator handles only the first one, others are ignored.

Describe the solution you'd like

If an operation have multiple content types a matching function call shall be generated pro content type, eg:
myFunction(<parameter list 0>)
myFunction_1(<parameter list 1>)
...

Describe alternatives you've considered

Currently I am using ugly workarounds using manual modification of the swagger file before the generation and further manual modifications of the generated C++ classes after the generation. Time consuming, error prone and really ugly.

Additional context

I develop in C++ with Qt, so I use cpp-qt-client generator. But the problem is language independent.
I have already made an in-house extension and I am going to provide it in form of a pull request.

See some swagger snippits, as an illustration of the problem:

paths:
  /myFunction:
    post:
      operationId: "myFunction"
      requestBody:
        content:
          multipart/form-data:
            schema:
              required:
              - "geoWhatever"
              - "payload"
              type: "object"
              properties:
                geoWhatever:
                  type: "string"
                  format: "binary"
                payload:
                  $ref: "#/components/schemas/myFunctionPayload1"
	       application/json:
            schema:
              required:
              - "payload"
              type: "object"
              properties:
                payload:
                  $ref: "#/components/schemas/myFunctionPayload2" 


Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the cpp-qt-client generator entry point that processes OpenAPI requestBody content, using the YAML example in the issue as a reproduction. Verify how multiple content types are currently reduced to one, then generate separate operation calls for each content type and confirm the generated client preserves the distinct request schemas.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, openapi
Domain
api, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.