openapi-typescript
Advanced tools
Comparing version 6.2.9 to 6.3.0
@@ -131,3 +131,3 @@ import fs from "node:fs"; | ||
hint: "OpenAPI3", | ||
schema: schema, | ||
schema: JSON.parse(JSON.stringify(schema)), | ||
}; | ||
@@ -134,0 +134,0 @@ } |
@@ -66,15 +66,13 @@ import { escObjKey, escStr, getEntries, getSchemaObjectComment, indent, parseRef, tsArrayOf, tsIntersectionOf, tsOmit, tsOneOf, tsOptionalProperty, tsReadonly, tsTupleOf, tsUnionOf, tsWithRequired } from "../utils.js"; | ||
let isTupleType = false; | ||
if (schemaObject.items) { | ||
if (Array.isArray(schemaObject.items)) { | ||
isTupleType = true; | ||
const result = []; | ||
schemaObject.items.forEach((item) => { | ||
result.push(transformSchemaObject(item, { path, ctx: { ...ctx, indentLv } })); | ||
}); | ||
itemType = `[${result.join(",")}]`; | ||
if (schemaObject.prefixItems || Array.isArray(schemaObject.items)) { | ||
isTupleType = true; | ||
const result = []; | ||
for (const item of schemaObject.prefixItems ?? schemaObject.items) { | ||
result.push(transformSchemaObject(item, { path, ctx: { ...ctx, indentLv } })); | ||
} | ||
else { | ||
itemType = transformSchemaObject(schemaObject.items, { path, ctx: { ...ctx, indentLv } }); | ||
} | ||
itemType = `[${result.join(", ")}]`; | ||
} | ||
else if (schemaObject.items) { | ||
itemType = transformSchemaObject(schemaObject.items, { path, ctx: { ...ctx, indentLv } }); | ||
} | ||
const minItems = typeof schemaObject.minItems === "number" && schemaObject.minItems >= 0 ? schemaObject.minItems : 0; | ||
@@ -81,0 +79,0 @@ const maxItems = typeof schemaObject.maxItems === "number" && schemaObject.maxItems >= 0 && minItems <= schemaObject.maxItems ? schemaObject.maxItems : undefined; |
@@ -134,3 +134,3 @@ /// <reference types="node" resolution-mode="require"/> | ||
encoding?: { | ||
[contentType: string]: EncodingObject; | ||
[propertyName: string]: EncodingObject; | ||
}; | ||
@@ -225,3 +225,3 @@ } | ||
type: "array"; | ||
prefixItems?: SchemaObject | ReferenceObject; | ||
prefixItems?: (SchemaObject | ReferenceObject)[]; | ||
items?: SchemaObject | ReferenceObject | (SchemaObject | ReferenceObject)[]; | ||
@@ -228,0 +228,0 @@ minItems?: number; |
{ | ||
"name": "openapi-typescript", | ||
"description": "Generate TypeScript types from Swagger OpenAPI specs", | ||
"version": "6.2.9", | ||
"version": "6.3.0", | ||
"author": { | ||
@@ -42,5 +42,5 @@ "name": "Drew Powers", | ||
"ansi-colors": "^4.1.3", | ||
"fast-glob": "^3.2.12", | ||
"fast-glob": "^3.3.0", | ||
"js-yaml": "^4.1.0", | ||
"supports-color": "^9.3.1", | ||
"supports-color": "^9.4.0", | ||
"undici": "^5.22.1", | ||
@@ -52,9 +52,9 @@ "yargs-parser": "^21.1.1" | ||
"@types/js-yaml": "^4.0.5", | ||
"@types/node": "^20.3.1", | ||
"@types/node": "^20.4.0", | ||
"degit": "^2.8.4", | ||
"del-cli": "^5.0.0", | ||
"execa": "^6.1.0", | ||
"vite": "^4.3.9", | ||
"vite-node": "^0.32.0", | ||
"vitest": "^0.32.0" | ||
"vite": "^4.4.1", | ||
"vite-node": "^0.33.0", | ||
"vitest": "^0.33.0" | ||
}, | ||
@@ -61,0 +61,0 @@ "scripts": { |
@@ -176,3 +176,3 @@ import type { ComponentsObject, Fetch, GlobalContext, OpenAPI3, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RequestBodyObject, ResponseObject, SchemaObject, Subschema } from "./types.js"; | ||
hint: "OpenAPI3", | ||
schema: schema as any, | ||
schema: JSON.parse(JSON.stringify(schema)), // create deep clone of inline schema (don’t mutate) | ||
}; | ||
@@ -179,0 +179,0 @@ } |
@@ -94,14 +94,12 @@ import type { GlobalContext, ReferenceObject, SchemaObject } from "../types.js"; | ||
let isTupleType = false; | ||
if (schemaObject.items) { | ||
if (Array.isArray(schemaObject.items)) { | ||
// tuple type support | ||
isTupleType = true; | ||
const result: string[] = []; | ||
schemaObject.items.forEach((item) => { | ||
result.push(transformSchemaObject(item, { path, ctx: { ...ctx, indentLv } })); | ||
}); | ||
itemType = `[${result.join(",")}]`; | ||
} else { | ||
itemType = transformSchemaObject(schemaObject.items, { path, ctx: { ...ctx, indentLv } }); | ||
if (schemaObject.prefixItems || Array.isArray(schemaObject.items)) { | ||
// tuple type support | ||
isTupleType = true; | ||
const result: string[] = []; | ||
for (const item of schemaObject.prefixItems ?? (schemaObject.items as (SchemaObject | ReferenceObject)[])) { | ||
result.push(transformSchemaObject(item, { path, ctx: { ...ctx, indentLv } })); | ||
} | ||
itemType = `[${result.join(", ")}]`; | ||
} else if (schemaObject.items) { | ||
itemType = transformSchemaObject(schemaObject.items, { path, ctx: { ...ctx, indentLv } }); | ||
} | ||
@@ -108,0 +106,0 @@ const minItems: number = typeof schemaObject.minItems === "number" && schemaObject.minItems >= 0 ? schemaObject.minItems : 0; |
@@ -285,3 +285,3 @@ import type { URL } from "node:url"; | ||
/** A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to requestBody objects when the media type is multipart or application/x-www-form-urlencoded. */ | ||
encoding?: { [contentType: string]: EncodingObject }; | ||
encoding?: { [propertyName: string]: EncodingObject }; | ||
} | ||
@@ -442,3 +442,3 @@ | ||
type: "array"; | ||
prefixItems?: SchemaObject | ReferenceObject; | ||
prefixItems?: (SchemaObject | ReferenceObject)[]; | ||
items?: SchemaObject | ReferenceObject | (SchemaObject | ReferenceObject)[]; | ||
@@ -445,0 +445,0 @@ minItems?: number; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
295881
4732
Updatedfast-glob@^3.3.0
Updatedsupports-color@^9.4.0