Skip to content

Commit c2998fa

Browse files
committed
test: include all spec version when testing default response constructor
1 parent d16906f commit c2998fa

3 files changed

Lines changed: 230 additions & 160 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using Xunit;
2+
3+
namespace OpenAPI.WebApiGenerator.Tests;
4+
5+
public partial class ApiGeneratorTests
6+
{
7+
public static TheoryData<string, string> NoResponseContentSpecs => new()
8+
{
9+
{
10+
"Swagger 2.0",
11+
"""
12+
{
13+
"swagger": "2.0",
14+
"info": { "title": "foo", "version": "1.0" },
15+
"paths": {
16+
"/foo": {
17+
"delete": {
18+
"operationId": "Delete",
19+
"responses": {
20+
"202": { "description": "Success" }
21+
}
22+
}
23+
}
24+
}
25+
}
26+
"""
27+
},
28+
{
29+
"OpenAPI 3.0",
30+
"""
31+
{
32+
"openapi": "3.0.3",
33+
"info": { "title": "foo", "version": "1.0" },
34+
"paths": {
35+
"/foo": {
36+
"delete": {
37+
"operationId": "Delete",
38+
"responses": {
39+
"202": { "description": "Success" }
40+
}
41+
}
42+
}
43+
}
44+
}
45+
"""
46+
},
47+
{
48+
"OpenAPI 3.1",
49+
"""
50+
{
51+
"openapi": "3.1.0",
52+
"info": { "title": "foo", "version": "1.0" },
53+
"paths": {
54+
"/foo": {
55+
"delete": {
56+
"operationId": "Delete",
57+
"responses": {
58+
"202": { "description": "Success" }
59+
}
60+
}
61+
}
62+
}
63+
}
64+
"""
65+
},
66+
{
67+
"OpenAPI 3.2",
68+
"""
69+
{
70+
"openapi": "3.2.0",
71+
"info": { "title": "foo", "version": "1.0" },
72+
"paths": {
73+
"/foo": {
74+
"delete": {
75+
"operationId": "Delete",
76+
"responses": {
77+
"202": { "description": "Success" }
78+
}
79+
}
80+
}
81+
}
82+
}
83+
"""
84+
}
85+
};
86+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
using Xunit;
2+
3+
namespace OpenAPI.WebApiGenerator.Tests;
4+
5+
public partial class ApiGeneratorTests
6+
{
7+
public static TheoryData<string, string> OpenApiSpecsWithOperations => new()
8+
{
9+
{
10+
"Swagger 2.0",
11+
"""
12+
{
13+
"swagger": "2.0",
14+
"info": { "title": "foo", "version": "1.0" },
15+
"paths": {
16+
"/foo": {
17+
"put": {
18+
"operationId": "Service_SetProperties",
19+
"parameters": [
20+
{
21+
"name": "body",
22+
"in": "body",
23+
"required": true,
24+
"schema": {
25+
"type": "object",
26+
"properties": {
27+
"HourMetrics": { "type": "string" }
28+
}
29+
}
30+
}
31+
],
32+
"responses": {
33+
"202": { "description": "Success (Accepted)" }
34+
}
35+
}
36+
}
37+
}
38+
}
39+
"""
40+
},
41+
{
42+
"OpenAPI 3.0",
43+
"""
44+
{
45+
"openapi": "3.0.3",
46+
"info": { "title": "foo", "version": "1.0" },
47+
"paths": {
48+
"/foo": {
49+
"put": {
50+
"operationId": "Service_SetProperties",
51+
"requestBody": {
52+
"required": true,
53+
"content": {
54+
"application/json": {
55+
"schema": {
56+
"type": "object",
57+
"properties": {
58+
"HourMetrics": { "type": "string" }
59+
}
60+
}
61+
}
62+
}
63+
},
64+
"responses": {
65+
"202": { "description": "Success (Accepted)" }
66+
}
67+
}
68+
}
69+
}
70+
}
71+
"""
72+
},
73+
{
74+
"OpenAPI 3.1",
75+
"""
76+
{
77+
"openapi": "3.1.0",
78+
"info": { "title": "foo", "version": "1.0" },
79+
"paths": {
80+
"/foo": {
81+
"put": {
82+
"operationId": "Service_SetProperties",
83+
"requestBody": {
84+
"required": true,
85+
"content": {
86+
"application/json": {
87+
"schema": {
88+
"type": "object",
89+
"properties": {
90+
"HourMetrics": { "type": "string" }
91+
}
92+
}
93+
}
94+
}
95+
},
96+
"responses": {
97+
"202": { "description": "Success (Accepted)" }
98+
}
99+
}
100+
}
101+
}
102+
}
103+
"""
104+
},
105+
{
106+
"OpenAPI 3.2",
107+
"""
108+
{
109+
"openapi": "3.2.0",
110+
"info": { "title": "foo", "version": "1.0" },
111+
"paths": {
112+
"/foo": {
113+
"put": {
114+
"operationId": "Service_SetProperties",
115+
"requestBody": {
116+
"required": true,
117+
"content": {
118+
"application/json": {
119+
"schema": {
120+
"type": "object",
121+
"properties": {
122+
"HourMetrics": { "type": "string" }
123+
}
124+
}
125+
}
126+
}
127+
},
128+
"responses": {
129+
"202": { "description": "Success (Accepted)" }
130+
}
131+
}
132+
}
133+
}
134+
}
135+
"""
136+
}
137+
};
138+
}

0 commit comments

Comments
 (0)