Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions internal/generate/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ func convertToValidGoType(property, typeName string, r *openapi3.SchemaRef) stri
}

func schemaValueToGoType(schemaValue *openapi3.Schema, property string) string {
// In the special case of an array of nullable items, we represent the
// item type with an allOf of length 1. In this case, return the schema
// of the 0th entry in anyOf.
if len(schemaValue.AllOf) == 1 {
value := schemaValue.AllOf[0]
reference := getReferenceSchema(value)
if reference == "" {
fmt.Printf("[WARN] TODO: handle allOf %+v for %q, marking as any for now\n", value, property)
return "any"
}
if schemaValue.Nullable {
reference = fmt.Sprintf("*%s", reference)
}
return reference
}

if schemaValue.Type == nil {
fmt.Printf("[WARN] TODO: handle nil type for %q, marking as any for now\n", property)
return "any"
Expand Down
8 changes: 4 additions & 4 deletions oxide/types.go

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