refactor(dist): remove inline-code (#7905)
* apply /dist changes to /dev-helpers * add missing "useBasicAuthenticationWithAccessCodeGrant: false" after merge conflict Co-authored-by: akop <akop@ppi.de> Co-authored-by: Tim Lai <timothy.lai@gmail.com>
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
/*
|
||||
* Replace static code with configured data based on environment-variables.
|
||||
* This code should be called BEFORE the webserver serve the api-documentation.
|
||||
*/
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
|
||||
@@ -5,8 +9,8 @@ const translator = require("./translator")
|
||||
const oauthBlockBuilder = require("./oauth")
|
||||
const indent = require("./helpers").indent
|
||||
|
||||
const START_MARKER = "// Begin Swagger UI call region"
|
||||
const END_MARKER = "// End Swagger UI call region"
|
||||
const START_MARKER = "//<editor-fold desc=\"Changeable Configuration Block\">"
|
||||
const END_MARKER = "//</editor-fold>"
|
||||
|
||||
const targetPath = path.normalize(process.cwd() + "/" + process.argv[2])
|
||||
|
||||
@@ -22,12 +26,12 @@ const afterEndMarkerContent = originalHtmlContent.slice(
|
||||
|
||||
if (startMarkerIndex < 0 || endMarkerIndex < 0) {
|
||||
console.error("ERROR: Swagger UI was unable to inject Docker configuration data!")
|
||||
console.error("! This can happen when you provide custom HTML to Swagger UI.")
|
||||
console.error("! This can happen when you provide custom HTML/JavaScript to Swagger UI.")
|
||||
console.error("! ")
|
||||
console.error("! In order to solve this, add the `Begin Swagger UI call region`")
|
||||
console.error("! and `End Swagger UI call region` markers to your HTML.")
|
||||
console.error(`! In order to solve this, add the "${START_MARKER}"`)
|
||||
console.error(`! and "${END_MARKER}" markers to your JavaScript.`)
|
||||
console.error("! See the repository for an example:")
|
||||
console.error("! https://github.com/swagger-api/swagger-ui/blob/02758b8125dbf38763cfd5d4f91c7c803e9bd0ad/dist/index.html#L40-L54")
|
||||
console.error("! https://github.com/swagger-api/swagger-ui/blob/8c946a02e73ef877d73b7635de27924418ba50f3/dist/swagger-initializer.js#L2-L19")
|
||||
console.error("! ")
|
||||
console.error("! If you're seeing this message and aren't using custom HTML,")
|
||||
console.error("! this message may be a bug. Please file an issue:")
|
||||
@@ -39,10 +43,9 @@ fs.writeFileSync(
|
||||
targetPath,
|
||||
`${beforeStartMarkerContent}
|
||||
${START_MARKER}
|
||||
const ui = SwaggerUIBundle({
|
||||
${indent(translator(process.env, { injectBaseConfig: true }), 8, 2)}
|
||||
window.ui = SwaggerUIBundle({
|
||||
${indent(translator(process.env, {injectBaseConfig: true}), 8, 2)}
|
||||
})
|
||||
|
||||
${indent(oauthBlockBuilder(process.env), 6, 2)}
|
||||
${END_MARKER}
|
||||
${afterEndMarkerContent}`
|
||||
|
||||
Reference in New Issue
Block a user