diff --git a/spec.go b/spec.go index a2468c2e..cfc35fe4 100644 --- a/spec.go +++ b/spec.go @@ -66,7 +66,7 @@ func (FileSpec) JSONSchemaExtend(sc *jsonschema.Schema) { }) // now we need to enforce format -> specific type - sc.OneOf = []*jsonschema.Schema{ + formatSpecOneOf := []*jsonschema.Schema{ // CSV { Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] { @@ -110,6 +110,16 @@ func (FileSpec) JSONSchemaExtend(sc *jsonschema.Schema) { }(), }, } + if sc.OneOf == nil { + sc.OneOf = formatSpecOneOf + } else { + // may happen when embedding, so move to all_of{{one_of},{one_of}} + sc.AllOf = []*jsonschema.Schema{ + {OneOf: sc.OneOf}, + {OneOf: formatSpecOneOf}, + } + sc.OneOf = nil + } } func (s *FileSpec) SetDefaults() {