@@ -225,7 +225,7 @@ type DefinitionCompiler(schema: OpenApiDocument, provideNullable) as this =
225225 let ns , tyName = tyPath |> DefinitionPath.Parse |> nsRoot.Resolve
226226 let ty = compileBySchema ns tyName def true ( registerInNsAndInDef tyPath ns) true
227227 ty :> Type
228- | None when tyPath.StartsWith( DefinitionPath.DefinitionPrefix) ->
228+ | None when tyPath.StartsWith DefinitionPath.DefinitionPrefix ->
229229 failwithf $" Cannot find definition '%s {tyPath}' in schema definitions %A {pathToType.Keys |> Seq.toArray}"
230230 | None -> failwithf $" Cannot find definition '%s {tyPath}' (references to relative documents are not supported yet)"
231231
@@ -244,23 +244,27 @@ type DefinitionCompiler(schema: OpenApiDocument, provideNullable) as this =
244244 registerNew( tyName, ty :> Type)
245245
246246 // Combine composite schemas
247+ let hasAllOf =
248+ match schemaObj.AllOf with
249+ | null -> false
250+ | _ -> schemaObj.AllOf.Count > 0
251+
247252 let schemaObjProperties =
248- match schemaObj.AllOf.Count > 0 with
253+ match hasAllOf with
249254 | true ->
250255 schemaObj.AllOf
251256 |> Seq.append [ schemaObj ]
252- |> Seq.collect( _. Properties)
257+ |> Seq.collect _. Properties
253258 | false -> schemaObj.Properties
259+ |> fun x -> if isNull x then Seq.empty else x
260+
254261
255262 let schemaObjRequired =
256- match schemaObj.AllOf.Count > 0 with
257- | true ->
258- schemaObj.AllOf
259- |> Seq.append [ schemaObj ]
260- |> Seq.collect(_. Required)
261- |> System.Collections.Generic.HashSet
262- :> System.Collections.Generic.ISet< string>
263+ match hasAllOf with
264+ | true -> schemaObj.AllOf |> Seq.append [ schemaObj ] |> Seq.collect _. Required
263265 | false -> schemaObj.Required
266+ |> fun x -> if isNull x then Seq.empty else x
267+ |> Set.ofSeq
264268
265269 // Generate fields and properties
266270 let members =
@@ -270,10 +274,10 @@ type DefinitionCompiler(schema: OpenApiDocument, provideNullable) as this =
270274 |> List.map( fun p ->
271275 let propName , propSchema = p.Key, p.Value
272276
273- if String.IsNullOrEmpty( propName) then
277+ if String.IsNullOrEmpty propName then
274278 failwithf $" Property cannot be created with empty name. TypeName:%A {tyName}; SchemaObj:%A {schemaObj}"
275279
276- let isRequired = schemaObjRequired.Contains( propName)
280+ let isRequired = schemaObjRequired.Contains propName
277281
278282 let pTy =
279283 compileBySchema ns ( ns.ReserveUniqueName tyName ( nicePascalName propName)) propSchema isRequired ns.RegisterType false
0 commit comments