OpenAPITools / OpenAPITools/openapi-generator

[REQ] Support RFC7807 problem response type

Open
#4,890 1 comment 2 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.

RFC7807 is an error response specification. It comes with its own Content-Types:

  • application/problem+json
  • application/problem+xml

Unfortunately the Content-Type checks does not match these.

I use the generator for generating Go code, the affected lines are https://github.com/OpenAPITools/openapi-generator/blob/af783a8/modules/openapi-generator/src/main/resources/go/client.mustache#L33-L36

But I think other languages might also benefit from this feature.

Describe the solution you'd like

In the specific case, I'd change the regular expressions to the following:

var (
	jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:(?:vnd\.[^;]+\+)|(?:problem\+))?json)`)
	xmlCheck  = regexp.MustCompile(`(?i:(?:application|text)/(?:problem\+)?xml)`)
)

I can imagine a better optimized regex, but this one is probably more readable.

Describe alternatives you've considered

Currently I run a post-processor script on the generated code, but it would be nice if it supported the RFC OOTB.

Additional context

I'm happy to provide a PR to change the above linked code.

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 in modules/openapi-generator/src/main/resources/go/client.mustache at lines 33-36, then read the RFC7807 content types linked in the issue. Update the Go client's Content-Type handling to recognize the specified problem response types, and verify that generated Go code handles both JSON and XML variants.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.