@grandlinex/swagger-mate 1.2.1 → 1.3.1
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/dist/cjs/Swagger/Client/ClientUtil.d.ts +18 -4
- package/dist/cjs/Swagger/Client/ClientUtil.js +51 -8
- package/dist/cjs/Swagger/Client/InterfaceTemplate.js +1 -1
- package/dist/cjs/Swagger/Client/SwaggerClient.js +5 -5
- package/dist/cjs/Swagger/Meta/SwaggerTypes.d.ts +1 -0
- package/dist/cjs/Swagger/Path/SPathUtil.js +3 -3
- package/dist/cjs/Swagger/SwaggerUtil.js +8 -4
- package/dist/mjs/Swagger/Client/ClientUtil.d.ts +18 -4
- package/dist/mjs/Swagger/Client/ClientUtil.js +50 -8
- package/dist/mjs/Swagger/Client/InterfaceTemplate.js +2 -2
- package/dist/mjs/Swagger/Client/SwaggerClient.js +5 -5
- package/dist/mjs/Swagger/Meta/SwaggerTypes.d.ts +1 -0
- package/dist/mjs/Swagger/Path/SPathUtil.js +3 -3
- package/dist/mjs/Swagger/SwaggerUtil.js +8 -4
- package/package.json +10 -8
|
@@ -3,6 +3,7 @@ export type IfMappingKeyType = {
|
|
|
3
3
|
key: string;
|
|
4
4
|
type: string;
|
|
5
5
|
required?: boolean;
|
|
6
|
+
nullable?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export type IfMappingType = {
|
|
8
9
|
name: string;
|
|
@@ -10,15 +11,28 @@ export type IfMappingType = {
|
|
|
10
11
|
rawType?: string;
|
|
11
12
|
};
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* Returns a string representation of the given value. If the value is falsy,
|
|
15
|
+
* an empty string is returned.
|
|
16
|
+
*
|
|
17
|
+
* @param e - The value to convert to a string.
|
|
18
|
+
* @returns The string representation of `e`, or an empty string if `e` is falsy.
|
|
15
19
|
*/
|
|
16
20
|
export declare function eS(e: any): string;
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
22
|
+
* Returns a type annotation delimiter based on whether a value is required.
|
|
23
|
+
*
|
|
24
|
+
* @param {boolean} [required] - Indicates if the value is required. If omitted or false, the value is considered optional.
|
|
25
|
+
* @returns {string} A colon (`:`) for required values or a question mark followed by a colon (`?:`) for optional values.
|
|
20
26
|
*/
|
|
21
27
|
export declare function rq(required?: boolean): string;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a type representation based on whether the value should be nullable.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} type - The base type name to return when the value is not nullable.
|
|
32
|
+
* @param {boolean} nullable - Indicates if the type should be considered nullable. If `true`, the function returns a colon (`:`); if `false`, it returns the original type string.
|
|
33
|
+
* @return {string} The original type string when `nullable` is `false`, otherwise a colon (`:`) to represent a nullable type in the consuming context.
|
|
34
|
+
*/
|
|
35
|
+
export declare function rN(type: string, nullable?: boolean): string;
|
|
22
36
|
export declare function sK(e: string): string;
|
|
23
37
|
/**
|
|
24
38
|
* Cast first letter to uppercase
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IFTag = void 0;
|
|
4
4
|
exports.eS = eS;
|
|
5
5
|
exports.rq = rq;
|
|
6
|
+
exports.rN = rN;
|
|
6
7
|
exports.sK = sK;
|
|
7
8
|
exports.fuc = fuc;
|
|
8
9
|
exports.S = S;
|
|
@@ -13,15 +14,20 @@ exports.transformInterface = transformInterface;
|
|
|
13
14
|
exports.transformFormInterface = transformFormInterface;
|
|
14
15
|
const SwaggerTypes_js_1 = require("../Meta/SwaggerTypes.js");
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
17
|
+
* Returns a string representation of the given value. If the value is falsy,
|
|
18
|
+
* an empty string is returned.
|
|
19
|
+
*
|
|
20
|
+
* @param e - The value to convert to a string.
|
|
21
|
+
* @returns The string representation of `e`, or an empty string if `e` is falsy.
|
|
18
22
|
*/
|
|
19
23
|
function eS(e) {
|
|
20
24
|
return e || '';
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
27
|
+
* Returns a type annotation delimiter based on whether a value is required.
|
|
28
|
+
*
|
|
29
|
+
* @param {boolean} [required] - Indicates if the value is required. If omitted or false, the value is considered optional.
|
|
30
|
+
* @returns {string} A colon (`:`) for required values or a question mark followed by a colon (`?:`) for optional values.
|
|
25
31
|
*/
|
|
26
32
|
function rq(required) {
|
|
27
33
|
if (!required) {
|
|
@@ -29,6 +35,19 @@ function rq(required) {
|
|
|
29
35
|
}
|
|
30
36
|
return ':';
|
|
31
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns a type representation based on whether the value should be nullable.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} type - The base type name to return when the value is not nullable.
|
|
42
|
+
* @param {boolean} nullable - Indicates if the type should be considered nullable. If `true`, the function returns a colon (`:`); if `false`, it returns the original type string.
|
|
43
|
+
* @return {string} The original type string when `nullable` is `false`, otherwise a colon (`:`) to represent a nullable type in the consuming context.
|
|
44
|
+
*/
|
|
45
|
+
function rN(type, nullable) {
|
|
46
|
+
if (nullable) {
|
|
47
|
+
return `${type} | null`;
|
|
48
|
+
}
|
|
49
|
+
return type;
|
|
50
|
+
}
|
|
32
51
|
function sK(e) {
|
|
33
52
|
if (e.indexOf(':') >= 0) {
|
|
34
53
|
return `'${e}'`;
|
|
@@ -98,20 +117,41 @@ function transformInterface(operation, tag, schema) {
|
|
|
98
117
|
const prop = schema.properties[key];
|
|
99
118
|
const isRequired = schema.required && schema.required.includes(key);
|
|
100
119
|
if (!(0, SwaggerTypes_js_1.isSwaggerRef)(prop)) {
|
|
120
|
+
const nullable = prop.nullable ?? false;
|
|
101
121
|
switch (prop.type) {
|
|
102
122
|
case 'number':
|
|
103
123
|
case 'integer':
|
|
104
|
-
cur.keys.push({
|
|
124
|
+
cur.keys.push({
|
|
125
|
+
key,
|
|
126
|
+
type: 'number',
|
|
127
|
+
required: isRequired,
|
|
128
|
+
nullable,
|
|
129
|
+
});
|
|
105
130
|
break;
|
|
106
131
|
case 'string':
|
|
107
|
-
cur.keys.push({
|
|
132
|
+
cur.keys.push({
|
|
133
|
+
key,
|
|
134
|
+
type: 'string',
|
|
135
|
+
required: isRequired,
|
|
136
|
+
nullable,
|
|
137
|
+
});
|
|
108
138
|
break;
|
|
109
139
|
case 'boolean':
|
|
110
|
-
cur.keys.push({
|
|
140
|
+
cur.keys.push({
|
|
141
|
+
key,
|
|
142
|
+
type: 'boolean',
|
|
143
|
+
required: isRequired,
|
|
144
|
+
nullable,
|
|
145
|
+
});
|
|
111
146
|
break;
|
|
112
147
|
case 'object':
|
|
113
148
|
if (!prop.properties) {
|
|
114
|
-
cur.keys.push({
|
|
149
|
+
cur.keys.push({
|
|
150
|
+
key,
|
|
151
|
+
type: 'any',
|
|
152
|
+
required: isRequired,
|
|
153
|
+
nullable,
|
|
154
|
+
});
|
|
115
155
|
}
|
|
116
156
|
else {
|
|
117
157
|
cur.keys.push({
|
|
@@ -128,6 +168,7 @@ function transformInterface(operation, tag, schema) {
|
|
|
128
168
|
key,
|
|
129
169
|
type: `${typeByRef(prop.items.$ref)}[]`,
|
|
130
170
|
required: isRequired,
|
|
171
|
+
nullable,
|
|
131
172
|
});
|
|
132
173
|
}
|
|
133
174
|
else {
|
|
@@ -135,6 +176,7 @@ function transformInterface(operation, tag, schema) {
|
|
|
135
176
|
key,
|
|
136
177
|
type: `${ifName(cur.name, `${key}Element`)}[]`,
|
|
137
178
|
required: isRequired,
|
|
179
|
+
nullable,
|
|
138
180
|
});
|
|
139
181
|
out.push(...transformInterface(cur.name, key, prop));
|
|
140
182
|
}
|
|
@@ -147,6 +189,7 @@ function transformInterface(operation, tag, schema) {
|
|
|
147
189
|
key,
|
|
148
190
|
type: typeByRef(prop.$ref),
|
|
149
191
|
required: isRequired,
|
|
192
|
+
nullable: schema.nullable ?? false,
|
|
150
193
|
});
|
|
151
194
|
}
|
|
152
195
|
}
|
|
@@ -8,6 +8,6 @@ function interfaceTemplate(IF_NAME, types, rawType) {
|
|
|
8
8
|
return `export type ${IF_NAME} = ${rawType};`;
|
|
9
9
|
}
|
|
10
10
|
return `export interface ${IF_NAME} {
|
|
11
|
-
${types.map(({ key, type, required }) => `${(0, ClientUtil_js_1.S)(2)}${(0, ClientUtil_js_1.sK)(key)}${(0, ClientUtil_js_1.rq)(required)} ${type};`).join('\n')}
|
|
11
|
+
${types.map(({ key, type, required, nullable }) => `${(0, ClientUtil_js_1.S)(2)}${(0, ClientUtil_js_1.sK)(key)}${(0, ClientUtil_js_1.rq)(required)} ${(0, ClientUtil_js_1.rN)(type, nullable)};`).join('\n')}
|
|
12
12
|
}`;
|
|
13
13
|
}
|
|
@@ -181,13 +181,13 @@ function createPackage(name, version, module) {
|
|
|
181
181
|
types: 'dist/index.d.ts',
|
|
182
182
|
module: module ? 'dist/index.js' : undefined,
|
|
183
183
|
type: module ? 'module' : undefined,
|
|
184
|
-
dependencies: {
|
|
185
|
-
'form-data': '4.0.4',
|
|
186
|
-
axios: '1.11.0',
|
|
187
|
-
},
|
|
188
184
|
devDependencies: {
|
|
189
185
|
'@types/node': '22.15.32',
|
|
190
|
-
typescript: '5.
|
|
186
|
+
typescript: '5.9.2',
|
|
187
|
+
},
|
|
188
|
+
peerDependencies: {
|
|
189
|
+
axios: '>=1.13.2',
|
|
190
|
+
'form-data': '>=4.0.5',
|
|
191
191
|
},
|
|
192
192
|
scripts: {
|
|
193
193
|
build: 'tsc',
|
|
@@ -8,6 +8,7 @@ const SUtilMap_js_1 = __importDefault(require("./SUtilMap.js"));
|
|
|
8
8
|
function resolveDBType(dType) {
|
|
9
9
|
switch (dType) {
|
|
10
10
|
case 'int':
|
|
11
|
+
case 'long':
|
|
11
12
|
return 'integer';
|
|
12
13
|
case 'double':
|
|
13
14
|
case 'float':
|
|
@@ -174,11 +175,10 @@ class SPathUtil {
|
|
|
174
175
|
keys.forEach((k) => {
|
|
175
176
|
const cMeta = (0, core_1.getColumnMeta)(entity, k);
|
|
176
177
|
if (cMeta && schema.properties) {
|
|
177
|
-
|
|
178
|
-
schema.required?.push(k);
|
|
179
|
-
}
|
|
178
|
+
schema.required.push(k);
|
|
180
179
|
schema.properties[k] = {
|
|
181
180
|
type: resolveDBType(cMeta.dataType),
|
|
181
|
+
nullable: cMeta.canBeNull,
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
});
|
|
@@ -118,10 +118,14 @@ class SwaggerUtil {
|
|
|
118
118
|
parameters: route.meta?.parameters,
|
|
119
119
|
};
|
|
120
120
|
if (route.meta) {
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
// Handle requestBody
|
|
122
|
+
if (!conf.requestBody) {
|
|
123
|
+
if (route.meta.requestSchema) {
|
|
124
|
+
conf.requestBody = index_js_2.SPathUtil.jsonBody(route.meta.requestSchema);
|
|
125
|
+
}
|
|
123
126
|
}
|
|
124
|
-
|
|
127
|
+
// Handle responses
|
|
128
|
+
if (route.meta.responseSchema) {
|
|
125
129
|
const ax = route.meta.responseCodes?.slice(1) || [];
|
|
126
130
|
if (typeof route.meta.responseSchema === 'string' ||
|
|
127
131
|
(0, core_1.instanceOfEntity)(route.meta.responseSchema)) {
|
|
@@ -134,7 +138,7 @@ class SwaggerUtil {
|
|
|
134
138
|
else if (route.meta.responseCodes) {
|
|
135
139
|
conf.responses = index_js_2.SPathUtil.defaultResponse(...route.meta.responseCodes);
|
|
136
140
|
}
|
|
137
|
-
|
|
141
|
+
if (!conf.responses) {
|
|
138
142
|
conf.responses = index_js_2.SPathUtil.defaultResponse('200');
|
|
139
143
|
}
|
|
140
144
|
}
|
|
@@ -3,6 +3,7 @@ export type IfMappingKeyType = {
|
|
|
3
3
|
key: string;
|
|
4
4
|
type: string;
|
|
5
5
|
required?: boolean;
|
|
6
|
+
nullable?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export type IfMappingType = {
|
|
8
9
|
name: string;
|
|
@@ -10,15 +11,28 @@ export type IfMappingType = {
|
|
|
10
11
|
rawType?: string;
|
|
11
12
|
};
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* Returns a string representation of the given value. If the value is falsy,
|
|
15
|
+
* an empty string is returned.
|
|
16
|
+
*
|
|
17
|
+
* @param e - The value to convert to a string.
|
|
18
|
+
* @returns The string representation of `e`, or an empty string if `e` is falsy.
|
|
15
19
|
*/
|
|
16
20
|
export declare function eS(e: any): string;
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
22
|
+
* Returns a type annotation delimiter based on whether a value is required.
|
|
23
|
+
*
|
|
24
|
+
* @param {boolean} [required] - Indicates if the value is required. If omitted or false, the value is considered optional.
|
|
25
|
+
* @returns {string} A colon (`:`) for required values or a question mark followed by a colon (`?:`) for optional values.
|
|
20
26
|
*/
|
|
21
27
|
export declare function rq(required?: boolean): string;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a type representation based on whether the value should be nullable.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} type - The base type name to return when the value is not nullable.
|
|
32
|
+
* @param {boolean} nullable - Indicates if the type should be considered nullable. If `true`, the function returns a colon (`:`); if `false`, it returns the original type string.
|
|
33
|
+
* @return {string} The original type string when `nullable` is `false`, otherwise a colon (`:`) to represent a nullable type in the consuming context.
|
|
34
|
+
*/
|
|
35
|
+
export declare function rN(type: string, nullable?: boolean): string;
|
|
22
36
|
export declare function sK(e: string): string;
|
|
23
37
|
/**
|
|
24
38
|
* Cast first letter to uppercase
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { isSwaggerRef } from '../Meta/SwaggerTypes.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Returns a string representation of the given value. If the value is falsy,
|
|
4
|
+
* an empty string is returned.
|
|
5
|
+
*
|
|
6
|
+
* @param e - The value to convert to a string.
|
|
7
|
+
* @returns The string representation of `e`, or an empty string if `e` is falsy.
|
|
5
8
|
*/
|
|
6
9
|
export function eS(e) {
|
|
7
10
|
return e || '';
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
13
|
+
* Returns a type annotation delimiter based on whether a value is required.
|
|
14
|
+
*
|
|
15
|
+
* @param {boolean} [required] - Indicates if the value is required. If omitted or false, the value is considered optional.
|
|
16
|
+
* @returns {string} A colon (`:`) for required values or a question mark followed by a colon (`?:`) for optional values.
|
|
12
17
|
*/
|
|
13
18
|
export function rq(required) {
|
|
14
19
|
if (!required) {
|
|
@@ -16,6 +21,19 @@ export function rq(required) {
|
|
|
16
21
|
}
|
|
17
22
|
return ':';
|
|
18
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns a type representation based on whether the value should be nullable.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} type - The base type name to return when the value is not nullable.
|
|
28
|
+
* @param {boolean} nullable - Indicates if the type should be considered nullable. If `true`, the function returns a colon (`:`); if `false`, it returns the original type string.
|
|
29
|
+
* @return {string} The original type string when `nullable` is `false`, otherwise a colon (`:`) to represent a nullable type in the consuming context.
|
|
30
|
+
*/
|
|
31
|
+
export function rN(type, nullable) {
|
|
32
|
+
if (nullable) {
|
|
33
|
+
return `${type} | null`;
|
|
34
|
+
}
|
|
35
|
+
return type;
|
|
36
|
+
}
|
|
19
37
|
export function sK(e) {
|
|
20
38
|
if (e.indexOf(':') >= 0) {
|
|
21
39
|
return `'${e}'`;
|
|
@@ -85,20 +103,41 @@ export function transformInterface(operation, tag, schema) {
|
|
|
85
103
|
const prop = schema.properties[key];
|
|
86
104
|
const isRequired = schema.required && schema.required.includes(key);
|
|
87
105
|
if (!isSwaggerRef(prop)) {
|
|
106
|
+
const nullable = prop.nullable ?? false;
|
|
88
107
|
switch (prop.type) {
|
|
89
108
|
case 'number':
|
|
90
109
|
case 'integer':
|
|
91
|
-
cur.keys.push({
|
|
110
|
+
cur.keys.push({
|
|
111
|
+
key,
|
|
112
|
+
type: 'number',
|
|
113
|
+
required: isRequired,
|
|
114
|
+
nullable,
|
|
115
|
+
});
|
|
92
116
|
break;
|
|
93
117
|
case 'string':
|
|
94
|
-
cur.keys.push({
|
|
118
|
+
cur.keys.push({
|
|
119
|
+
key,
|
|
120
|
+
type: 'string',
|
|
121
|
+
required: isRequired,
|
|
122
|
+
nullable,
|
|
123
|
+
});
|
|
95
124
|
break;
|
|
96
125
|
case 'boolean':
|
|
97
|
-
cur.keys.push({
|
|
126
|
+
cur.keys.push({
|
|
127
|
+
key,
|
|
128
|
+
type: 'boolean',
|
|
129
|
+
required: isRequired,
|
|
130
|
+
nullable,
|
|
131
|
+
});
|
|
98
132
|
break;
|
|
99
133
|
case 'object':
|
|
100
134
|
if (!prop.properties) {
|
|
101
|
-
cur.keys.push({
|
|
135
|
+
cur.keys.push({
|
|
136
|
+
key,
|
|
137
|
+
type: 'any',
|
|
138
|
+
required: isRequired,
|
|
139
|
+
nullable,
|
|
140
|
+
});
|
|
102
141
|
}
|
|
103
142
|
else {
|
|
104
143
|
cur.keys.push({
|
|
@@ -115,6 +154,7 @@ export function transformInterface(operation, tag, schema) {
|
|
|
115
154
|
key,
|
|
116
155
|
type: `${typeByRef(prop.items.$ref)}[]`,
|
|
117
156
|
required: isRequired,
|
|
157
|
+
nullable,
|
|
118
158
|
});
|
|
119
159
|
}
|
|
120
160
|
else {
|
|
@@ -122,6 +162,7 @@ export function transformInterface(operation, tag, schema) {
|
|
|
122
162
|
key,
|
|
123
163
|
type: `${ifName(cur.name, `${key}Element`)}[]`,
|
|
124
164
|
required: isRequired,
|
|
165
|
+
nullable,
|
|
125
166
|
});
|
|
126
167
|
out.push(...transformInterface(cur.name, key, prop));
|
|
127
168
|
}
|
|
@@ -134,6 +175,7 @@ export function transformInterface(operation, tag, schema) {
|
|
|
134
175
|
key,
|
|
135
176
|
type: typeByRef(prop.$ref),
|
|
136
177
|
required: isRequired,
|
|
178
|
+
nullable: schema.nullable ?? false,
|
|
137
179
|
});
|
|
138
180
|
}
|
|
139
181
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable prettier/prettier */
|
|
2
|
-
import { rq, S, sK } from './ClientUtil.js';
|
|
2
|
+
import { rq, S, sK, rN } from './ClientUtil.js';
|
|
3
3
|
function interfaceTemplate(IF_NAME, types, rawType) {
|
|
4
4
|
if (rawType) {
|
|
5
5
|
return `export type ${IF_NAME} = ${rawType};`;
|
|
6
6
|
}
|
|
7
7
|
return `export interface ${IF_NAME} {
|
|
8
|
-
${types.map(({ key, type, required }) => `${S(2)}${sK(key)}${rq(required)} ${type};`).join('\n')}
|
|
8
|
+
${types.map(({ key, type, required, nullable }) => `${S(2)}${sK(key)}${rq(required)} ${rN(type, nullable)};`).join('\n')}
|
|
9
9
|
}`;
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
@@ -143,13 +143,13 @@ function createPackage(name, version, module) {
|
|
|
143
143
|
types: 'dist/index.d.ts',
|
|
144
144
|
module: module ? 'dist/index.js' : undefined,
|
|
145
145
|
type: module ? 'module' : undefined,
|
|
146
|
-
dependencies: {
|
|
147
|
-
'form-data': '4.0.4',
|
|
148
|
-
axios: '1.11.0',
|
|
149
|
-
},
|
|
150
146
|
devDependencies: {
|
|
151
147
|
'@types/node': '22.15.32',
|
|
152
|
-
typescript: '5.
|
|
148
|
+
typescript: '5.9.2',
|
|
149
|
+
},
|
|
150
|
+
peerDependencies: {
|
|
151
|
+
axios: '>=1.13.2',
|
|
152
|
+
'form-data': '>=4.0.5',
|
|
153
153
|
},
|
|
154
154
|
scripts: {
|
|
155
155
|
build: 'tsc',
|
|
@@ -3,6 +3,7 @@ import map from './SUtilMap.js';
|
|
|
3
3
|
function resolveDBType(dType) {
|
|
4
4
|
switch (dType) {
|
|
5
5
|
case 'int':
|
|
6
|
+
case 'long':
|
|
6
7
|
return 'integer';
|
|
7
8
|
case 'double':
|
|
8
9
|
case 'float':
|
|
@@ -169,11 +170,10 @@ export default class SPathUtil {
|
|
|
169
170
|
keys.forEach((k) => {
|
|
170
171
|
const cMeta = getColumnMeta(entity, k);
|
|
171
172
|
if (cMeta && schema.properties) {
|
|
172
|
-
|
|
173
|
-
schema.required?.push(k);
|
|
174
|
-
}
|
|
173
|
+
schema.required.push(k);
|
|
175
174
|
schema.properties[k] = {
|
|
176
175
|
type: resolveDBType(cMeta.dataType),
|
|
176
|
+
nullable: cMeta.canBeNull,
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
});
|
|
@@ -80,10 +80,14 @@ export default class SwaggerUtil {
|
|
|
80
80
|
parameters: route.meta?.parameters,
|
|
81
81
|
};
|
|
82
82
|
if (route.meta) {
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
// Handle requestBody
|
|
84
|
+
if (!conf.requestBody) {
|
|
85
|
+
if (route.meta.requestSchema) {
|
|
86
|
+
conf.requestBody = SPathUtil.jsonBody(route.meta.requestSchema);
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
|
-
|
|
89
|
+
// Handle responses
|
|
90
|
+
if (route.meta.responseSchema) {
|
|
87
91
|
const ax = route.meta.responseCodes?.slice(1) || [];
|
|
88
92
|
if (typeof route.meta.responseSchema === 'string' ||
|
|
89
93
|
instanceOfEntity(route.meta.responseSchema)) {
|
|
@@ -96,7 +100,7 @@ export default class SwaggerUtil {
|
|
|
96
100
|
else if (route.meta.responseCodes) {
|
|
97
101
|
conf.responses = SPathUtil.defaultResponse(...route.meta.responseCodes);
|
|
98
102
|
}
|
|
99
|
-
|
|
103
|
+
if (!conf.responses) {
|
|
100
104
|
conf.responses = SPathUtil.defaultResponse('200');
|
|
101
105
|
}
|
|
102
106
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grandlinex/swagger-mate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -38,17 +38,19 @@
|
|
|
38
38
|
"swagger-mate-esm": "./dist/mjs/cli.js"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@grandlinex/core": "1.
|
|
42
|
-
"
|
|
43
|
-
"form-data": "4.0.4",
|
|
44
|
-
"js-yaml": "4.1.0",
|
|
41
|
+
"@grandlinex/core": "1.3.1",
|
|
42
|
+
"js-yaml": "4.1.1",
|
|
45
43
|
"reflect-metadata": "0.2.2"
|
|
46
44
|
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"express": ">=5.2.1",
|
|
47
|
+
"form-data": ">=4.0.5"
|
|
48
|
+
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"axios": "1.
|
|
50
|
+
"axios": "1.13.2",
|
|
49
51
|
"node-fetch": "3.3.2",
|
|
50
52
|
"cross-env": "10.0.0",
|
|
51
|
-
"@types/express": "5.0.
|
|
53
|
+
"@types/express": "5.0.6",
|
|
52
54
|
"@types/js-yaml": "4.0.9",
|
|
53
55
|
"@types/jest": "29.5.14",
|
|
54
56
|
"@types/node": "22.15.20",
|
|
@@ -68,7 +70,7 @@
|
|
|
68
70
|
"ts-jest": "29.3.4",
|
|
69
71
|
"ts-loader": "9.5.2",
|
|
70
72
|
"ts-node": "10.9.2",
|
|
71
|
-
"typedoc": "0.28.
|
|
73
|
+
"typedoc": "0.28.15",
|
|
72
74
|
"typescript": "5.9.2"
|
|
73
75
|
}
|
|
74
76
|
}
|