1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT license.
3
3
4
+ using System . Collections . Generic ;
4
5
using System . Globalization ;
5
6
using System . IO ;
6
7
using FluentAssertions ;
7
8
using Microsoft . OpenApi . Any ;
8
9
using Microsoft . OpenApi . Extensions ;
10
+ using Microsoft . OpenApi . Interfaces ;
9
11
using Microsoft . OpenApi . Models ;
10
12
using Microsoft . OpenApi . Writers ;
11
13
using Xunit ;
@@ -33,7 +35,11 @@ public class OpenApiResponseTests
33
35
Reference = new OpenApiReference { Type = ReferenceType . Schema , Id = "customType" }
34
36
}
35
37
} ,
36
- Example = new OpenApiString ( "Blabla" )
38
+ Example = new OpenApiString ( "Blabla" ) ,
39
+ Extensions = new Dictionary < string , IOpenApiExtension >
40
+ {
41
+ [ "myextension" ] = new OpenApiString ( "myextensionvalue" ) ,
42
+ } ,
37
43
}
38
44
} ,
39
45
Headers =
@@ -158,7 +164,8 @@ public void SerializeAdvancedResponseAsV3JsonWorks()
158
164
""$ref"": ""#/components/schemas/customType""
159
165
}
160
166
},
161
- ""example"": ""Blabla""
167
+ ""example"": ""Blabla"",
168
+ ""myextension"": ""myextensionvalue""
162
169
}
163
170
}
164
171
}" ;
@@ -193,7 +200,8 @@ public void SerializeAdvancedResponseAsV3YamlWorks()
193
200
type: array
194
201
items:
195
202
$ref: '#/components/schemas/customType'
196
- example: Blabla" ;
203
+ example: Blabla
204
+ myextension: myextensionvalue" ;
197
205
198
206
// Act
199
207
var actual = AdvancedResponse . SerializeAsYaml ( OpenApiSpecVersion . OpenApi3_0 ) ;
@@ -219,6 +227,7 @@ public void SerializeAdvancedResponseAsV2JsonWorks()
219
227
""examples"": {
220
228
""text/plain"": ""Blabla""
221
229
},
230
+ ""myextension"": ""myextensionvalue"",
222
231
""headers"": {
223
232
""X-Rate-Limit-Limit"": {
224
233
""description"": ""The number of allowed requests in the current period"",
@@ -252,6 +261,7 @@ public void SerializeAdvancedResponseAsV2YamlWorks()
252
261
$ref: '#/definitions/customType'
253
262
examples:
254
263
text/plain: Blabla
264
+ myextension: myextensionvalue
255
265
headers:
256
266
X-Rate-Limit-Limit:
257
267
description: The number of allowed requests in the current period
0 commit comments