77
88namespace Microsoft . OpenApi . Readers . Tests . V32Tests ;
99
10- // NOTE: These tests are currently disabled because media type reference deserialization
11- // support needs to be implemented in the parser. The tests are kept here as a specification
12- // of the expected behavior once parser support is added.
1310public class OpenApiMediaTypeReferenceDeserializerTests
1411{
15- /*
1612 [ Fact ]
1713 public void ShouldDeserializeMediaTypeReferenceInRequestBodyContent ( )
1814 {
@@ -30,7 +26,7 @@ public void ShouldDeserializeMediaTypeReferenceInRequestBodyContent()
3026 "requestBody": {
3127 "content": {
3228 "application/json": {
33- "$ref": "#/components/mediaTypes/application~1json "
29+ "$ref": "#/components/mediaTypes/MyCustomMediaTypeObject1.9-1_9 "
3430 }
3531 }
3632 },
@@ -44,7 +40,7 @@ public void ShouldDeserializeMediaTypeReferenceInRequestBodyContent()
4440 },
4541 "components": {
4642 "mediaTypes": {
47- "application/json ": {
43+ "MyCustomMediaTypeObject1.9-1_9 ": {
4844 "schema": {
4945 "type": "object",
5046 "properties": {
@@ -71,8 +67,7 @@ public void ShouldDeserializeMediaTypeReferenceInRequestBodyContent()
7167 Assert . True ( requestBody . Content . ContainsKey ( "application/json" ) ) ;
7268
7369 var mediaType = requestBody . Content [ "application/json" ] ;
74- Assert.IsType<OpenApiMediaTypeReference>(mediaType);
75- var mediaTypeRef = (OpenApiMediaTypeReference)mediaType;
70+ var mediaTypeRef = Assert . IsType < OpenApiMediaTypeReference > ( mediaType ) ;
7671
7772 Assert . NotNull ( mediaTypeRef . Target ) ;
7873 Assert . NotNull ( mediaTypeRef . Schema ) ;
@@ -98,7 +93,7 @@ public void ShouldDeserializeMediaTypeReferenceInResponseBodyContent()
9893 "description": "OK",
9994 "content": {
10095 "application/json": {
101- "$ref": "#/components/mediaTypes/application~1json "
96+ "$ref": "#/components/mediaTypes/jsonMediaType "
10297 }
10398 }
10499 }
@@ -108,7 +103,7 @@ public void ShouldDeserializeMediaTypeReferenceInResponseBodyContent()
108103 },
109104 "components": {
110105 "mediaTypes": {
111- "application/json ": {
106+ "jsonMediaType ": {
112107 "schema": {
113108 "type": "object",
114109 "properties": {
@@ -135,8 +130,7 @@ public void ShouldDeserializeMediaTypeReferenceInResponseBodyContent()
135130 Assert . True ( response . Content . ContainsKey ( "application/json" ) ) ;
136131
137132 var mediaType = response . Content [ "application/json" ] ;
138- Assert.IsType<OpenApiMediaTypeReference>(mediaType);
139- var mediaTypeRef = (OpenApiMediaTypeReference)mediaType;
133+ var mediaTypeRef = Assert . IsType < OpenApiMediaTypeReference > ( mediaType ) ;
140134
141135 Assert . NotNull ( mediaTypeRef . Target ) ;
142136 Assert . NotNull ( mediaTypeRef . Schema ) ;
@@ -163,7 +157,7 @@ public void ShouldDeserializeMediaTypeReferenceInParameterContent()
163157 "in": "query",
164158 "content": {
165159 "application/json": {
166- "$ref": "#/components/mediaTypes/application~1json "
160+ "$ref": "#/components/mediaTypes/jsonMediaType "
167161 }
168162 }
169163 }
@@ -178,7 +172,7 @@ public void ShouldDeserializeMediaTypeReferenceInParameterContent()
178172 },
179173 "components": {
180174 "mediaTypes": {
181- "application/json ": {
175+ "jsonMediaType ": {
182176 "schema": {
183177 "type": "string"
184178 }
@@ -203,8 +197,7 @@ public void ShouldDeserializeMediaTypeReferenceInParameterContent()
203197 Assert . True ( parameter . Content . ContainsKey ( "application/json" ) ) ;
204198
205199 var mediaType = parameter . Content [ "application/json" ] ;
206- Assert.IsType<OpenApiMediaTypeReference>(mediaType);
207- var mediaTypeRef = (OpenApiMediaTypeReference)mediaType;
200+ var mediaTypeRef = Assert . IsType < OpenApiMediaTypeReference > ( mediaType ) ;
208201
209202 Assert . NotNull ( mediaTypeRef . Target ) ;
210203 Assert . NotNull ( mediaTypeRef . Schema ) ;
@@ -233,7 +226,7 @@ public void ShouldDeserializeMediaTypeReferenceInHeaderContent()
233226 "description": "Custom header",
234227 "content": {
235228 "application/json": {
236- "$ref": "#/components/mediaTypes/application~1json "
229+ "$ref": "#/components/mediaTypes/jsonMediaType "
237230 }
238231 }
239232 }
@@ -245,7 +238,7 @@ public void ShouldDeserializeMediaTypeReferenceInHeaderContent()
245238 },
246239 "components": {
247240 "mediaTypes": {
248- "application/json ": {
241+ "jsonMediaType ": {
249242 "schema": {
250243 "type": "array",
251244 "items": {
@@ -273,12 +266,10 @@ public void ShouldDeserializeMediaTypeReferenceInHeaderContent()
273266 Assert . True ( header . Content . ContainsKey ( "application/json" ) ) ;
274267
275268 var mediaType = header . Content [ "application/json" ] ;
276- Assert.IsType<OpenApiMediaTypeReference>(mediaType);
277- var mediaTypeRef = (OpenApiMediaTypeReference)mediaType;
269+ var mediaTypeRef = Assert . IsType < OpenApiMediaTypeReference > ( mediaType ) ;
278270
279271 Assert . NotNull ( mediaTypeRef . Target ) ;
280272 Assert . NotNull ( mediaTypeRef . Schema ) ;
281273 Assert . Equal ( JsonSchemaType . Array , mediaTypeRef . Schema . Type ) ;
282274 }
283- */
284275}
0 commit comments