11using Microsoft . OpenApi . Models ;
2+ using Microsoft . OpenApi . Models . Interfaces ;
23
34namespace JsonApiDotNetCore . OpenApi . Swashbuckle ;
45
@@ -9,22 +10,23 @@ public static void ReorderProperties(this OpenApiSchema fullSchema, IEnumerable<
910 ArgumentNullException . ThrowIfNull ( fullSchema ) ;
1011 ArgumentNullException . ThrowIfNull ( propertyNamesInOrder ) ;
1112
12- var propertiesInOrder = new Dictionary < string , OpenApiSchema > ( ) ;
13+ var propertiesInOrder = new Dictionary < string , IOpenApiSchema > ( ) ;
1314
1415 foreach ( string propertyName in propertyNamesInOrder )
1516 {
16- if ( fullSchema . Properties . TryGetValue ( propertyName , out OpenApiSchema ? schema ) )
17+ if ( fullSchema . Properties != null && fullSchema . Properties . TryGetValue ( propertyName , out IOpenApiSchema ? schema ) )
1718 {
1819 propertiesInOrder . Add ( propertyName , schema ) ;
1920 }
2021 }
2122
23+ ConsistencyGuard . ThrowIf ( fullSchema . Properties == null ) ;
2224 ConsistencyGuard . ThrowIf ( fullSchema . Properties . Count != propertiesInOrder . Count ) ;
2325
2426 fullSchema . Properties = propertiesInOrder ;
2527 }
2628
27- public static OpenApiSchema WrapInExtendedSchema ( this OpenApiSchema source )
29+ public static OpenApiSchema WrapInExtendedSchema ( this IOpenApiSchema source )
2830 {
2931 ArgumentNullException . ThrowIfNull ( source ) ;
3032
@@ -34,11 +36,11 @@ public static OpenApiSchema WrapInExtendedSchema(this OpenApiSchema source)
3436 } ;
3537 }
3638
37- public static OpenApiSchema UnwrapLastExtendedSchema ( this OpenApiSchema source )
39+ public static IOpenApiSchema UnwrapLastExtendedSchema ( this IOpenApiSchema source )
3840 {
3941 ArgumentNullException . ThrowIfNull ( source ) ;
4042
41- if ( source . AllOf is { Count : > 0 } )
43+ if ( source is OpenApiSchema && source . AllOf is { Count : > 0 } )
4244 {
4345 return source . AllOf . Last ( ) ;
4446 }
0 commit comments