swagger-axios-codegen
Advanced tools
Comparing version
@@ -0,1 +1,6 @@ | ||
## 0.14.0 | ||
- feat: | ||
- set loading in axios interceptor config | ||
## 0.13.2 | ||
@@ -2,0 +7,0 @@ |
@@ -38,2 +38,4 @@ "use strict"; | ||
export interface IRequestOptions extends AxiosRequestConfig { | ||
/** only in axios interceptor config*/ | ||
loading:boolean; | ||
} | ||
@@ -51,3 +53,5 @@ | ||
export interface ServiceOptions { | ||
axios?: AxiosInstance, | ||
axios?: AxiosInstance; | ||
/** only in axios interceptor config*/ | ||
loading:boolean; | ||
} | ||
@@ -73,2 +77,4 @@ | ||
headers?: any; | ||
/** only in axios interceptor config*/ | ||
loading:boolean; | ||
} | ||
@@ -103,3 +109,5 @@ | ||
export interface ServiceOptions { | ||
axios?: IRequestInstance, | ||
axios?: IRequestInstance; | ||
/** only in axios interceptor config*/ | ||
loading:boolean; | ||
} | ||
@@ -134,3 +142,3 @@ | ||
export function getConfigs(method: string, contentType: string, url: string,options: any):IRequestConfig { | ||
const configs: IRequestConfig = { ...options, method, url }; | ||
const configs: IRequestConfig = { loading:serviceOptions.loading, ...options, method, url }; | ||
configs.headers = { | ||
@@ -137,0 +145,0 @@ ...options.headers, |
{ | ||
"name": "swagger-axios-codegen", | ||
"version": "0.13.3", | ||
"version": "0.14.0", | ||
"main": "./dist/index", | ||
@@ -41,2 +41,2 @@ "typings": "./dist/", | ||
} | ||
} | ||
} |
@@ -313,1 +313,46 @@ # swagger-axios-codegen | ||
At the moment there are only two rules are supported - `required` and `maxLength`. | ||
## Some Solution | ||
### 1.Reference parameters | ||
see in [#53](https://github.com/Manweill/swagger-axios-codegen/issues/53), use package [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser) | ||
### 2.With `Microservice Gateway` | ||
```js | ||
const {codegen} = require('swagger-axios-codegen') | ||
const axios = require('axios') | ||
// host 地址 | ||
const host = 'http://your-host-name' | ||
// | ||
const modules = [ | ||
... | ||
] | ||
axios.get(`${host}/swagger-resources`).then(async ({data}) => { | ||
console.warn('code', host) | ||
for (let n of data) { | ||
if (modules.includes(n.name)) { | ||
try { | ||
await codegen({ | ||
remoteUrl: `${host}${n.url}`, | ||
methodNameMode: 'operationId', | ||
modelMode: 'interface', | ||
strictNullChecks: false, | ||
outputDir: './services', | ||
fileName: `${n.name}.ts`, | ||
sharedServiceOptions: true, | ||
extendDefinitionFile: './customerDefinition.ts', | ||
}) | ||
} catch (e) { | ||
console.log(`${n.name} service error`, e.message) | ||
} | ||
} | ||
} | ||
}) | ||
``` | ||
Sorry, the diff of this file is not supported yet
201236
0.7%2695
0.3%358
14.38%