swagger-ui-cli
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

Swagger UI CLI

Package lint Build and Release Discord

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.

Usage

Build

This command will build a static HTML page from your OpenAPI specification file.

swagger-ui-cli build <openapi-file | openapi-url>

Options

  • --output: Output folder name. Default is dist.
  • --multiFileBuild: Should output multiple files instead of single index.html. Default is false.
  • --config: Path to the configuration file, there you can configure the swagger-ui. Default is swagger-ui.config.js.

Serve

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>

Options

  • --port: The port to serve the Swagger UI on. Default is 8000.
  • --domain: The domain to serve the Swagger UI on. Default is localhost.
  • --config: Path to the configuration file, there you can configure the swagger-ui. Default is swagger-ui.config.js.
  • --serverConfig: Path to the server configuration file, there you can configure the dev server. Default is swagger-ui.server-config.js.

swagger-ui.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;

swagger-ui.server-config.js

/** @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;

Readme

Keywords

none

Package Sidebar

Install

npm i swagger-ui-cli

Weekly Downloads

138

Version

0.0.11

License

MIT

Unpacked Size

26.4 kB

Total Files

34

Last publish

Collaborators

  • szendezsombor