swagger2api-v3 1.1.6 → 1.1.7
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/utils/index.js +2 -8
- package/package.json +1 -1
package/dist/utils/index.js
CHANGED
|
@@ -298,10 +298,7 @@ function swaggerTypeToTsType(schema, schemas) {
|
|
|
298
298
|
const refName = schema.$ref.split('/').pop();
|
|
299
299
|
baseType = sanitizeTypeName(refName || 'any');
|
|
300
300
|
// 如果提供了 schemas 上下文,检查被引用的 schema 是否是数组类型
|
|
301
|
-
if (schemas &&
|
|
302
|
-
refName &&
|
|
303
|
-
typeof schema.$ref === 'string' &&
|
|
304
|
-
schema.$ref.startsWith('#/')) {
|
|
301
|
+
if (schemas && refName) {
|
|
305
302
|
const referencedSchema = schemas[refName];
|
|
306
303
|
if (referencedSchema && referencedSchema.type === 'array') {
|
|
307
304
|
// 被引用的 schema 是数组类型,添加 []
|
|
@@ -313,10 +310,7 @@ function swaggerTypeToTsType(schema, schemas) {
|
|
|
313
310
|
else if (schema.type === 'array') {
|
|
314
311
|
const itemSchema = schema.items;
|
|
315
312
|
const itemType = swaggerTypeToTsType(itemSchema, schemas);
|
|
316
|
-
if (itemSchema?.$ref &&
|
|
317
|
-
schemas &&
|
|
318
|
-
typeof itemSchema.$ref === 'string' &&
|
|
319
|
-
itemSchema.$ref.startsWith('#/')) {
|
|
313
|
+
if (itemSchema?.$ref && schemas) {
|
|
320
314
|
const refName = itemSchema.$ref.split('/').pop();
|
|
321
315
|
const referencedSchema = refName ? schemas[refName] : undefined;
|
|
322
316
|
if (referencedSchema?.type === 'array') {
|
package/package.json
CHANGED