ogen-go / ogen

OpenAPI v3 code generator for go
https://ogen.dev
Apache License 2.0
1.43k stars 84 forks source link

gen: support `application/problem+json` Content-Type #883

Closed p1ass closed 1 year ago

p1ass commented 1 year ago

Description

I request support for the application/problem+json Content-Type.

Calling API server returns error responses as application/problem+json which is defined by RFC 7808. ogen does not currently support application/problem+json, so when I use a generated API client, I got the below error:

decode response: default (code 404): unexpected Content-Type: application/problem+json

References

tdakkota commented 1 year ago
  1. OpenAPI Spec you're using should define response with a application/problem+json content type.
  2. To avoid Content types ... are unsupported error, you may instruct ogen to decode application/problem+json like JSON by using --ct-alias "application/problem+json=application/json" option.
  3. If response schema is properly defined, generated code would be able to decode the problem object.

It doesn't seem like any special support needed.

p1ass commented 1 year ago

I missed that parameter. It worked fine! Thanks for letting me know!