-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(): routing platform independence (resolved PR remarks)
- Loading branch information
Showing
7 changed files
with
6,293 additions
and
14,451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SwaggerCustomOptions } from './swagger-custom-options.interface'; | ||
import { OpenAPIObject } from './open-api-spec.interface'; | ||
|
||
export interface SwaggerUIInitOptions { | ||
swaggerDoc: OpenAPIObject; | ||
customOptions: SwaggerCustomOptions; | ||
swaggerUrl: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { SwaggerUIInitOptions } from '../interfaces/swagger-ui-init-options.interface'; | ||
|
||
/** | ||
* Transforms options JS object into a string that can be inserted as 'variable' into JS file | ||
*/ | ||
export function buildJSInitOptions(initOptions: SwaggerUIInitOptions) { | ||
const functionPlaceholder = '____FUNCTION_PLACEHOLDER____'; | ||
const fns = []; | ||
let json = JSON.stringify( | ||
initOptions, | ||
(key, value) => { | ||
if (typeof value === 'function') { | ||
fns.push(value); | ||
return functionPlaceholder; | ||
} | ||
return value; | ||
}, | ||
2 | ||
); | ||
|
||
json = json.replace(new RegExp(functionPlaceholder, 'g'), () => fns.shift()); | ||
|
||
return `let options = ${json};`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.