swagger-api / swagger-api/swagger-codegen
Properties defined within allOf omitted depending on ordering
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Properties defined via an inline object definition as part of an allOf appear to be dropped when followed by a reference to a named type.
The following definition:
{
"openapi": "3.0.3",
"info": {
"title": "Example",
"version": "0.0.1"
},
"paths": {},
"components": {
"schemas": {
"A": {
"type": "object",
"properties": {
"a": { "type": "string" }
}
},
"B": {
"allOf": [
{
"type": "object",
"properties": {
"b": { "type": "string" }
}
},
{ "$ref": "#/components/schemas/A" }
]
},
"C": {
"allOf": [
{ "$ref": "#/components/schemas/A" },
{
"type": "object",
"properties": {
"c": { "type": "string" }
}
}
]
}
}
}
}
produces these models when run using the online tool - note that the property b is omitted from B:
type A struct {
A string `json:"a,omitempty"`
}
type B struct {
A string `json:"a,omitempty"`
}
type C struct {
A string `json:"a,omitempty"`
C string `json:"c,omitempty"`
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied OpenAPI 3.0.3 example in the online tool and compare the generated Go models for B and C. Trace the allOf handling for inline object properties followed by a named $ref; done means B retains property b while C retains property c and both preserve property a.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100