@@ -14,6 +14,9 @@ describe('Definition generation for OpenAPI 3.0.0', () => {
14
14
const metadataPost = new MetadataGenerator ( './fixtures/controllers/postController.ts' ) . Generate ( ) ;
15
15
16
16
const defaultOptions : ExtendedSpecConfig = getDefaultExtendedOptions ( ) ;
17
+ const optionsWithServers = Object . assign < object , ExtendedSpecConfig , Partial < ExtendedSpecConfig > > ( { } , defaultOptions , {
18
+ servers : [ 'localhost:3000' , 'staging.api.com' ] ,
19
+ } ) ;
17
20
const optionsWithNoAdditional = Object . assign < object , ExtendedSpecConfig , Partial < ExtendedSpecConfig > > ( { } , defaultOptions , {
18
21
noImplicitAdditionalProperties : 'silently-remove-extras' ,
19
22
} ) ;
@@ -29,13 +32,17 @@ describe('Definition generation for OpenAPI 3.0.0', () => {
29
32
/**
30
33
* If you want to add another spec here go for it. The reason why we use a string literal is so that tests below won't have "magic string" errors when expected test results differ based on the name of the spec you're testing.
31
34
*/
32
- specName : 'specDefault' | 'specWithNoImplicitExtras' | 'specWithXEnumVarnames' | 'specWithOperationIdTemplate' ;
35
+ specName : 'specDefault' | 'specWithServers' | ' specWithNoImplicitExtras' | 'specWithXEnumVarnames' | 'specWithOperationIdTemplate' ;
33
36
}
34
37
35
38
const specDefault : SpecAndName = {
36
39
spec : new SpecGenerator3 ( metadataGet , defaultOptions ) . GetSpec ( ) ,
37
40
specName : 'specDefault' ,
38
41
} ;
42
+ const specWithServers : SpecAndName = {
43
+ spec : new SpecGenerator3 ( metadataGet , optionsWithServers ) . GetSpec ( ) ,
44
+ specName : 'specWithServers' ,
45
+ } ;
39
46
const specWithNoImplicitExtras : SpecAndName = {
40
47
spec : new SpecGenerator3 ( metadataGet , optionsWithNoAdditional ) . GetSpec ( ) ,
41
48
specName : 'specWithNoImplicitExtras' ,
@@ -85,6 +92,11 @@ describe('Definition generation for OpenAPI 3.0.0', () => {
85
92
expect ( specDefault . spec . servers [ 0 ] . url ) . to . match ( / l o c a l h o s t : 3 0 0 0 / ) ;
86
93
} ) ;
87
94
95
+ it ( 'should replace the parent hosts element' , ( ) => {
96
+ expect ( specWithServers . spec . servers [ 0 ] . url ) . to . match ( / l o c a l h o s t : 3 0 0 0 / ) ;
97
+ expect ( specWithServers . spec . servers [ 1 ] . url ) . to . match ( / s t a g i n g \. a p i \. c o m / ) ;
98
+ } ) ;
99
+
88
100
it ( 'should replace the parent basePath element' , ( ) => {
89
101
expect ( specDefault . spec ) . to . not . have . property ( 'basePath' ) ;
90
102
expect ( specDefault . spec . servers [ 0 ] . url ) . to . match ( / \/ v 1 / ) ;
0 commit comments