Skip to content

Commit 7372bb8

Browse files
committed
Add more scenarios to snapsho tests
1 parent 5b44e5e commit 7372bb8

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

src/OpenApi/sample/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Collections.Frozen;
5+
using System.Collections.Immutable;
46
using System.ComponentModel;
57
using Microsoft.AspNetCore.Http.HttpResults;
68
using Microsoft.AspNetCore.Mvc;
@@ -101,6 +103,11 @@
101103
schemas.MapGet("/primitives", ([Description("The ID associated with the Todo item.")] int id, [Description("The number of Todos to fetch")] int size) => { });
102104
schemas.MapGet("/product", (Product product) => TypedResults.Ok(product));
103105
schemas.MapGet("/account", (Account account) => TypedResults.Ok(account));
106+
schemas.MapPost("/array-of-ints", (int[] values) => values.Sum());
107+
schemas.MapPost("/list-of-ints", (List<int> values) => values.Count);
108+
schemas.MapPost("/ienumerable-of-ints", (IEnumerable<int> values) => values.Count());
109+
schemas.MapGet("/dictionary-of-ints", () => new Dictionary<string, int> { { "one", 1 }, { "two", 2 } });
110+
schemas.MapGet("/frozen-dictionary-of-ints", () => ImmutableDictionary.CreateRange(new Dictionary<string, int> { { "one", 1 }, { "two", 2 } }));
104111

105112
app.MapControllers();
106113

src/OpenApi/test/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=schemas-by-ref.verified.txt

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,121 @@
175175
}
176176
}
177177
}
178+
},
179+
"/schemas-by-ref/array-of-ints": {
180+
"post": {
181+
"tags": [
182+
"Sample"
183+
],
184+
"requestBody": {
185+
"content": {
186+
"application/json": {
187+
"schema": {
188+
"$ref": "#/components/schemas/ArrayOfint"
189+
}
190+
}
191+
},
192+
"required": true
193+
},
194+
"responses": {
195+
"200": {
196+
"description": "OK",
197+
"content": {
198+
"application/json": {
199+
"schema": {
200+
"$ref": "#/components/schemas/int"
201+
}
202+
}
203+
}
204+
}
205+
}
206+
}
207+
},
208+
"/schemas-by-ref/list-of-ints": {
209+
"post": {
210+
"tags": [
211+
"Sample"
212+
],
213+
"requestBody": {
214+
"content": {
215+
"application/json": {
216+
"schema": {
217+
"$ref": "#/components/schemas/ArrayOfint"
218+
}
219+
}
220+
},
221+
"required": true
222+
},
223+
"responses": {
224+
"200": {
225+
"description": "OK",
226+
"content": {
227+
"application/json": {
228+
"schema": {
229+
"$ref": "#/components/schemas/int"
230+
}
231+
}
232+
}
233+
}
234+
}
235+
}
236+
},
237+
"/schemas-by-ref/ienumerable-of-ints": {
238+
"post": {
239+
"tags": [
240+
"Sample"
241+
],
242+
"responses": {
243+
"200": {
244+
"description": "OK",
245+
"content": {
246+
"application/json": {
247+
"schema": {
248+
"$ref": "#/components/schemas/int"
249+
}
250+
}
251+
}
252+
}
253+
}
254+
}
255+
},
256+
"/schemas-by-ref/dictionary-of-ints": {
257+
"get": {
258+
"tags": [
259+
"Sample"
260+
],
261+
"responses": {
262+
"200": {
263+
"description": "OK",
264+
"content": {
265+
"application/json": {
266+
"schema": {
267+
"$ref": "#/components/schemas/DictionaryOfstringAndint"
268+
}
269+
}
270+
}
271+
}
272+
}
273+
}
274+
},
275+
"/schemas-by-ref/frozen-dictionary-of-ints": {
276+
"get": {
277+
"tags": [
278+
"Sample"
279+
],
280+
"responses": {
281+
"200": {
282+
"description": "OK",
283+
"content": {
284+
"application/json": {
285+
"schema": {
286+
"$ref": "#/components/schemas/DictionaryOfstringAndint"
287+
}
288+
}
289+
}
290+
}
291+
}
292+
}
178293
}
179294
},
180295
"components": {
@@ -190,6 +305,18 @@
190305
}
191306
}
192307
},
308+
"ArrayOfint": {
309+
"type": "array",
310+
"items": {
311+
"$ref": "#/components/schemas/int"
312+
}
313+
},
314+
"DictionaryOfstringAndint": {
315+
"type": "object",
316+
"additionalProperties": {
317+
"$ref": "#/components/schemas/int"
318+
}
319+
},
193320
"int": {
194321
"type": "integer",
195322
"format": "int32"

0 commit comments

Comments
 (0)