@@ -57,18 +57,21 @@ public void RemoveAnyOfAndOneOfFromSchema()
57
57
var walker = new OpenApiWalker ( powerShellFormatter ) ;
58
58
walker . Walk ( openApiDocument ) ;
59
59
60
- var testSchema = openApiDocument . Components . Schemas [ "TestSchema" ] ;
61
- var averageAudioDegradationProperty = testSchema . Properties [ "averageAudioDegradation" ] ;
62
- var defaultPriceProperty = testSchema . Properties [ "defaultPrice" ] ;
60
+ var testSchema = openApiDocument . Components ? . Schemas ? [ "TestSchema" ] ;
61
+ var averageAudioDegradationProperty = testSchema ? . Properties [ "averageAudioDegradation" ] ;
62
+ var defaultPriceProperty = testSchema ? . Properties [ "defaultPrice" ] ;
63
63
64
64
// Assert
65
- Assert . Null ( averageAudioDegradationProperty . AnyOf ) ;
66
- Assert . Equal ( "number" , averageAudioDegradationProperty . Type ) ;
67
- Assert . Equal ( "float" , averageAudioDegradationProperty . Format ) ;
68
- Assert . True ( averageAudioDegradationProperty . Nullable ) ;
69
- Assert . Null ( defaultPriceProperty . OneOf ) ;
70
- Assert . Equal ( "number" , defaultPriceProperty . Type ) ;
71
- Assert . Equal ( "double" , defaultPriceProperty . Format ) ;
65
+ Assert . NotNull ( openApiDocument . Components ) ;
66
+ Assert . NotNull ( openApiDocument . Components . Schemas ) ;
67
+ Assert . NotNull ( testSchema ) ;
68
+ Assert . Null ( averageAudioDegradationProperty ? . AnyOf ) ;
69
+ Assert . Equal ( "number" , averageAudioDegradationProperty ? . Type ) ;
70
+ Assert . Equal ( "float" , averageAudioDegradationProperty ? . Format ) ;
71
+ Assert . True ( averageAudioDegradationProperty ? . Nullable ) ;
72
+ Assert . Null ( defaultPriceProperty ? . OneOf ) ;
73
+ Assert . Equal ( "number" , defaultPriceProperty ? . Type ) ;
74
+ Assert . Equal ( "double" , defaultPriceProperty ? . Format ) ;
72
75
Assert . NotNull ( testSchema . AdditionalProperties ) ;
73
76
}
74
77
@@ -83,12 +86,12 @@ public void ResolveFunctionParameters()
83
86
var walker = new OpenApiWalker ( powerShellFormatter ) ;
84
87
walker . Walk ( openApiDocument ) ;
85
88
86
- var idsParameter = openApiDocument . Paths [ "/foo" ] . Operations [ OperationType . Get ] . Parameters . Where ( static p => p . Name == "ids" ) . FirstOrDefault ( ) ;
89
+ var idsParameter = openApiDocument . Paths ? [ "/foo" ] . Operations [ OperationType . Get ] . Parameters ? . Where ( static p => p . Name == "ids" ) . FirstOrDefault ( ) ;
87
90
88
91
// Assert
89
92
Assert . Null ( idsParameter ? . Content ) ;
90
93
Assert . NotNull ( idsParameter ? . Schema ) ;
91
- Assert . Equal ( "array" , idsParameter ? . Schema . Type ) ;
94
+ Assert . Equal ( "array" , idsParameter . Schema . Type ) ;
92
95
}
93
96
94
97
private static OpenApiDocument GetSampleOpenApiDocument ( )
0 commit comments