2.0.1 • Published 3 months ago

swagger-fetch-client v2.0.1

Weekly downloads
2
License
ISC
Repository
-
Last release
3 months ago

swagger-fetch-client

Generates a typescript fetch api client from a swagger configuration endpoint (v1 or v2)

Running

Install the fetch client into your application (as a dev dependency)

npm i swagger-fetch-client -SD

In the root of your repository create a swagger-fetch-client.config.js file, like:

module.exports = {
  url: "https://api.rocketmakers.net/swagger/docs/v1",
  apiOutputPath: "./source/api/apiclient.ts",
  defintionOutputFile: "./source/typings/api/apiclient.d.ts"
}

The complete list of config options are:

  /** The url of the swagger endpoint */
  url: string,

  /** The path of the generated typescript api (.ts) */
  apiOutputPath: string,

  /** The path of the generated typescript api definitions (.d.ts) */
  defintionOutputFile: string,

  /** If property required not specified, override with true */
  propertiesRequiredByDefault?: boolean,

  /** ensure the generated models use proper case */
  properCaseProps?: boolean

  /** Generate a sample fetch client (beta) */
  generateFetchClient?: boolean

  /** To override the generated IFetchApiResponse<T> you can import your own version */
  fetchApiInterfaceImport?: string

  /** encodes all URI params after the "?" with "encodeURIComponent" */
  encodeUriParams?: boolean

  /** By default we write 'const enums' - set this to true to create full enums */
  fullEnums?: boolean

  /** Allows the grouping of endpoint parameters into a single object, named using this string */
  paramObjectKey?: string

Then from the command line run:

swagger-fetch-client

If you want to create an alternative config file you can:

swagger-fetch-client <config file path>
2.0.1

3 months ago

2.0.0

3 months ago

1.1.0

4 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago