1.0.2 • Published 7 months ago

@createiq/swagger-ts v1.0.2

Weekly downloads
-
License
UNLICENSED
Repository
gitlab
Last release
7 months ago

@createiq/swagger-ts

Pipeline Status Test Coverage npm


Take a swagger.yml file and generate a TypeScript client library using @hey-api/openapi-ts, so that types can be distributed automatically.

Usage

Example:

npx @createiq/swagger-ts \
    --generate-npm-library @createiq/client \
    swagger.json

All options:

   ____                      _       _          __                                            _
  / __ \  ___ _ __ ___  __ _| |_ ___(_) __ _   / /____      ____ _  __ _  __ _  ___ _ __     | |_ ___
 / / _` |/ __| '__/ _ \/ _` | __/ _ \ |/ _` | / / __\ \ /\ / / _` |/ _` |/ _` |/ _ \ '__|____| __/ __|
| | (_| | (__| | |  __/ (_| | ||  __/ | (_| |/ /\__ \\ V  V / (_| | (_| | (_| |  __/ | |_____| |_\__ \
 \ \__,_|\___|_|  \___|\__,_|\__\___|_|\__, /_/ |___/ \_/\_/ \__,_|\__, |\__, |\___|_|        \__|___/
  \____/                                  |_|                      |___/ |___/
Version: 1.0.0
Usage: swagger-ts [options] <input>

Create a client library from Swagger/OpenAPI definitions

Arguments:
  input                             OpenAPI/Swagger specification file

Options:
  -V, --version                     output the version number
  --output-basedir <directory>      output base directory (default: current working directory)
  --hash                            generate a hash of the output (useful for inclusion in npm library to check whether it needs to be updated)
  --generate-npm-library <package>  generate an npm library with the license information
  --publish-npm-library             publish the generated npm library
  --publish-npm-library-dry-run     publish the generated npm library (dry run) (env: PUBLISH_NPM_LIBRARY_DRY_RUN)
  -h, --help                        display help for command

Using a configuration file

You can also specify options using a swagger-ts.config.(js|cjs|mjs|ts} file, which should have a single default object export. If you're using a ts file, you can use the SwaggerTsConfig type to verify your config matches the type.

Configuration keys:

  • file: (type: string) a reference to the OpenAPI specification file
  • outputBasedir: (type: string, default current working directory) the directory to output files in
  • hash: (type: boolean) whether to generate a sha256 hash of the input
  • npmLibrary.name: (type: string) the package name of the npm library to output if this is set
  • npmLibrary.publish: (type: boolean or 'dry-run') whether to publish the npm library

Contributing

The library uses Biome for linting and formatting, and Vitest for unit tests and benchmarking. It's worth ensuring that you have appropriate plugins for your development environment, particularly for Biome to avoid having to fix formatting issues late.

Releasing

Merge requests to the main branch should be reviewed by the team as normal but will not release a new version of the library to npm. This happens when merge requests are made to the prod branch, this should be an MR directly from main to prod and MUST include a bump to the version in package.json satisfying semver.