swaggie 0.7.4 → 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/cli.d.ts +2 -0
- package/dist/gen/js/createBarrel.d.ts +2 -0
- package/dist/gen/js/genOperations.d.ts +15 -0
- package/dist/gen/js/genTypes.d.ts +17 -0
- package/dist/gen/js/index.d.ts +2 -0
- package/dist/gen/js/models.d.ts +40 -0
- package/dist/gen/js/support.d.ts +2 -0
- package/dist/gen/templateManager.d.ts +2 -0
- package/dist/gen/util.d.ts +14 -0
- package/dist/swagger/index.d.ts +3 -0
- package/dist/swagger/operations.d.ts +20 -0
- package/dist/swagger/swagger.d.ts +17 -0
- package/dist/types.d.ts +117 -117
- package/package.json +9 -7
- package/templates/ng1/operation.ejs +21 -1
package/README.md
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|

|
|
9
|
-
[](https://circleci.com/gh/yhnavein/swaggie)
|
|
10
9
|

|
|
11
10
|

|
|
12
11
|

|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IApiOperation, IQueryDefinitions } from './models';
|
|
2
|
+
import { ApiSpec, ApiOperation, ClientOptions } from '../../types';
|
|
3
|
+
export default function genOperations(spec: ApiSpec, operations: ApiOperation[], options: ClientOptions): Promise<[string, IQueryDefinitions]>;
|
|
4
|
+
export declare function prepareOperations(operations: ApiOperation[], options: ClientOptions): [IApiOperation[], IQueryDefinitions];
|
|
5
|
+
/**
|
|
6
|
+
* We will add numbers to the duplicated operation names to avoid breaking code
|
|
7
|
+
* @param operations
|
|
8
|
+
*/
|
|
9
|
+
export declare function fixDuplicateOperations(operations: ApiOperation[]): ApiOperation[];
|
|
10
|
+
export declare function getOperationName(opId: string, group?: string): string;
|
|
11
|
+
export declare function renderOperationGroup(group: any[], func: any, spec: ApiSpec, options: ClientOptions): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Escapes param names to more safe form
|
|
14
|
+
*/
|
|
15
|
+
export declare function getParamName(name: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IQueryDefinitions } from './models';
|
|
2
|
+
import { ApiSpec, ClientOptions } from '../../types';
|
|
3
|
+
export default function genTypes(spec: ApiSpec, queryDefinitions: IQueryDefinitions, options: ClientOptions): string;
|
|
4
|
+
/**
|
|
5
|
+
* Types coming from query models are different and they need to support nesting. Examples:
|
|
6
|
+
* @example
|
|
7
|
+
* 'parameters.filter.name': string, 'parameters.filter.query': string
|
|
8
|
+
* Will need to become:
|
|
9
|
+
* @example
|
|
10
|
+
* {
|
|
11
|
+
* parameters: {
|
|
12
|
+
* filter: { name: string, query: string }
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
export declare function renderQueryStringParameters(def: any, options: ClientOptions): string[];
|
|
17
|
+
export declare function renderComment(comment: string): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ApiOperationParam } from '../../types';
|
|
2
|
+
export interface IApiOperation {
|
|
3
|
+
returnType: string;
|
|
4
|
+
method: string;
|
|
5
|
+
name: string;
|
|
6
|
+
url: string;
|
|
7
|
+
body: object | null | undefined;
|
|
8
|
+
parameters: IOperationParam[];
|
|
9
|
+
headers: IOperationParam[];
|
|
10
|
+
}
|
|
11
|
+
export interface IOperationParam {
|
|
12
|
+
name: string;
|
|
13
|
+
originalName: string;
|
|
14
|
+
type: string;
|
|
15
|
+
optional: boolean;
|
|
16
|
+
value?: string;
|
|
17
|
+
original: ApiOperationParam;
|
|
18
|
+
}
|
|
19
|
+
export interface IServiceClient {
|
|
20
|
+
clientName: string;
|
|
21
|
+
camelCaseName: string;
|
|
22
|
+
baseUrl?: string;
|
|
23
|
+
operations: IApiOperation[];
|
|
24
|
+
}
|
|
25
|
+
export interface IQueryPropDefinition {
|
|
26
|
+
type: string;
|
|
27
|
+
format?: string;
|
|
28
|
+
required?: string[];
|
|
29
|
+
properties?: {
|
|
30
|
+
[key: string]: ApiOperationParam;
|
|
31
|
+
};
|
|
32
|
+
enum?: any;
|
|
33
|
+
fullEnum?: any;
|
|
34
|
+
description?: string;
|
|
35
|
+
'x-enumNames'?: string[];
|
|
36
|
+
queryParam?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface IQueryDefinitions {
|
|
39
|
+
[key: string]: IQueryPropDefinition;
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Stats } from 'fs';
|
|
3
|
+
import { ApiOperation, ApiOperationResponse } from '../types';
|
|
4
|
+
export declare function exists(filePath: string): Stats;
|
|
5
|
+
export declare function saveFile(filePath: string, contents: string): Promise<unknown>;
|
|
6
|
+
export declare function groupOperationsByGroupName(operations: any): any;
|
|
7
|
+
export declare function join(parent: string[], child: string[]): string[];
|
|
8
|
+
export declare function getBestResponse(op: ApiOperation): ApiOperationResponse;
|
|
9
|
+
export declare function escapeReservedWords(name: string): string;
|
|
10
|
+
/** This method tries to fix potentially wrong out parameter given from commandline */
|
|
11
|
+
export declare function prepareOutputFilename(out: string): string;
|
|
12
|
+
export declare function uniq<T>(arr?: T[]): T[];
|
|
13
|
+
export declare function orderBy<T>(arr: T[] | null | undefined, key: string): T[];
|
|
14
|
+
export declare function upperFirst(str?: string | null): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ApiOperation, ApiSpec } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* This method converts dictionary-alike operation definition to operation array.
|
|
4
|
+
* Additionally some data inheritance from the specification is done as well
|
|
5
|
+
* @example
|
|
6
|
+
* {
|
|
7
|
+
* "paths": {
|
|
8
|
+
* "/api/heartbeat": {
|
|
9
|
+
* "get": { ... },
|
|
10
|
+
* "post": { ... }
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* @returns
|
|
15
|
+
* [
|
|
16
|
+
* { "method": "GET", "path": "/api/heartbeat", ... },
|
|
17
|
+
* { "method": "POST", "path": "/api/heartbeat", ... },
|
|
18
|
+
* ]
|
|
19
|
+
*/
|
|
20
|
+
export declare function getOperations(spec: ApiSpec): ApiOperation[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApiSpec } from '../types';
|
|
2
|
+
export interface SpecOptions {
|
|
3
|
+
/**
|
|
4
|
+
* A base ref string to ignore when expanding ref dependencies e.g. '#/definitions/'
|
|
5
|
+
*/
|
|
6
|
+
ignoreRefType?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveSpec(src: string | object, options?: SpecOptions): Promise<ApiSpec>;
|
|
9
|
+
/**
|
|
10
|
+
* Recursively expand internal references in the form `#/path/to/object`.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} data the object to search for and update refs
|
|
13
|
+
* @param {object} lookup the object to clone refs from
|
|
14
|
+
* @param {regexp=} refMatch an optional regex to match specific refs to resolve
|
|
15
|
+
* @returns {object} the resolved data object
|
|
16
|
+
*/
|
|
17
|
+
export declare function expandRefs(data: any, lookup: object, options: SpecOptions): any;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
export interface ClientOptions {
|
|
2
|
-
/**
|
|
3
|
-
* Path or URL to the Swagger specification file (JSON or YAML).
|
|
4
|
-
* Alternatively you can provide parsed object here instead
|
|
5
|
-
**/
|
|
6
|
-
src: string | object;
|
|
7
|
-
/** Path to the file which will contain generated TypeScript code */
|
|
8
|
-
out?: string;
|
|
9
|
-
/** Template to be used for generation */
|
|
10
|
-
template: Template;
|
|
11
|
-
baseUrl?: string;
|
|
12
|
-
preferAny?: boolean;
|
|
13
|
-
servicePrefix?: string;
|
|
14
|
-
/** Generate models for query string instead list of parameters */
|
|
15
|
-
queryModels?: boolean;
|
|
16
|
-
/** How date should be handled. It does not do any special serialization */
|
|
17
|
-
dateFormat?: DateSupport;
|
|
18
|
-
}
|
|
19
|
-
export interface FullAppOptions extends ClientOptions {
|
|
20
|
-
/** Path to the configuration file that contains actual config tp be used */
|
|
21
|
-
config?: string;
|
|
22
|
-
}
|
|
23
|
-
export interface ApiRequestData {
|
|
24
|
-
method: HttpMethod;
|
|
25
|
-
url: string;
|
|
26
|
-
headers: {
|
|
27
|
-
[index: string]: string;
|
|
28
|
-
};
|
|
29
|
-
body: any;
|
|
30
|
-
}
|
|
31
|
-
export interface ApiInfo {
|
|
32
|
-
version: string;
|
|
33
|
-
title: string;
|
|
34
|
-
}
|
|
35
|
-
export interface ApiSpec {
|
|
36
|
-
swagger: string;
|
|
37
|
-
info: ApiInfo;
|
|
38
|
-
host?: string;
|
|
39
|
-
basePath?: string;
|
|
40
|
-
schemes?: string[];
|
|
41
|
-
securityDefinitions?: any;
|
|
42
|
-
paths: any;
|
|
43
|
-
definitions: any;
|
|
44
|
-
accepts: string[];
|
|
45
|
-
contentTypes: string[];
|
|
46
|
-
}
|
|
47
|
-
export declare type Template = 'axios' | 'fetch' | 'ng1' | 'ng2' | 'swr-axios';
|
|
48
|
-
export declare type HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch';
|
|
49
|
-
export declare type DateSupport = 'string' | 'Date';
|
|
50
|
-
export interface ApiOperation {
|
|
51
|
-
id: string;
|
|
52
|
-
summary: string;
|
|
53
|
-
description: string;
|
|
54
|
-
method: HttpMethod;
|
|
55
|
-
group: string;
|
|
56
|
-
path: string;
|
|
57
|
-
parameters: ApiOperationParam[];
|
|
58
|
-
responses: ApiOperationResponse[];
|
|
59
|
-
security?: ApiOperationSecurity[];
|
|
60
|
-
accepts: string[];
|
|
61
|
-
contentTypes: string[];
|
|
62
|
-
tags?: string[];
|
|
63
|
-
}
|
|
64
|
-
export interface ApiOperationParam extends ApiOperationParamBase {
|
|
65
|
-
name: string;
|
|
66
|
-
in: 'header' | 'path' | 'query' | 'body' | 'formData';
|
|
67
|
-
description: string;
|
|
68
|
-
required: boolean;
|
|
69
|
-
readonly?: boolean;
|
|
70
|
-
allowEmptyValue: boolean;
|
|
71
|
-
schema: object;
|
|
72
|
-
'x-nullable'?: boolean;
|
|
73
|
-
'x-schema'?: object;
|
|
74
|
-
}
|
|
75
|
-
declare type CollectionFormat = 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi';
|
|
76
|
-
export interface ApiOperationParamBase {
|
|
77
|
-
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'file';
|
|
78
|
-
format: 'int32' | 'int64' | 'float' | 'double' | 'byte' | 'binary' | 'date' | 'date-time' | 'password';
|
|
79
|
-
items: ApiOperationParamBase;
|
|
80
|
-
collectionFormat: CollectionFormat;
|
|
81
|
-
default: any;
|
|
82
|
-
maximum: number;
|
|
83
|
-
exclusiveMaximum: boolean;
|
|
84
|
-
minimum: number;
|
|
85
|
-
exclusiveMinimum: boolean;
|
|
86
|
-
maxLength: number;
|
|
87
|
-
minLength: number;
|
|
88
|
-
pattern: string;
|
|
89
|
-
maxItems: number;
|
|
90
|
-
minItems: number;
|
|
91
|
-
uniqueItems: boolean;
|
|
92
|
-
enum: any[];
|
|
93
|
-
multipleOf: number;
|
|
94
|
-
}
|
|
95
|
-
export interface ApiOperationParamGroups {
|
|
96
|
-
header?: any;
|
|
97
|
-
path?: any;
|
|
98
|
-
query?: any;
|
|
99
|
-
formData?: any;
|
|
100
|
-
body?: any;
|
|
101
|
-
}
|
|
102
|
-
export interface ApiOperationResponse {
|
|
103
|
-
code: string;
|
|
104
|
-
description: string;
|
|
105
|
-
schema: object;
|
|
106
|
-
headers: object;
|
|
107
|
-
examples: object;
|
|
108
|
-
}
|
|
109
|
-
export interface ApiOperationSecurity {
|
|
110
|
-
id: string;
|
|
111
|
-
scopes?: string[];
|
|
112
|
-
}
|
|
113
|
-
export interface ApiRights {
|
|
114
|
-
query?: any;
|
|
115
|
-
headers?: any;
|
|
116
|
-
}
|
|
117
|
-
export {};
|
|
1
|
+
export interface ClientOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Path or URL to the Swagger specification file (JSON or YAML).
|
|
4
|
+
* Alternatively you can provide parsed object here instead
|
|
5
|
+
**/
|
|
6
|
+
src: string | object;
|
|
7
|
+
/** Path to the file which will contain generated TypeScript code */
|
|
8
|
+
out?: string;
|
|
9
|
+
/** Template to be used for generation */
|
|
10
|
+
template: Template;
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
preferAny?: boolean;
|
|
13
|
+
servicePrefix?: string;
|
|
14
|
+
/** Generate models for query string instead list of parameters */
|
|
15
|
+
queryModels?: boolean;
|
|
16
|
+
/** How date should be handled. It does not do any special serialization */
|
|
17
|
+
dateFormat?: DateSupport;
|
|
18
|
+
}
|
|
19
|
+
export interface FullAppOptions extends ClientOptions {
|
|
20
|
+
/** Path to the configuration file that contains actual config tp be used */
|
|
21
|
+
config?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ApiRequestData {
|
|
24
|
+
method: HttpMethod;
|
|
25
|
+
url: string;
|
|
26
|
+
headers: {
|
|
27
|
+
[index: string]: string;
|
|
28
|
+
};
|
|
29
|
+
body: any;
|
|
30
|
+
}
|
|
31
|
+
export interface ApiInfo {
|
|
32
|
+
version: string;
|
|
33
|
+
title: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ApiSpec {
|
|
36
|
+
swagger: string;
|
|
37
|
+
info: ApiInfo;
|
|
38
|
+
host?: string;
|
|
39
|
+
basePath?: string;
|
|
40
|
+
schemes?: string[];
|
|
41
|
+
securityDefinitions?: any;
|
|
42
|
+
paths: any;
|
|
43
|
+
definitions: any;
|
|
44
|
+
accepts: string[];
|
|
45
|
+
contentTypes: string[];
|
|
46
|
+
}
|
|
47
|
+
export declare type Template = 'axios' | 'fetch' | 'ng1' | 'ng2' | 'swr-axios';
|
|
48
|
+
export declare type HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch';
|
|
49
|
+
export declare type DateSupport = 'string' | 'Date';
|
|
50
|
+
export interface ApiOperation {
|
|
51
|
+
id: string;
|
|
52
|
+
summary: string;
|
|
53
|
+
description: string;
|
|
54
|
+
method: HttpMethod;
|
|
55
|
+
group: string;
|
|
56
|
+
path: string;
|
|
57
|
+
parameters: ApiOperationParam[];
|
|
58
|
+
responses: ApiOperationResponse[];
|
|
59
|
+
security?: ApiOperationSecurity[];
|
|
60
|
+
accepts: string[];
|
|
61
|
+
contentTypes: string[];
|
|
62
|
+
tags?: string[];
|
|
63
|
+
}
|
|
64
|
+
export interface ApiOperationParam extends ApiOperationParamBase {
|
|
65
|
+
name: string;
|
|
66
|
+
in: 'header' | 'path' | 'query' | 'body' | 'formData';
|
|
67
|
+
description: string;
|
|
68
|
+
required: boolean;
|
|
69
|
+
readonly?: boolean;
|
|
70
|
+
allowEmptyValue: boolean;
|
|
71
|
+
schema: object;
|
|
72
|
+
'x-nullable'?: boolean;
|
|
73
|
+
'x-schema'?: object;
|
|
74
|
+
}
|
|
75
|
+
declare type CollectionFormat = 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi';
|
|
76
|
+
export interface ApiOperationParamBase {
|
|
77
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'file';
|
|
78
|
+
format: 'int32' | 'int64' | 'float' | 'double' | 'byte' | 'binary' | 'date' | 'date-time' | 'password';
|
|
79
|
+
items: ApiOperationParamBase;
|
|
80
|
+
collectionFormat: CollectionFormat;
|
|
81
|
+
default: any;
|
|
82
|
+
maximum: number;
|
|
83
|
+
exclusiveMaximum: boolean;
|
|
84
|
+
minimum: number;
|
|
85
|
+
exclusiveMinimum: boolean;
|
|
86
|
+
maxLength: number;
|
|
87
|
+
minLength: number;
|
|
88
|
+
pattern: string;
|
|
89
|
+
maxItems: number;
|
|
90
|
+
minItems: number;
|
|
91
|
+
uniqueItems: boolean;
|
|
92
|
+
enum: any[];
|
|
93
|
+
multipleOf: number;
|
|
94
|
+
}
|
|
95
|
+
export interface ApiOperationParamGroups {
|
|
96
|
+
header?: any;
|
|
97
|
+
path?: any;
|
|
98
|
+
query?: any;
|
|
99
|
+
formData?: any;
|
|
100
|
+
body?: any;
|
|
101
|
+
}
|
|
102
|
+
export interface ApiOperationResponse {
|
|
103
|
+
code: string;
|
|
104
|
+
description: string;
|
|
105
|
+
schema: object;
|
|
106
|
+
headers: object;
|
|
107
|
+
examples: object;
|
|
108
|
+
}
|
|
109
|
+
export interface ApiOperationSecurity {
|
|
110
|
+
id: string;
|
|
111
|
+
scopes?: string[];
|
|
112
|
+
}
|
|
113
|
+
export interface ApiRights {
|
|
114
|
+
query?: any;
|
|
115
|
+
headers?: any;
|
|
116
|
+
}
|
|
117
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swaggie",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "Generate ES6 or TypeScript service integration code from an OpenAPI spec",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Piotr Dabrowski",
|
|
@@ -45,20 +45,22 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"case": "^1.6.3",
|
|
47
47
|
"commander": "^8.3.0",
|
|
48
|
-
"dset": "^3.1.
|
|
48
|
+
"dset": "^3.1.2",
|
|
49
49
|
"eta": "^1.12.3",
|
|
50
50
|
"js-yaml": "^4.1.0",
|
|
51
51
|
"nanocolors": "^0.2.0",
|
|
52
52
|
"node-fetch": "^2.6.7"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@types/chai": "4.3.
|
|
55
|
+
"@types/chai": "4.3.3",
|
|
56
56
|
"@types/js-yaml": "4.0.5",
|
|
57
|
-
"@types/mocha": "
|
|
57
|
+
"@types/mocha": "10.0.0",
|
|
58
58
|
"@types/node-fetch": "2.5.12",
|
|
59
|
+
"@types/sinon": "^10.0.13",
|
|
59
60
|
"chai": "4.3.6",
|
|
60
|
-
"mocha": "
|
|
61
|
-
"
|
|
62
|
-
"
|
|
61
|
+
"mocha": "10.1.0",
|
|
62
|
+
"sinon": "^14.0.1",
|
|
63
|
+
"sucrase": "3.28.0",
|
|
64
|
+
"typescript": "4.8.4"
|
|
63
65
|
}
|
|
64
66
|
}
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
<%= it.name %>(<% it.parameters.forEach((parameter) => { %>
|
|
9
9
|
<%= parameter.name %>: <%~ parameter.type %> <%= parameter.optional ? ' | null | undefined' : '' %>,
|
|
10
10
|
<% }); %>
|
|
11
|
-
|
|
11
|
+
<% if(it.formData && it.formData.length > 0) { %>
|
|
12
|
+
config: IRequestShortcutConfig = {headers: {'Content-Type': undefined}}
|
|
13
|
+
<% } else { %>
|
|
14
|
+
config?: IRequestShortcutConfig
|
|
15
|
+
<% } %>
|
|
12
16
|
): IPromise<<%~ it.returnType %>> {
|
|
13
17
|
let url = '<%= it.url %>?';
|
|
14
18
|
<% if(it.pathParams && it.pathParams.length > 0) {
|
|
@@ -16,6 +20,18 @@ config?: IRequestShortcutConfig
|
|
|
16
20
|
url = url.replace('{<%= parameter.name %>}', encodeURIComponent("" + <%= parameter.name %>));
|
|
17
21
|
<% });
|
|
18
22
|
} %>
|
|
23
|
+
<% if(it.formData && it.formData.length > 0) { %>
|
|
24
|
+
const formDataBody = new FormData();
|
|
25
|
+
<% it.formData.forEach((parameter) => { %>
|
|
26
|
+
if (!!<%= parameter.name %>) {
|
|
27
|
+
<% if(parameter.original && parameter.original.type === 'array') { %>
|
|
28
|
+
<%= parameter.name %>.forEach((f: any) => formDataBody.append(`<%= parameter.originalName %>`, f));
|
|
29
|
+
<% } else { %>
|
|
30
|
+
formDataBody.append("<%= parameter.originalName %>", <%= parameter.name %><%= parameter.type === 'Date' ? '.toISOString()' : (parameter.type !== 'string' && parameter.type !== 'File' && parameter.type !== 'Blob' ? '.toString()' : '') %>);
|
|
31
|
+
<% } %>
|
|
32
|
+
}
|
|
33
|
+
<% });
|
|
34
|
+
} %>
|
|
19
35
|
<% if(it.query && it.query.length > 0) { %>
|
|
20
36
|
<% it.query.forEach((parameter) => { %>
|
|
21
37
|
if (<%= parameter.name %> !== undefined) {
|
|
@@ -31,7 +47,11 @@ config?: IRequestShortcutConfig
|
|
|
31
47
|
return this.$<%= it.method.toLowerCase() %>(
|
|
32
48
|
url,
|
|
33
49
|
<% if(['POST', 'PUT', 'PATCH'].includes(it.method)) { %>
|
|
50
|
+
<% if(it.formData && it.formData.length > 0) { %>
|
|
51
|
+
formDataBody,
|
|
52
|
+
<% } else { %>
|
|
34
53
|
<%= it.body ? it.body.name : 'null' %>,
|
|
54
|
+
<% } %>
|
|
35
55
|
<% } %>
|
|
36
56
|
config
|
|
37
57
|
);
|