Skip to content

Commit 1adcd4b

Browse files
authored
Merge pull request #5 from livesession/fix/x-go-type-override-on-ref
fix(x-go-type-override-on-ref): fix impl for go type override
2 parents be3b9ef + 70f4608 commit 1adcd4b

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

internal/test/x-go/x-go-type/override_on_ref/Makefile

Lines changed: 0 additions & 2 deletions
This file was deleted.

internal/test/x-go/x-go-type/override_on_ref/x_go_type_override_on_ref.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/codegen/schema.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,19 @@ func GenerateGoSchema(sref *openapi3.SchemaRef, path []string) (Schema, error) {
334334
return mergedSchema, nil
335335
}
336336

337+
// AllOf is interesting, and useful. It's the union of a number of other
338+
// schemas. A common usage is to create a union of an object with an ID,
339+
// so that in a RESTful paradigm, the Create operation can return
340+
// (object, id), so that other operations can refer to (id)
341+
if schema.AllOf != nil {
342+
mergedSchema, err := MergeSchemas(schema, path)
343+
if err != nil {
344+
return Schema{}, fmt.Errorf("error merging schemas: %w", err)
345+
}
346+
mergedSchema.OAPISchema = schema
347+
return mergedSchema, nil
348+
}
349+
337350
// Schema type and format, eg. string / binary
338351
t := schema.Type
339352
// Handle objects and empty schemas first as a special case

0 commit comments

Comments
 (0)