@rjgf/swagger2ts
Advanced tools
Comparing version 0.1.18 to 0.1.19
@@ -102,4 +102,5 @@ "use strict"; | ||
// if it's top level type | ||
const comments = [ | ||
const commentsArray = [ | ||
// description | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
c.description, | ||
@@ -110,3 +111,3 @@ // format | ||
if (!parent) { | ||
const comment = `${generateJSDocs(comments, 0)}`; | ||
const comment = `${generateJSDocs(commentsArray, 0)}`; | ||
if (c.enum) { | ||
@@ -139,2 +140,3 @@ return `${comment} | ||
*/ | ||
// eslint-disable-next-line import/no-unused-modules | ||
function generate(swaggerJSONStr, options = {}) { | ||
@@ -171,14 +173,14 @@ var _a, _b; | ||
const queryArr = []; | ||
for (const params of instance.parameters) { | ||
if (params.in !== 'query') { | ||
for (const paramsObj of instance.parameters) { | ||
if (paramsObj.in !== 'query') { | ||
continue; | ||
} | ||
let isOptional = (_b = params.required) !== null && _b !== void 0 ? _b : params.schema.nullable; | ||
if (isOptional == void 0 && swagger_1.isRefComponent(params.schema)) { | ||
const component = extraSchema(params.schema.$ref); | ||
let isOptional = (_b = paramsObj.required) !== null && _b !== void 0 ? _b : paramsObj.schema.nullable; | ||
if (isOptional == void 0 && swagger_1.isRefComponent(paramsObj.schema)) { | ||
const component = extraSchema(paramsObj.schema.$ref); | ||
isOptional = !!component.nullable; | ||
} | ||
const type = generateComponent(void 0, params.schema, indent, params.schema); | ||
const type = generateComponent(void 0, paramsObj.schema, indent, paramsObj.schema); | ||
queryArr.push({ | ||
key: params.name, | ||
key: paramsObj.name, | ||
value: type, | ||
@@ -188,5 +190,5 @@ optional: isOptional, | ||
// description | ||
params.schema.description ? params.schema.description : '', | ||
paramsObj.schema.description ? paramsObj.schema.description : '', | ||
// format | ||
params.schema.format ? 'format: ' + params.schema.format : '', | ||
paramsObj.schema.format ? 'format: ' + paramsObj.schema.format : '', | ||
], | ||
@@ -238,4 +240,4 @@ }); | ||
const tags = []; | ||
for (const tag of instance.tags) { | ||
const definedTag = swaggerJSON.tags.find((t) => t.name === tag); | ||
for (const tagName of instance.tags) { | ||
const definedTag = swaggerJSON.tags.find((t) => t.name === tagName); | ||
if (definedTag) { | ||
@@ -242,0 +244,0 @@ tags.push(definedTag.description); |
"use strict"; | ||
/* eslint-disable import/no-unused-modules */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -17,3 +18,3 @@ exports.isBooleanComponent = exports.isNumberComponent = exports.isIntegerComponent = exports.isStringComponent = exports.isRefComponent = exports.isArrayComponent = exports.isObjectComponent = exports.isComponent = void 0; | ||
function isRefComponent(x) { | ||
// @ts-expect-error | ||
// @ts-expect-error ignore error | ||
return !!x.$ref; | ||
@@ -38,2 +39,3 @@ } | ||
exports.isBooleanComponent = isBooleanComponent; | ||
/* eslint-enable import/no-unused-modules */ | ||
//# sourceMappingURL=swagger.js.map |
@@ -13,3 +13,3 @@ { | ||
], | ||
"gitHead": "5862d5ff45549b697c872b9e5bdc58f04d6dbfd8", | ||
"gitHead": "f5411f2e7ed46b355aa778d5ef7fd1688b87bc50", | ||
"license": "Apache-2.0", | ||
@@ -28,3 +28,3 @@ "main": "./dist/index.js", | ||
}, | ||
"version": "0.1.18" | ||
"version": "0.1.19" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27072
454