Skip to content

Commit

Permalink
Make it the same way with AnyOf and OneOf
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddenmarten committed Dec 1, 2024
1 parent 261bbbf commit f19f08e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions internal/test/issues/issue-1476/issue1476.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions pkg/codegen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,6 @@ func GenerateGoSchema(sref *openapi3.SchemaRef, path []string) (Schema, error) {
for _, pName := range SortedSchemaKeys(schema.Properties) {
p := schema.Properties[pName]

// Merge allOf in property
if p.Value.AllOf != nil {
val, err := mergeAllOf(p.Value.AllOf)
if err != nil {
return Schema{}, fmt.Errorf("error generating Go schema from allOf for property '%s': %w", pName, err)
}
p.Value = &val
}

propertyPath := append(path, pName)
pSchema, err := GenerateGoSchema(p, propertyPath)
if err != nil {
Expand Down Expand Up @@ -446,6 +437,11 @@ func GenerateGoSchema(sref *openapi3.SchemaRef, path []string) (Schema, error) {
}
}

if schema.AllOf != nil {
if err := generateUnion(&outSchema, schema.AllOf, schema.Discriminator, path); err != nil {
return Schema{}, fmt.Errorf("error generating type for allOf: %w", err)
}
}
if schema.AnyOf != nil {
if err := generateUnion(&outSchema, schema.AnyOf, schema.Discriminator, path); err != nil {
return Schema{}, fmt.Errorf("error generating type for anyOf: %w", err)
Expand Down

0 comments on commit f19f08e

Please sign in to comment.