fix: correctly generate structs and properties for anyOfs#1178
fix: correctly generate structs and properties for anyOfs#1178jamietanna merged 15 commits intooapi-codegen:mainfrom
anyOfs#1178Conversation
…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 |
jamietanna
left a comment
There was a problem hiding this comment.
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 |
anyOfs
anyOfsanyOfs
#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