@@ -53,55 +53,19 @@ public void GivenAnOpenAPISpec_WhenGeneratingAPI_ExpectedClassesShouldHaveBeenGe
5353 generatedFiles . Should ( ) . ContainMatch ( "*.Operation.g.cs" ) ;
5454 }
5555
56- [ Fact ]
57- public void GivenAImplementedOperation_WhenGeneratingAPI_NoOperationHandlerStubsShouldBeGenerated ( )
56+
57+ [ Theory ]
58+ [ MemberData ( nameof ( OpenApiSpecsWithOperations ) ) ]
59+ public void GivenAImplementedOperation_WhenGeneratingAPI_NoOperationHandlerStubsShouldBeGenerated (
60+ string _ , string openApiSpec )
5861 {
5962 var generator = new ApiGenerator ( ) ;
6063
6164 GeneratorDriver driver = CSharpGeneratorDriver . Create ( generator ) ;
6265
6366 driver = driver . AddAdditionalTexts (
6467 [
65- new InMemoryAdditionalText ( "openapi.json" ,
66- """
67- {
68- "swagger": "2.0",
69- "info": {
70- "title": "foo",
71- "version": "1.0"
72- },
73- "paths": {
74- "/foo": {
75- "put": {
76- "operationId": "Service_SetProperties",
77- "description": "Sets properties for a storage account's File service endpoint, including properties for Storage Analytics metrics and CORS (Cross-Origin Resource Sharing) rules.",
78- "parameters": [
79- {
80- "name": "StorageServiceProperties",
81- "in": "body",
82- "description": "The StorageService properties.",
83- "required": true,
84- "schema": {
85- "description": "Storage service properties.",
86- "type": "object",
87- "properties": {
88- "HourMetrics": {
89- "description": "A summary of request statistics grouped by API in hourly aggregates for files.",
90- "type": "string"
91- }
92- }
93- }
94- }],
95- "responses": {
96- "202": {
97- "description": "Success (Accepted)"
98- }
99- }
100- }
101- }
102- }
103- }
104- """ )
68+ new InMemoryAdditionalText ( "openapi.json" , openApiSpec )
10569 ]
10670 ) ;
10771
@@ -226,4 +190,136 @@ private Compilation SetupGenerator(string openApiSpec, out ImmutableArray<Diagno
226190 return newCompilation ;
227191 }
228192
193+ public static TheoryData < string , string > OpenApiSpecsWithOperations => new ( )
194+ {
195+ {
196+ "Swagger 2.0" ,
197+ """
198+ {
199+ "swagger": "2.0",
200+ "info": { "title": "foo", "version": "1.0" },
201+ "paths": {
202+ "/foo": {
203+ "put": {
204+ "operationId": "Service_SetProperties",
205+ "parameters": [
206+ {
207+ "name": "body",
208+ "in": "body",
209+ "required": true,
210+ "schema": {
211+ "type": "object",
212+ "properties": {
213+ "HourMetrics": { "type": "string" }
214+ }
215+ }
216+ }
217+ ],
218+ "responses": {
219+ "202": { "description": "Success (Accepted)" }
220+ }
221+ }
222+ }
223+ }
224+ }
225+ """
226+ } ,
227+ {
228+ "OpenAPI 3.0" ,
229+ """
230+ {
231+ "openapi": "3.0.3",
232+ "info": { "title": "foo", "version": "1.0" },
233+ "paths": {
234+ "/foo": {
235+ "put": {
236+ "operationId": "Service_SetProperties",
237+ "requestBody": {
238+ "required": true,
239+ "content": {
240+ "application/json": {
241+ "schema": {
242+ "type": "object",
243+ "properties": {
244+ "HourMetrics": { "type": "string" }
245+ }
246+ }
247+ }
248+ }
249+ },
250+ "responses": {
251+ "202": { "description": "Success (Accepted)" }
252+ }
253+ }
254+ }
255+ }
256+ }
257+ """
258+ } ,
259+ {
260+ "OpenAPI 3.1" ,
261+ """
262+ {
263+ "openapi": "3.1.0",
264+ "info": { "title": "foo", "version": "1.0" },
265+ "paths": {
266+ "/foo": {
267+ "put": {
268+ "operationId": "Service_SetProperties",
269+ "requestBody": {
270+ "required": true,
271+ "content": {
272+ "application/json": {
273+ "schema": {
274+ "type": "object",
275+ "properties": {
276+ "HourMetrics": { "type": "string" }
277+ }
278+ }
279+ }
280+ }
281+ },
282+ "responses": {
283+ "202": { "description": "Success (Accepted)" }
284+ }
285+ }
286+ }
287+ }
288+ }
289+ """
290+ } ,
291+ {
292+ "OpenAPI 3.2" ,
293+ """
294+ {
295+ "openapi": "3.2.0",
296+ "info": { "title": "foo", "version": "1.0" },
297+ "paths": {
298+ "/foo": {
299+ "put": {
300+ "operationId": "Service_SetProperties",
301+ "requestBody": {
302+ "required": true,
303+ "content": {
304+ "application/json": {
305+ "schema": {
306+ "type": "object",
307+ "properties": {
308+ "HourMetrics": { "type": "string" }
309+ }
310+ }
311+ }
312+ }
313+ },
314+ "responses": {
315+ "202": { "description": "Success (Accepted)" }
316+ }
317+ }
318+ }
319+ }
320+ }
321+ """
322+ }
323+ } ;
324+
229325}
0 commit comments