@@ -3,7 +3,7 @@ import * as request from 'supertest';
3
3
import { createApp } from './common/app' ;
4
4
import * as packageJson from '../package.json' ;
5
5
import { OpenAPIV3 } from '../src/framework/types' ;
6
- import { expect } from " chai" ;
6
+ import { expect } from ' chai' ;
7
7
8
8
describe ( packageJson . name , ( ) => {
9
9
let app = null ;
@@ -63,12 +63,12 @@ describe(packageJson.name, () => {
63
63
required : [ 'id' ] ,
64
64
properties : {
65
65
id : {
66
- type : 'integer'
67
- }
68
- }
69
- }
70
- }
71
- }
66
+ type : 'integer' ,
67
+ } ,
68
+ } ,
69
+ } ,
70
+ } ,
71
+ } ,
72
72
} ,
73
73
responses : {
74
74
'200' : {
@@ -88,6 +88,26 @@ describe(packageJson.name, () => {
88
88
} ,
89
89
} ,
90
90
} ,
91
+
92
+ '/some/{wildcard}*' : {
93
+ parameters : [
94
+ {
95
+ name : 'wildcard' ,
96
+ in : 'path' ,
97
+ required : true ,
98
+ schema : {
99
+ type : 'string' ,
100
+ } ,
101
+ } ,
102
+ ] ,
103
+ get : {
104
+ responses : {
105
+ '200' : {
106
+ description : 'OK' ,
107
+ } ,
108
+ } ,
109
+ } ,
110
+ } ,
91
111
} ,
92
112
} ;
93
113
@@ -102,8 +122,17 @@ describe(packageJson.name, () => {
102
122
app . use (
103
123
express
104
124
. Router ( )
105
- . get ( `/api/test/:id` , ( req , res ) => res . status ( 200 ) . json ( { id : 'id-test' , label : 'label' } ) )
106
- . post ( `/api/test/:id:clone` , ( req , res ) => res . status ( 200 ) . json ( { ...req . body , id : 'id-test' } ) ) ,
125
+ . get ( `/api/test/:id` , ( req , res ) =>
126
+ res . status ( 200 ) . json ( { id : 'id-test' , label : 'label' } ) ,
127
+ )
128
+ . post ( `/api/test/:id:clone` , ( req , res ) =>
129
+ res . status ( 200 ) . json ( { ...req . body , id : 'id-test' } ) ,
130
+ )
131
+ . get ( '/api/some/:wildcard(*)' , ( req , res ) => {
132
+ const wildcard = req . params . wildcard ;
133
+ console . log ( `Wildcard: ${ wildcard } ` ) ;
134
+ res . status ( 200 ) . send ( `Matched wildcard: ${ wildcard } ` ) ;
135
+ } ) ,
107
136
) ,
108
137
) ;
109
138
} ) ;
@@ -112,19 +141,23 @@ describe(packageJson.name, () => {
112
141
app . server . close ( ) ;
113
142
} ) ;
114
143
115
- it ( 'get /test/{id} should return 200' , async ( ) =>
144
+ it ( 'GET /test/{id} should return 200' , async ( ) =>
116
145
request ( app ) . get ( `/api/test/abc123` ) . expect ( 200 ) ) ;
117
146
118
147
it ( 'POST /test/{id}:clone should return 200' , async ( ) =>
119
- request ( app ) . post ( `/api/test/abc123:clone` )
120
- . send ( { id : 10 } )
121
- . expect ( 200 ) ) ;
148
+ request ( app ) . post ( `/api/test/abc123:clone` ) . send ( { id : 10 } ) . expect ( 200 ) ) ;
122
149
123
150
it ( 'POST /test/{id}:clone should return 400' , async ( ) =>
124
- request ( app ) . post ( `/api/test/abc123:clone` )
125
- . send ( { id : 'abc123' } )
126
- . expect ( 400 )
127
- . then ( r => {
128
- expect ( r . body . message ) . to . include ( 'id must be integer' ) ;
129
- } ) ) ;
151
+ request ( app )
152
+ . post ( `/api/test/abc123:clone` )
153
+ . send ( { id : 'abc123' } )
154
+ . expect ( 400 )
155
+ . then ( ( r ) => {
156
+ expect ( r . body . message ) . to . include ( 'id must be integer' ) ;
157
+ } ) ) ;
158
+
159
+ it ( 'GET /some/test with wildcard should return 200' , async ( ) =>
160
+ request ( app )
161
+ . get ( `/api/some/test/stuff` )
162
+ . expect ( 200 ) ) ;
130
163
} ) ;
0 commit comments