OpenAPITools / OpenAPITools/openapi-generator

[REQ] Method generation based on Accept type.

Open
#9,267 0 comments 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 APIs have different outputs based on the Accept header type. For example, the endpoint would return SVG when request header is Accept: image/svg+xml or return PNG (binary) when request header is Accept: image/png.

Currently, Java generator does the following:

  • Sends ALL accept headers in the request, not being able to control that.
  • Generates a single method, using the information only from the first defined Accept.

Describe the solution you'd like

It would be great if the generator can take into account multiple Accept headers (when they exist). In that case it would create a method for each endpoint AND accept type. For example: fooAsImageSvgXml, fooAsImagePng - where the naming As... comes from the Accept definition.

Describe alternatives you've considered

I wanted to change the templates, but I would rather not maintain the fork.

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 by reviewing the Java generator's current handling of multiple Accept headers and how generated method names are derived from the first Accept definition. The work is complete when each endpoint and Accept type produces a distinct method, with the corresponding media type sent independently in its request.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.