0.0.10 • Published 4 years ago
@tradeling/swagger-sdk-generator v0.0.10
gen-sdk
Helps generate the SDK from the swagger file
Installation
Run the below command
npm install -g @tradeling/swagger-sdk-generator
Usage
$ gen-sdk --help
Options:
--i Runs in interactive mode no input required
--version Show version number [boolean]
--pkg, -p Name of the package e.g. @tradeling/my-api-sdk [string]
--output, -o Output path for the generated SDK [string]
--swagger, -s Path to the swagger file [string]
--pkgVersion, -e Version to set for the npm package
(defaults to the one from swagger file)
--help, -h Show help [boolean]
Using the generated SDK
Install the SDK using the name that you used to publish it e.g.
yarn add @tradeling/catalog-search-sdk
Now create a client file at src/util/clients/
path e.g. catalog-search-sdk.ts
below content
// Enter the camel cased name of package postfixed with `Client` instead of `-sdk` postfix
// e.g. `@tradeling/catalog-search-sdk` will export `catalogSearchClient`
// `@tradeling/acount-sdk` will export `accountClient` and so on
import { catalogSearchClient } from '@tradeling/catalog-search-sdk';
export const catalogSearchSdk = catalogSearchClient({
baseURL: '...'
});
Now import this client anywhere in your project and call the methods on it
import { catalogSearchSdk } from '@util/clients/catalog-search-sdk';