swagger-typescript-api

Generate api via swagger scheme

Subcommands

NameDescription
generate-templatesGenerate ".ejs" templates needed for generate api

Options

NameDescription
--version, -vOutput the current version
--path, -p <Path>Path/url to swagger scheme
--output, -o <Path>Output path of typescript api file (default: "./")
--name, -n <Name>Name of output typescript api file (default: "Api.ts")
--templates, -t <Path>Path to folder containing templates
--default-as-success, -dUse "default" response status code as success response too
--responses, -rGenerate additional information about request responses
--union-enumsGenerate all "enum" types as union types (T1 | T2 | TN)
--add-readonlyGenerate readonly properties
--route-typesGenerate type definitions for API routes
--no-clientDo not generate an API class
--enum-names-as-valuesUse values in 'x-enumNames' as enum values (not only as keys)
--extract-request-paramsExtract request params to data contract
--extract-request-bodyExtract request body type to data contract
--extract-response-bodyExtract response body type to data contract
--extract-response-errorExtract response error type to data contract
--modularGenerate separated files for http client, data contracts, and routes
--jsGenerate js api module with declaration file
--module-name-index <Index>Determines which path index should be used for routes separation
--module-name-first-tagSplits routes based on the first tag
--disableStrictSSLDisabled strict SSL
--disableProxyDisabled proxy
--axiosGenerate axios http client
--unwrap-response-dataUnwrap the data item from the response
--disable-throw-on-errorDo not throw an error when response.ok is not true (default: false)
--single-http-clientAbility to send HttpClient instance to Api constructor (default: false)
--silent
  • Persistent ⚖
--default-response <Type>Default type for empty response schema
--type-prefix <Prefix>Data contract name prefix
--type-suffix <Suffix>Data contract name suffix
--clean-outputClean output folder before generate api. WARNING: May cause data loss (default: false)
--api-class-name <Name>Name of the api class
--patchFix up small errors in the swagger source definition (default: false)
--debugAdditional information about processes inside this tool (default: false)
--another-array-typeGenerate array types as Array<Type> (by default Type[]) (default: false)
--sort-typesSort fields and types (default: false)
--extract-enumsExtract all enums from inline interface ype content to typescript enum construction (default: false)
--help, -h
  • Persistent ⚖