This CLI tool is designed to serve and live-reload an OpenAPI specification file during development, and also to build a static HTML page from your OpenAPI spec file.
This command will build a static HTML page from your OpenAPI specification file.
swagger-ui-cli build <openapi-file | openapi-url>
-
--output
: Output folder name. Default isdist
. -
--multiFileBuild
: Should output multiple files instead of single index.html. Default isfalse
. -
--config
: Path to the configuration file, there you can configure the swagger-ui. Default isswagger-ui.config.js
.
This command will open a live reloading server, if you change your config it will change the page.
swagger-ui-cli serve <openapi-file | openapi-url>
-
--port
: The port to serve the Swagger UI on. Default is8000
. -
--domain
: The domain to serve the Swagger UI on. Default islocalhost
. -
--config
: Path to the configuration file, there you can configure the swagger-ui. Default isswagger-ui.config.js
. -
--serverConfig
: Path to the server configuration file, there you can configure the dev server. Default isswagger-ui.server-config.js
.
/** @type {import('swagger-ui-cli').ClientConfig} */
const config = {
// For more please visit the official site: https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md
docExpansion: 'none',
deepLinking: true,
displayOperationId: true,
defaultModelsExpandDepth: -1,
showExtensions: true,
showCommonExtensions: true,
filter: true,
onComplete: () => console.log('swagger can run'),
};
export default config;
/** @type {import('swagger-ui-cli').ServerConfig} */
const config = {
// Under the hood there is a simple vite server running, so you can use any vite server options here. https://vite.dev/config/server-options
server: {
port: 1234,
},
};
export default config;