feat(openapi): Add modified typescript-fetch template
This template is modified from the original one, to handle multiple status-code handling of response. Don't ask me how they work, I don't quite understand them in depth...
This commit is contained in:
parent
b7c2a3dff9
commit
5dd6067c95
32 changed files with 2852 additions and 0 deletions
127
openapi-template/README.mustache
Normal file
127
openapi-template/README.mustache
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
# {{npmName}}@{{npmVersion}}
|
||||
|
||||
A TypeScript SDK client for the {{host}} API.
|
||||
|
||||
## Usage
|
||||
|
||||
First, install the SDK from npm.
|
||||
|
||||
```bash
|
||||
npm install {{npmName}} --save
|
||||
```
|
||||
|
||||
Next, try it out.
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
|
||||
```ts
|
||||
{{>api_example}}
|
||||
```
|
||||
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation
|
||||
|
||||
### API Endpoints
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
| Class | Method | HTTP request | Description
|
||||
| ----- | ------ | ------------ | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}/{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
### Models
|
||||
|
||||
{{#models}}{{#model}}- [{{{classname}}}]({{modelDocPath}}/{{{classname}}}.md){{/model}}
|
||||
{{/models}}
|
||||
|
||||
### Authorization
|
||||
|
||||
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
|
||||
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
<a id="{{name}}{{#isOAuth}}-{{flow}}{{/isOAuth}}"></a>
|
||||
#### {{name}}{{#isOAuth}} {{flow}}{{/isOAuth}}
|
||||
|
||||
{{#isApiKey}}
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: `{{keyParamName}}`
|
||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasicBasic}}
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
|
||||
- **Type**: HTTP Bearer Token authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
|
||||
{{/isBasicBearer}}
|
||||
{{#isHttpSignature}}
|
||||
|
||||
- **Type**: HTTP signature authentication
|
||||
{{/isHttpSignature}}
|
||||
{{#isOAuth}}
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: {{flow}}
|
||||
- **Authorization URL**: {{authorizationUrl}}
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}} - `{{scope}}`: {{description}}
|
||||
{{/scopes}}
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
|
||||
## About
|
||||
|
||||
This TypeScript SDK client supports the [Fetch API](https://fetch.spec.whatwg.org/)
|
||||
and is automatically generated by the
|
||||
[OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: `{{appVersion}}`
|
||||
- Package version: `{{npmVersion}}`
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: `{{generatedDate}}`
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Generator version: `{{generatorVersion}}`
|
||||
- Build package: `{{generatorClass}}`
|
||||
|
||||
The generated npm module supports the following:
|
||||
|
||||
- Environments
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
- Language levels
|
||||
* ES5 - you must have a Promises/A+ library installed
|
||||
* ES6
|
||||
- Module systems
|
||||
* CommonJS
|
||||
* ES6 module system
|
||||
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
## Development
|
||||
|
||||
### Building
|
||||
|
||||
To build the TypeScript source code, you need to have Node.js and npm installed.
|
||||
After cloning the repository, navigate to the project directory and run:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
Once you've built the package, you can publish it to npm:
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[{{licenseInfo}}]({{{licenseUrl}}})
|
||||
Loading…
Add table
Add a link
Reference in a new issue