openapi-typescript
Advanced tools
Comparing version 6.4.5 to 6.5.0
# openapi-typescript | ||
## 6.5.0 | ||
### Minor Changes | ||
- [#1295](https://github.com/drwpow/openapi-typescript/pull/1295) [`99a1648`](https://github.com/drwpow/openapi-typescript/commit/99a1648affd5731c2d303619f050fee2ed834eef) Thanks [@pvanagtmaal](https://github.com/pvanagtmaal)! - Avoid adding a undefined union to additionProperties | ||
## 6.4.5 | ||
@@ -4,0 +10,0 @@ |
@@ -144,3 +144,9 @@ import { escObjKey, escStr, getEntries, getSchemaObjectComment, indent, parseRef, tsArrayOf, tsIntersectionOf, tsOmit, tsOneOf, tsOptionalProperty, tsReadonly, tsTupleOf, tsUnionOf, tsWithRequired } from "../utils.js"; | ||
} | ||
coreType.push(indent(`[key: string]: ${tsUnionOf(addlType ? addlType : "unknown", "undefined")};`, indentLv)); | ||
const numProperties = schemaObject.properties ? Object.keys(schemaObject.properties).length : 0; | ||
if (schemaObject.properties && ((!schemaObject.required && numProperties) || (schemaObject.required && numProperties !== schemaObject.required.length))) { | ||
coreType.push(indent(`[key: string]: ${tsUnionOf(addlType ? addlType : "unknown", "undefined")};`, indentLv)); | ||
} | ||
else { | ||
coreType.push(indent(`[key: string]: ${addlType ? addlType : "unknown"};`, indentLv)); | ||
} | ||
} | ||
@@ -147,0 +153,0 @@ indentLv--; |
{ | ||
"name": "openapi-typescript", | ||
"description": "Generate TypeScript types from Swagger OpenAPI specs", | ||
"version": "6.4.5", | ||
"version": "6.5.0", | ||
"author": { | ||
@@ -57,6 +57,6 @@ "name": "Drew Powers", | ||
"esbuild": "^0.19.0", | ||
"execa": "^6.1.0", | ||
"execa": "^7.2.0", | ||
"vite": "^4.4.9", | ||
"vite-node": "^0.33.0", | ||
"vitest": "^0.33.0" | ||
"vite-node": "^0.34.1", | ||
"vitest": "^0.34.1" | ||
}, | ||
@@ -63,0 +63,0 @@ "scripts": { |
@@ -190,3 +190,12 @@ import type { GlobalContext, ReferenceObject, SchemaObject } from "../types.js"; | ||
} | ||
coreType.push(indent(`[key: string]: ${tsUnionOf(addlType ? addlType : "unknown", "undefined")};`, indentLv)); // note: `| undefined` is required to mesh with possibly-undefined keys | ||
// We need to add undefined when there are other optional properties in the schema.properties object | ||
// that is the case when either schemaObject.required is empty and there are defined properties, or | ||
// schemaObject.required is only contains a part of the schemaObject.properties | ||
const numProperties = schemaObject.properties ? Object.keys(schemaObject.properties).length : 0; | ||
if (schemaObject.properties && ((!schemaObject.required && numProperties) || (schemaObject.required && numProperties !== schemaObject.required.length))) { | ||
coreType.push(indent(`[key: string]: ${tsUnionOf(addlType ? addlType : "unknown", "undefined")};`, indentLv)); | ||
} else { | ||
coreType.push(indent(`[key: string]: ${addlType ? addlType : "unknown"};`, indentLv)); | ||
} | ||
} | ||
@@ -193,0 +202,0 @@ indentLv--; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
399696
6750