-
-
Notifications
You must be signed in to change notification settings - Fork 954
fix: correctly generate structs and properties for anyOf
s
#1178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: correctly generate structs and properties for anyOf
s
#1178
Conversation
…number An issue oapi-codegen#1121 was reported that use of AnyOf inline generates invalid go code for client. This PR fixes 2 issues: 1. When status code is the starting element of path PathToTypeName will generated names starting with a number 2. When we have UnionElements and we use PathToTypeName to generate a reference type, we are not creating the struct for it Closes oapi-codegen#1121
I accidentally closed #1136 and lost the changes. Recovered the commits and opening a new PR here. |
@deepmap-marcinr I have addressed your comment on #1136 and fixed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @daleef-rahman looks like we're missing the config for oapi-codegen to generate the code for internal/test/any_of/codegen
- mind adding?
@jamietanna Added the missing config. Please check now. |
@daleef-rahman FYI, i tried this fork on a schema i had issues with. i have a scenario where the fix outputs the same struct twice: operationId: myOperation
responses:
"200":
content:
application/something.v1+json:
schema:
type: array
items:
type: object
oneOf:
- $ref: '#/components/schemas/Ref1'
- $ref: '#/components/schemas/Ref2'
- $ref: '#/components/schemas/Ref3'
application/json:
schema:
type: array
items:
type: object
oneOf:
- $ref: '#/components/schemas/Ref1'
- $ref: '#/components/schemas/Ref2'
- $ref: '#/components/schemas/Ref3' output: type MyOperation_200_Item struct {
union json.RawMessage
}
type MyOperation_200_Item struct {
union json.RawMessage
} i don't know why the schema looks the way it does and i have no control over it, but it seems to be valid. Note Maintainer edit: this issue is related to #1367 |
I'll come back to this one - in particular re #1178 (comment) which seems interesting, and could be an existing issue |
anyOf
s
anyOf
sanyOf
s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
#1121 reports that use of AnyOf inline generates invalid go code for client (struct type names starting with a number).
This PR fixes 2 issues:
Closes #1121