@@ -196,12 +196,10 @@ type TestNonTaggedType struct {
196
196
197
197
func TestOpenAPI3SwaggerGen (t * testing.T ) {
198
198
doc := NewSwaggerGen (& SwaggerGenOptions {
199
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
200
- Title : "UnitTest" ,
201
- Version : "1.0" ,
202
- SupportFieldRedaction : true ,
203
- },
204
- BaseURL : "http://localhost:12345/api/v1" ,
199
+ Title : "UnitTest" ,
200
+ Version : "1.0" ,
201
+ SupportFieldRedaction : true ,
202
+ BaseURL : "http://localhost:12345/api/v1" ,
205
203
RouteCustomizations : func (ctx context.Context , sg * SwaggerGen , route * Route , op * openapi3.Operation ) {
206
204
sg .AddParam (ctx , op , "header" , "x-my-param" , "thing" , "stuff" , ExampleDesc , false )
207
205
},
@@ -233,10 +231,8 @@ func TestBadCustomInputSchemaFail(t *testing.T) {
233
231
}
234
232
assert .Panics (t , func () {
235
233
_ = NewSwaggerGen (& SwaggerGenOptions {
236
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
237
- Title : "UnitTest" ,
238
- Version : "1.0" ,
239
- },
234
+ Title : "UnitTest" ,
235
+ Version : "1.0" ,
240
236
BaseURL : "http://localhost:12345/api/v1" ,
241
237
}).Generate (context .Background (), routes )
242
238
})
@@ -257,10 +253,8 @@ func TestBadCustomOutputSchemaFail(t *testing.T) {
257
253
}
258
254
assert .Panics (t , func () {
259
255
_ = NewSwaggerGen (& SwaggerGenOptions {
260
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
261
- Title : "UnitTest" ,
262
- Version : "1.0" ,
263
- },
256
+ Title : "UnitTest" ,
257
+ Version : "1.0" ,
264
258
BaseURL : "http://localhost:12345/api/v1" ,
265
259
}).Generate (context .Background (), routes )
266
260
})
@@ -272,11 +266,8 @@ func TestDuplicateOperationIDCheck(t *testing.T) {
272
266
}
273
267
assert .PanicsWithValue (t , "Duplicate/invalid name (used as operation ID in swagger): op1" , func () {
274
268
_ = NewSwaggerGen (& SwaggerGenOptions {
275
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
276
- Title : "UnitTest" ,
277
- Version : "1.0" ,
278
- },
279
- BaseURL : "http://localhost:12345/api/v1" ,
269
+ Title : "UnitTest" ,
270
+ Version : "1.0" ,
280
271
}).Generate (context .Background (), routes )
281
272
})
282
273
}
@@ -292,10 +283,10 @@ func TestWildcards(t *testing.T) {
292
283
},
293
284
}
294
285
swagger := NewSwaggerGen (& SwaggerGenOptions {
295
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
296
- Title : "UnitTest" ,
297
- Version : "1.0" ,
298
- },
286
+
287
+ Title : "UnitTest" ,
288
+ Version : "1.0" ,
289
+
299
290
BaseURL : "http://localhost:12345/api/v1" ,
300
291
}).Generate (context .Background (), routes )
301
292
assert .NotNil (t , swagger .Paths .Find ("/namespaces/{ns}/example1/{id}" ))
@@ -314,10 +305,8 @@ func TestFFExcludeTag(t *testing.T) {
314
305
},
315
306
}
316
307
swagger := NewSwaggerGen (& SwaggerGenOptions {
317
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
318
- Title : "UnitTest" ,
319
- Version : "1.0" ,
320
- },
308
+ Title : "UnitTest" ,
309
+ Version : "1.0" ,
321
310
BaseURL : "http://localhost:12345/api/v1" ,
322
311
}).Generate (context .Background (), routes )
323
312
assert .NotNil (t , swagger .Paths .Find ("/namespaces/{ns}/example1/test" ).Post .RequestBody .Value )
@@ -353,10 +342,9 @@ func TestCustomResponseRefs(t *testing.T) {
353
342
},
354
343
}
355
344
swagger := NewSwaggerGen (& SwaggerGenOptions {
356
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
357
- Title : "UnitTest" ,
358
- Version : "1.0" ,
359
- },
345
+ Title : "UnitTest" ,
346
+ Version : "1.0" ,
347
+
360
348
BaseURL : "http://localhost:12345/api/v1" ,
361
349
}).Generate (context .Background (), routes )
362
350
assert .Nil (t , swagger .Paths .Find ("/test" ).Get .RequestBody )
@@ -381,12 +369,10 @@ func TestPanicOnMissingDescription(t *testing.T) {
381
369
}
382
370
assert .PanicsWithValue (t , "invalid schema: FF00158: Field description missing for 'TestInOutType.conditional' on route 'PostPanicOnMissingDescription'" , func () {
383
371
_ = NewSwaggerGen (& SwaggerGenOptions {
384
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
385
- Title : "UnitTest" ,
386
- Version : "1.0" ,
387
- PanicOnMissingDescription : true ,
388
- },
389
- BaseURL : "http://localhost:12345/api/v1" ,
372
+ Title : "UnitTest" ,
373
+ Version : "1.0" ,
374
+ PanicOnMissingDescription : true ,
375
+ BaseURL : "http://localhost:12345/api/v1" ,
390
376
}).Generate (context .Background (), routes )
391
377
})
392
378
}
@@ -404,12 +390,10 @@ func TestPanicOnMissingFFStructTag(t *testing.T) {
404
390
}
405
391
assert .PanicsWithValue (t , "invalid schema: FF00160: ffstruct tag is missing for 'noFFStructTag' on route 'GetPanicOnMissingFFStructTag'" , func () {
406
392
_ = NewSwaggerGen (& SwaggerGenOptions {
407
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
408
- Title : "UnitTest" ,
409
- Version : "1.0" ,
410
- PanicOnMissingDescription : true ,
411
- },
412
- BaseURL : "http://localhost:12345/api/v1" ,
393
+ Title : "UnitTest" ,
394
+ Version : "1.0" ,
395
+ PanicOnMissingDescription : true ,
396
+ BaseURL : "http://localhost:12345/api/v1" ,
413
397
}).Generate (context .Background (), routes )
414
398
})
415
399
}
@@ -426,12 +410,10 @@ func TestPanicOnMissingRouteDescription(t *testing.T) {
426
410
}
427
411
assert .PanicsWithValue (t , "FF00159: API route description missing for route 'GetPanicOnMissingRouteDescription'" , func () {
428
412
_ = NewSwaggerGen (& SwaggerGenOptions {
429
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
430
- Title : "UnitTest" ,
431
- Version : "1.0" ,
432
- PanicOnMissingDescription : true ,
433
- },
434
- BaseURL : "http://localhost:12345/api/v1" ,
413
+ Title : "UnitTest" ,
414
+ Version : "1.0" ,
415
+ PanicOnMissingDescription : true ,
416
+ BaseURL : "http://localhost:12345/api/v1" ,
435
417
}).Generate (context .Background (), routes )
436
418
})
437
419
}
@@ -449,10 +431,8 @@ func TestPreTranslatedRouteDescription(t *testing.T) {
449
431
},
450
432
}
451
433
swagger := NewSwaggerGen (& SwaggerGenOptions {
452
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
453
- Title : "UnitTest" ,
454
- Version : "1.0" ,
455
- },
434
+ Title : "UnitTest" ,
435
+ Version : "1.0" ,
456
436
BaseURL : "http://localhost:12345/api/v1" ,
457
437
}).Generate (context .Background (), routes )
458
438
assert .NotNil (t , swagger .Paths .Find ("/namespaces/{ns}/example1/test" ).Post .RequestBody .Value )
@@ -464,10 +444,8 @@ func TestPreTranslatedRouteDescription(t *testing.T) {
464
444
465
445
func TestBaseURLVariables (t * testing.T ) {
466
446
doc := NewSwaggerGen (& SwaggerGenOptions {
467
- BaseSwaggerGenOptions : BaseSwaggerGenOptions {
468
- Title : "UnitTest" ,
469
- Version : "1.0" ,
470
- },
447
+ Title : "UnitTest" ,
448
+ Version : "1.0" ,
471
449
BaseURL : "http://localhost:12345/api/v1/{param}" ,
472
450
BaseURLVariables : map [string ]BaseURLVariable {
473
451
"param" : {
0 commit comments