-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I'm creating a spec for an application/hal+json API but the resulting Go client raises an "undefined response type" error for every operation because it only treats responses with a Content-Type that conforms to application/vnd.*+json as JSON. Hence, application/hal+json is considered an "unknown" content type.
My understanding of RFC 6838, which the OpenAPI docs say is the source of truth for supported media types, is that any media type with a +suffix should conform to the suffix type. By that logic, I expect the client to treat any media type with the suffix +json as JSON and +xml as XML. I'm not using XML but it only supports application/xml so may as well update it while touching the JSON regular expression.
Assuming my understanding isn't flawed the fix is a fairly simple change to two regular expressions that I'll open a PR for but starting with an issue per the contribution guidelines. Happy to provide additional details upon request but given the simplicity of the issue they seem unnecessary.
openapi-generator version
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
openapi-generator/modules/openapi-generator/src/main/resources/go/client.mustache
Lines 36 to 37 in 2cfce7c
| jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) | |
| xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) |
Would be updated to
jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`)
xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`)