@@ -154,6 +154,13 @@ class DefinitionGenerator {
154154 if ( documentation . contact . url ) contactObj . url = documentation . contact . url ;
155155
156156 contactObj . email = documentation . contact . email || "" ;
157+
158+ const extendedSpec = this . extendSpecification ( documentation . contact ) ;
159+
160+ if ( Object . keys ( extendedSpec ) . length ) {
161+ Object . assign ( contactObj , extendedSpec ) ;
162+ }
163+
157164 Object . assign ( info , { contact : contactObj } ) ;
158165 }
159166
@@ -164,14 +171,22 @@ class DefinitionGenerator {
164171 if ( documentation . license . url )
165172 licenseObj . url = documentation . license . url || "" ;
166173
174+ const extendedSpec = this . extendSpecification ( documentation . license ) ;
175+
176+ if ( Object . keys ( extendedSpec ) . length ) {
177+ Object . assign ( licenseObj , extendedSpec ) ;
178+ }
179+
167180 Object . assign ( info , { license : licenseObj } ) ;
168181 }
169182
170- // for (const key of Object.keys(documentation)) {
171- // if (/^[x\-]/i.test(key)) {
172- // Object.assign(info, { [key]: documentation[key] });
173- // }
174- // }
183+ if ( documentation [ "x-tagGroups" ] ) {
184+ Object . assign ( this . openAPI , {
185+ "x-tagGroups" : documentation [ "x-tagGroups" ] ,
186+ } ) ;
187+
188+ delete documentation [ "x-tagGroups" ] ;
189+ }
175190
176191 const extendedSpec = this . extendSpecification ( documentation ) ;
177192
@@ -237,6 +252,29 @@ class DefinitionGenerator {
237252 const serverDoc = servers ;
238253 const newServers = [ ] ;
239254
255+ const variableManipulation = ( variables ) => {
256+ for ( const key of Object . keys ( variables ) ) {
257+ if ( variables [ key ] . enum ) {
258+ const strEnum = variables [ key ] . enum . map ( ( enumVar ) =>
259+ enumVar . toString ( )
260+ ) ;
261+
262+ variables [ key ] . enum = strEnum ;
263+ }
264+
265+ if ( variables [ key ] . default )
266+ variables [ key ] . default = variables [ key ] . default . toString ( ) ;
267+
268+ const extendedSpec = this . extendSpecification ( variables [ key ] ) ;
269+
270+ if ( Object . keys ( extendedSpec ) . length ) {
271+ Object . assign ( variables [ key ] , extendedSpec ) ;
272+ }
273+ }
274+
275+ return variables ;
276+ } ;
277+
240278 if ( Array . isArray ( serverDoc ) ) {
241279 for ( const server of serverDoc ) {
242280 const obj = {
@@ -248,7 +286,13 @@ class DefinitionGenerator {
248286 }
249287
250288 if ( server . variables ) {
251- obj . variables = server . variables ;
289+ obj . variables = variableManipulation ( server . variables ) ;
290+ }
291+
292+ const extendedSpec = this . extendSpecification ( server ) ;
293+
294+ if ( Object . keys ( extendedSpec ) . length ) {
295+ Object . assign ( obj , extendedSpec ) ;
252296 }
253297
254298 newServers . push ( obj ) ;
@@ -263,7 +307,13 @@ class DefinitionGenerator {
263307 }
264308
265309 if ( servers . variables ) {
266- obj . variables = servers . variables ;
310+ obj . variables = variableManipulation ( servers . variables ) ;
311+ }
312+
313+ const extendedSpec = this . extendSpecification ( servers ) ;
314+
315+ if ( Object . keys ( extendedSpec ) . length ) {
316+ Object . assign ( obj , extendedSpec ) ;
267317 }
268318
269319 newServers . push ( obj ) ;
@@ -297,6 +347,13 @@ class DefinitionGenerator {
297347 tag . externalDocumentation
298348 ) ;
299349 }
350+
351+ const extendedSpec = this . extendSpecification ( tag ) ;
352+
353+ if ( Object . keys ( extendedSpec ) . length ) {
354+ Object . assign ( obj , extendedSpec ) ;
355+ }
356+
300357 tags . push ( obj ) ;
301358 }
302359 Object . assign ( this . openAPI , { tags : tags } ) ;
0 commit comments