7
7
8
8
namespace Microsoft . OpenApi . Readers . Tests . V32Tests ;
9
9
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.
13
10
public class OpenApiMediaTypeReferenceDeserializerTests
14
11
{
15
- /*
16
12
[ Fact ]
17
13
public void ShouldDeserializeMediaTypeReferenceInRequestBodyContent ( )
18
14
{
@@ -30,7 +26,7 @@ public void ShouldDeserializeMediaTypeReferenceInRequestBodyContent()
30
26
"requestBody": {
31
27
"content": {
32
28
"application/json": {
33
- "$ref": "#/components/mediaTypes/application~1json "
29
+ "$ref": "#/components/mediaTypes/MyCustomMediaTypeObject1.9-1_9 "
34
30
}
35
31
}
36
32
},
@@ -44,7 +40,7 @@ public void ShouldDeserializeMediaTypeReferenceInRequestBodyContent()
44
40
},
45
41
"components": {
46
42
"mediaTypes": {
47
- "application/json ": {
43
+ "MyCustomMediaTypeObject1.9-1_9 ": {
48
44
"schema": {
49
45
"type": "object",
50
46
"properties": {
@@ -71,8 +67,7 @@ public void ShouldDeserializeMediaTypeReferenceInRequestBodyContent()
71
67
Assert . True ( requestBody . Content . ContainsKey ( "application/json" ) ) ;
72
68
73
69
var mediaType = requestBody . Content [ "application/json" ] ;
74
- Assert.IsType<OpenApiMediaTypeReference>(mediaType);
75
- var mediaTypeRef = (OpenApiMediaTypeReference)mediaType;
70
+ var mediaTypeRef = Assert . IsType < OpenApiMediaTypeReference > ( mediaType ) ;
76
71
77
72
Assert . NotNull ( mediaTypeRef . Target ) ;
78
73
Assert . NotNull ( mediaTypeRef . Schema ) ;
@@ -98,7 +93,7 @@ public void ShouldDeserializeMediaTypeReferenceInResponseBodyContent()
98
93
"description": "OK",
99
94
"content": {
100
95
"application/json": {
101
- "$ref": "#/components/mediaTypes/application~1json "
96
+ "$ref": "#/components/mediaTypes/jsonMediaType "
102
97
}
103
98
}
104
99
}
@@ -108,7 +103,7 @@ public void ShouldDeserializeMediaTypeReferenceInResponseBodyContent()
108
103
},
109
104
"components": {
110
105
"mediaTypes": {
111
- "application/json ": {
106
+ "jsonMediaType ": {
112
107
"schema": {
113
108
"type": "object",
114
109
"properties": {
@@ -135,8 +130,7 @@ public void ShouldDeserializeMediaTypeReferenceInResponseBodyContent()
135
130
Assert . True ( response . Content . ContainsKey ( "application/json" ) ) ;
136
131
137
132
var mediaType = response . Content [ "application/json" ] ;
138
- Assert.IsType<OpenApiMediaTypeReference>(mediaType);
139
- var mediaTypeRef = (OpenApiMediaTypeReference)mediaType;
133
+ var mediaTypeRef = Assert . IsType < OpenApiMediaTypeReference > ( mediaType ) ;
140
134
141
135
Assert . NotNull ( mediaTypeRef . Target ) ;
142
136
Assert . NotNull ( mediaTypeRef . Schema ) ;
@@ -163,7 +157,7 @@ public void ShouldDeserializeMediaTypeReferenceInParameterContent()
163
157
"in": "query",
164
158
"content": {
165
159
"application/json": {
166
- "$ref": "#/components/mediaTypes/application~1json "
160
+ "$ref": "#/components/mediaTypes/jsonMediaType "
167
161
}
168
162
}
169
163
}
@@ -178,7 +172,7 @@ public void ShouldDeserializeMediaTypeReferenceInParameterContent()
178
172
},
179
173
"components": {
180
174
"mediaTypes": {
181
- "application/json ": {
175
+ "jsonMediaType ": {
182
176
"schema": {
183
177
"type": "string"
184
178
}
@@ -203,8 +197,7 @@ public void ShouldDeserializeMediaTypeReferenceInParameterContent()
203
197
Assert . True ( parameter . Content . ContainsKey ( "application/json" ) ) ;
204
198
205
199
var mediaType = parameter . Content [ "application/json" ] ;
206
- Assert.IsType<OpenApiMediaTypeReference>(mediaType);
207
- var mediaTypeRef = (OpenApiMediaTypeReference)mediaType;
200
+ var mediaTypeRef = Assert . IsType < OpenApiMediaTypeReference > ( mediaType ) ;
208
201
209
202
Assert . NotNull ( mediaTypeRef . Target ) ;
210
203
Assert . NotNull ( mediaTypeRef . Schema ) ;
@@ -233,7 +226,7 @@ public void ShouldDeserializeMediaTypeReferenceInHeaderContent()
233
226
"description": "Custom header",
234
227
"content": {
235
228
"application/json": {
236
- "$ref": "#/components/mediaTypes/application~1json "
229
+ "$ref": "#/components/mediaTypes/jsonMediaType "
237
230
}
238
231
}
239
232
}
@@ -245,7 +238,7 @@ public void ShouldDeserializeMediaTypeReferenceInHeaderContent()
245
238
},
246
239
"components": {
247
240
"mediaTypes": {
248
- "application/json ": {
241
+ "jsonMediaType ": {
249
242
"schema": {
250
243
"type": "array",
251
244
"items": {
@@ -273,12 +266,10 @@ public void ShouldDeserializeMediaTypeReferenceInHeaderContent()
273
266
Assert . True ( header . Content . ContainsKey ( "application/json" ) ) ;
274
267
275
268
var mediaType = header . Content [ "application/json" ] ;
276
- Assert.IsType<OpenApiMediaTypeReference>(mediaType);
277
- var mediaTypeRef = (OpenApiMediaTypeReference)mediaType;
269
+ var mediaTypeRef = Assert . IsType < OpenApiMediaTypeReference > ( mediaType ) ;
278
270
279
271
Assert . NotNull ( mediaTypeRef . Target ) ;
280
272
Assert . NotNull ( mediaTypeRef . Schema ) ;
281
273
Assert . Equal ( JsonSchemaType . Array , mediaTypeRef . Schema . Type ) ;
282
274
}
283
- */
284
275
}
0 commit comments