Skip to content

Commit e62e6d0

Browse files
committed
add typescript-axios-slim templates
1 parent 7a93789 commit e62e6d0

24 files changed

Lines changed: 1270 additions & 0 deletions
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
## {{npmName}}@{{npmVersion}}
2+
3+
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
4+
5+
> `typescript-axios-slim` intentionally differs from `typescript-axios`: it removes `AxiosParamCreator`, `Fp`, and `Factory` layers and emits direct class methods with request-parameter schema validation.
6+
7+
Environment
8+
* Node.js
9+
* Webpack
10+
* Browserify
11+
12+
Language level
13+
* ES5 - you must have a Promises/A+ library installed
14+
* ES6
15+
16+
Module system
17+
* CommonJS
18+
* ES6 module system
19+
20+
It can be used in both TypeScript and JavaScript. In TypeScript, the definition will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html))
21+
22+
### Building
23+
24+
To build and compile the typescript sources to javascript use:
25+
```
26+
npm install
27+
npm run build
28+
```
29+
30+
### Publishing
31+
32+
First build the package then run `npm publish`
33+
34+
### Consuming
35+
36+
navigate to the folder of your consuming project and run one of the following commands.
37+
38+
_published:_
39+
40+
```
41+
npm install {{npmName}}@{{npmVersion}} --save
42+
```
43+
44+
_unPublished (not recommended):_
45+
46+
```
47+
npm install PATH_TO_GENERATED_PACKAGE --save
48+
```
49+
50+
### Documentation for API Endpoints
51+
52+
All URIs are relative to *{{{basePath}}}*
53+
54+
Class | Method | HTTP request | Description
55+
------------ | ------------- | ------------- | -------------
56+
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
57+
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
58+
59+
### Documentation For Models
60+
61+
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
62+
{{/model}}{{/models}}
63+
64+
<a id="documentation-for-authorization"></a>
65+
## Documentation For Authorization
66+
67+
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
68+
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
69+
{{#authMethods}}
70+
<a id="{{name}}"></a>
71+
### {{{name}}}
72+
73+
{{#isApiKey}}
74+
- **Type**: API key
75+
- **API key parameter name**: {{{keyParamName}}}
76+
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
77+
{{/isApiKey}}
78+
{{#isBasic}}
79+
{{#isBasicBasic}}
80+
- **Type**: HTTP basic authentication
81+
{{/isBasicBasic}}
82+
{{#isBasicBearer}}
83+
- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
84+
{{/isBasicBearer}}
85+
{{#isHttpSignature}}
86+
- **Type**: HTTP signature authentication
87+
{{/isHttpSignature}}
88+
{{/isBasic}}
89+
{{#isOAuth}}
90+
- **Type**: OAuth
91+
- **Flow**: {{{flow}}}
92+
- **Authorization URL**: {{{authorizationUrl}}}
93+
- **Scopes**: {{^scopes}}N/A{{/scopes}}
94+
{{#scopes}} - **{{{scope}}}**: {{{description}}}
95+
{{/scopes}}
96+
{{/isOAuth}}
97+
98+
{{/authMethods}}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
{{>licenseInfo}}
4+
5+
6+
{{^withSeparateModelsAndApi}}
7+
import type { Configuration } from './configuration{{importFileExtension}}';
8+
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig, AxiosResponse } from 'axios';
9+
import globalAxios from 'axios';
10+
{{#withNodeImports}}
11+
// URLSearchParams not necessarily used
12+
// @ts-ignore
13+
import { URL, URLSearchParams } from 'url';
14+
{{#multipartFormData}}
15+
import FormData from 'form-data'
16+
{{/multipartFormData}}
17+
{{/withNodeImports}}
18+
import * as v from 'valibot';
19+
// Some imports not used depending on template conditions
20+
// @ts-ignore
21+
import { DUMMY_BASE_URL, validateRequestParameters, withParams, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, replaceWithSerializableTypeIfNeeded{{#withAWSV4Signature}}, setAWS4SignatureInterceptor{{/withAWSV4Signature}} } from './common{{importFileExtension}}';
22+
import type { RequestArgs } from './base{{importFileExtension}}';
23+
// @ts-ignore
24+
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base{{importFileExtension}}';
25+
26+
{{#models}}
27+
{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{#oneOf}}{{#-first}}{{>modelOneOf}}{{/-first}}{{/oneOf}}{{^isEnum}}{{^oneOf}}{{>modelGeneric}}{{/oneOf}}{{/isEnum}}{{/model}}
28+
{{/models}}
29+
{{#apiInfo}}{{#apis}}
30+
{{>apiInner}}
31+
32+
{{/apis}}{{/apiInfo}}
33+
{{/withSeparateModelsAndApi}}{{#withSeparateModelsAndApi}}
34+
{{#apiInfo}}{{#apis}}{{#operations}}export * from './{{tsApiPackage}}/{{classFilename}}{{importFileExtension}}';
35+
{{/operations}}{{/apis}}{{/apiInfo}}
36+
{{/withSeparateModelsAndApi}}

0 commit comments

Comments
 (0)