Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@scalar/cli
Advanced tools
Command-line interface to work with OpenAPI files
npx @scalar/cli help
If you really want to become friends you should install the CLI:
npm -g install @scalar/cli
Otherwise just prefix all commands with npx @scalar/cli
instead of scalar
. That’s fine, too.
There’s another scalar
CLI, which is bundled with git
. If you run into naming conflicts, but never use the other CLI anyway, you can replace it like this:
npm -g --force install @scalar/cli
Or, if you want to keep using the other scalar
CLI, you can just stick to npx
(or pnpm dlx
):
# Execute without installation (npm)
npx @scalar/cli help
# Execute without installation (pnpm)
pnpm dlx @scalar/cli help
The given JSON file will be formatted with Prettier.
scalar format
scalar format openapi.json --output openapi.yaml
scalar format https://example.com/openapi.json --output openapi.json
To check whether your OpenAPI file adheres to the Swagger 2.0, OpenAPI 3.0 or OpenAPI 3.1 specification, run the following command:
scalar validate
scalar validate openapi.json
scalar validate https://example.com/openapi.json
To quickly share an OpenAPI file or reference with someone, you can use the share command:
scalar share
scalar share openapi.json
This will upload your OpenAPI file to the Scalar Sandbox to give you a public reference URL and a public URL to your OpenAPI JSON file.
You can quickly spin up a local server with an API reference based on your OpenAPI file.
scalar serve
scalar serve openapi.json
scalar serve openapi.json --port 1234
scalar serve openapi.json --watch
scalar serve https://example.com/openapi.json --watch
We can even mock your API, and it’s just one command:
scalar mock
This will boot up a server on port 3000 which gives you an API returning the dummy data according to your schema.
If you’d like to watch for file changes (to the OpenAPI file), do it like this:
scalar mock openapi.json --watch
You can also change the port like this:
scalar mock openapi.json --watch --port 8080
And it even works with URLs:
scalar mock https://example.com/openapi.json --watch
Start a HTTP dummy server, that just responds with the request data.
scalar void
This will boot up a server on port 3000, but you can also change the port like this:
scalar void --port 8080
Warning! The bundle command isn’t ready for production yet. Circular dependencies are not supported yet.
Some OpenAPI files reference other files from the file system or an URL. You can bundle those files and make them a single file:
scalar bundle openapi.json --output bundle.json
If you don’t provide an output
file name, the input file will be overwritten.
If you’re tired of passing the file name again and again, just configure it once:
scalar init
This will create a scalar.config.json
file for you. All commands will use the configured OpenAPI file by default.
Validate a Scalar Configuration file (scalar.config.json
), gives helpful hints to fix invalid configurations. To check a scalar.config.json
in the same folder:
scalar check
Or to validate a specific file:
scalar check some-custom-folder/scalar.config.json
If you want to check which version of the CLI is installed, just run this:
scalar --version
scalar --help
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.yaml` 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.yaml
Set up the development environment:
pnpm install
pnpm @scalar/cli --version
To symlink the package and use it globally on your machine:
pnpm cli:link
scalar --version
We are API nerds. You too? Let’s chat on Discord: https://discord.gg/scalar
The source code in this repository is licensed under MIT.
FAQs
A command-line interface to work with OpenAPI files
We found that @scalar/cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.