feat: expose build info via new versions plugin (#9820)
This commit is contained in:
@@ -26,9 +26,9 @@ import ViewPlugin from "./plugins/view"
|
|||||||
import ViewLegacyPlugin from "core/plugins/view-legacy"
|
import ViewLegacyPlugin from "core/plugins/view-legacy"
|
||||||
import DownloadUrlPlugin from "./plugins/download-url"
|
import DownloadUrlPlugin from "./plugins/download-url"
|
||||||
import SyntaxHighlightingPlugin from "core/plugins/syntax-highlighting"
|
import SyntaxHighlightingPlugin from "core/plugins/syntax-highlighting"
|
||||||
|
import VersionsPlugin from "core/plugins/versions"
|
||||||
import SafeRenderPlugin from "./plugins/safe-render"
|
import SafeRenderPlugin from "./plugins/safe-render"
|
||||||
|
|
||||||
import win from "./window"
|
|
||||||
import {
|
import {
|
||||||
defaultOptions,
|
defaultOptions,
|
||||||
optionsFromQuery,
|
optionsFromQuery,
|
||||||
@@ -39,18 +39,8 @@ import {
|
|||||||
storeOptionsFactorization
|
storeOptionsFactorization
|
||||||
} from "./config"
|
} from "./config"
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION, BUILD_TIME } = buildInfo
|
|
||||||
|
|
||||||
export default function SwaggerUI(userOptions) {
|
export default function SwaggerUI(userOptions) {
|
||||||
win.versions = win.versions || {}
|
|
||||||
win.versions.swaggerUi = {
|
|
||||||
version: PACKAGE_VERSION,
|
|
||||||
gitRevision: GIT_COMMIT,
|
|
||||||
gitDirty: GIT_DIRTY,
|
|
||||||
buildTimestamp: BUILD_TIME,
|
|
||||||
}
|
|
||||||
|
|
||||||
const queryOptions = optionsFromQuery()(userOptions)
|
const queryOptions = optionsFromQuery()(userOptions)
|
||||||
let mergedOptions = mergeOptions({}, defaultOptions, userOptions, queryOptions)
|
let mergedOptions = mergeOptions({}, defaultOptions, userOptions, queryOptions)
|
||||||
const storeOptions = storeOptionsFactorization(mergedOptions)
|
const storeOptions = storeOptionsFactorization(mergedOptions)
|
||||||
@@ -130,5 +120,6 @@ SwaggerUI.plugins = {
|
|||||||
ViewLegacy: ViewLegacyPlugin,
|
ViewLegacy: ViewLegacyPlugin,
|
||||||
DownloadUrl: DownloadUrlPlugin,
|
DownloadUrl: DownloadUrlPlugin,
|
||||||
SyntaxHighlighting: SyntaxHighlightingPlugin,
|
SyntaxHighlighting: SyntaxHighlightingPlugin,
|
||||||
|
Versions: VersionsPlugin,
|
||||||
SafeRender: SafeRenderPlugin,
|
SafeRender: SafeRenderPlugin,
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/core/plugins/versions/after-load.js
Normal file
19
src/core/plugins/versions/after-load.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
|
import win from "core/window"
|
||||||
|
|
||||||
|
const afterLoad = () => {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION, BUILD_TIME } = buildInfo
|
||||||
|
|
||||||
|
win.versions = win.versions || {}
|
||||||
|
win.versions.swaggerUI = {
|
||||||
|
version: PACKAGE_VERSION,
|
||||||
|
gitRevision: GIT_COMMIT,
|
||||||
|
gitDirty: GIT_DIRTY,
|
||||||
|
buildTimestamp: BUILD_TIME,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default afterLoad
|
||||||
10
src/core/plugins/versions/index.js
Normal file
10
src/core/plugins/versions/index.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* @prettier
|
||||||
|
*/
|
||||||
|
import afterLoad from "./after-load.js"
|
||||||
|
|
||||||
|
const VersionsPlugin = () => ({
|
||||||
|
afterLoad,
|
||||||
|
})
|
||||||
|
|
||||||
|
export default VersionsPlugin
|
||||||
@@ -20,6 +20,7 @@ import ViewPlugin from "core/plugins/view"
|
|||||||
import ViewLegacyPlugin from "core/plugins/view-legacy"
|
import ViewLegacyPlugin from "core/plugins/view-legacy"
|
||||||
import DownloadUrlPlugin from "core/plugins/download-url"
|
import DownloadUrlPlugin from "core/plugins/download-url"
|
||||||
import SyntaxHighlightingPlugin from "core/plugins/syntax-highlighting"
|
import SyntaxHighlightingPlugin from "core/plugins/syntax-highlighting"
|
||||||
|
import VersionsPlugin from "core/plugins/versions"
|
||||||
import SafeRenderPlugin from "core/plugins/safe-render"
|
import SafeRenderPlugin from "core/plugins/safe-render"
|
||||||
// ad-hoc plugins
|
// ad-hoc plugins
|
||||||
import CoreComponentsPlugin from "core/presets/base/plugins/core-components"
|
import CoreComponentsPlugin from "core/presets/base/plugins/core-components"
|
||||||
@@ -47,6 +48,7 @@ const BasePreset = () => [
|
|||||||
OnCompletePlugin,
|
OnCompletePlugin,
|
||||||
RequestSnippetsPlugin,
|
RequestSnippetsPlugin,
|
||||||
SyntaxHighlightingPlugin,
|
SyntaxHighlightingPlugin,
|
||||||
|
VersionsPlugin,
|
||||||
SafeRenderPlugin(),
|
SafeRenderPlugin(),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user