Bug Report Checklist
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
|
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)`)
Bug Report Checklist
Description
I'm creating a spec for an
application/hal+jsonAPI but the resulting Go client raises an "undefined response type" error for every operation because it only treats responses with aContent-Typethat conforms toapplication/vnd.*+jsonas JSON. Hence,application/hal+jsonis 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
+suffixshould conform to the suffix type. By that logic, I expect the client to treat any media type with the suffix+jsonas JSON and+xmlas XML. I'm not using XML but it only supportsapplication/xmlso 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
Would be updated to