Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
/ cli Public archive

Command-line interface to work with OpenAPI files

License

Notifications You must be signed in to change notification settings

scalar/cli

Repository files navigation

This repository was moved to our monorepo: https://github.com/scalar/scalar/tree/main/packages/cli

Scalar CLI

CI Release Contributors GitHub License Discord

Command-line interface to work with OpenAPI files

Demo Video

Features

  • Format & validate OpenAPI files
  • Upload your OpenAPI files to Scalar
  • Get a fully mocked API for testing purposes
  • Preview your API reference
  • Bundle multiple OpenAPI files

Quickstart

npx @scalar/cli help

Installation

npm install -g @scalar/cli
scalar --version

Usage

scalar init
scalar format openapi.json
scalar validate openapi.json
scalar bundle openapi.json --output bundle.json
scalar reference openapi.json --watch
scalar mock openapi.json --watch
scalar share openapi.json

Full documentation

GitHub Actions

To validate your OpenAPI file in GitHub Actions, add this workflow:

# .github/workflows/validate-openapi-file.yml
name: Validate OpenAPI File

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  validate:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
      - name: Validate OpenAPI File
        # Replace `./my-openapi-file.json` with the correct path and filename for your project.
        # Or: run `npx @scalar/cli init` and add the config file to your repository.
        run: npx @scalar/cli validate ./my-openapi-file.json

Community

We are API nerds. You too? Let’s chat on Discord: https://discord.gg/8HeZcRGPFS

Contributors

hanspagel
hanspagel
hwkr
hwkr

Contributions are welcome! Read CONTRIBUTING.

License

The source code in this repository is licensed under MIT.