@openapi-codegen/typescript
Advanced tools
Comparing version 9.0.0 to 9.0.1
@@ -63,5 +63,5 @@ "use strict"; | ||
adHocSchemas.push({ | ||
type: 'object', | ||
type: "object", | ||
properties: schema.properties, | ||
required: schema.required | ||
required: schema.required, | ||
}); | ||
@@ -71,10 +71,7 @@ } | ||
adHocSchemas.push({ | ||
type: 'object', | ||
additionalProperties: schema.additionalProperties | ||
type: "object", | ||
additionalProperties: schema.additionalProperties, | ||
}); | ||
} | ||
return getAllOf([ | ||
...schema.allOf, | ||
...adHocSchemas | ||
], context); | ||
return getAllOf([...schema.allOf, ...adHocSchemas], context); | ||
} | ||
@@ -135,3 +132,5 @@ if (schema.enum) { | ||
const members = Object.entries(schema.properties || {}).map(([key, property]) => { | ||
const isEnum = typeof property === "object" && "enum" in property && useEnumsConfigBase; | ||
const isEnum = typeof property === "object" && | ||
"enum" in property && | ||
useEnumsConfigBase; | ||
const propertyNode = typescript_1.factory.createPropertySignature(undefined, (0, tsutils_1.isValidIdentifier)(key) | ||
@@ -392,3 +391,3 @@ ? typescript_1.factory.createIdentifier(key) | ||
} | ||
// Value is not stringifiable | ||
// Value is not stringifyable | ||
// See https://github.com/fabien0102/openapi-codegen/issues/36, https://github.com/fabien0102/openapi-codegen/issues/57 | ||
@@ -409,7 +408,5 @@ return typescript_1.factory.createIdentifier("[see original specs]"); | ||
}); | ||
if (schemaWithAllOfResolved.description || propertyTags.length > 0) { | ||
return typescript_1.factory.createJSDocComment(schemaWithAllOfResolved.description | ||
? schemaWithAllOfResolved.description.trim() + | ||
(propertyTags.length ? "\n" : "") | ||
: undefined, propertyTags); | ||
const description = sanitizeDescription(schemaWithAllOfResolved.description); | ||
if (description || propertyTags.length > 0) { | ||
return typescript_1.factory.createJSDocComment(description ? description + (propertyTags.length ? "\n" : "") : undefined, propertyTags); | ||
} | ||
@@ -420,2 +417,21 @@ return undefined; | ||
/** | ||
* Remove any unwanted chars from the description to avoid | ||
* unparsable multiline comment. | ||
* | ||
* @param description | ||
*/ | ||
const sanitizeDescription = (description) => { | ||
if (!description || description.trim().length === 0) | ||
return undefined; | ||
if (!description.includes("*/")) { | ||
return description.trim(); | ||
} | ||
// Try to return first line, since it’s more likely than the `*/` is the body | ||
const [title] = description.trim().split("\n"); | ||
if (title && !title.includes("*/")) { | ||
return `${title}\n\n[see original specs]`; | ||
} | ||
return "[see original specs]"; | ||
}; | ||
/** | ||
* Add js comment to a node (mutate the original node). | ||
@@ -422,0 +438,0 @@ * |
{ | ||
"name": "@openapi-codegen/typescript", | ||
"version": "9.0.0", | ||
"version": "9.0.1", | ||
"description": "OpenAPI Codegen typescript generators", | ||
@@ -44,3 +44,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "c270a54735701fea074189d041c9cfcabb3eefe4" | ||
"gitHead": "4359bdd0c303f552531297430213a7784dea491d" | ||
} |
Sorry, the diff of this file is not supported yet
239937
2953