openapi-typescript
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -13,2 +13,3 @@ /// <reference types="node" /> | ||
schemas: SchemaMap; | ||
urlCache?: Set<string>; | ||
httpHeaders?: Headers; | ||
@@ -15,0 +16,0 @@ httpMethod?: string; |
@@ -72,4 +72,4 @@ "use strict"; | ||
} | ||
let urlCache = new Set(); | ||
async function load(schema, options) { | ||
const urlCache = options.urlCache || new Set(); | ||
const isJSON = schema instanceof url_1.URL === false; | ||
@@ -143,3 +143,3 @@ let schemaID = isJSON ? new url_1.URL(exports.VIRTUAL_JSON_URL).href : schema.href; | ||
const nextURL = isRemoteURL ? new url_1.URL(refURL) : new url_1.URL((0, slash_1.default)(refURL), schema); | ||
refPromises.push(load(nextURL, options).then((subschemas) => { | ||
refPromises.push(load(nextURL, { ...options, urlCache }).then((subschemas) => { | ||
for (const subschemaURL of Object.keys(subschemas)) { | ||
@@ -146,0 +146,0 @@ schemas[subschemaURL] = subschemas[subschemaURL]; |
@@ -13,2 +13,3 @@ /// <reference types="node" /> | ||
schemas: SchemaMap; | ||
urlCache?: Set<string>; | ||
httpHeaders?: Headers; | ||
@@ -15,0 +16,0 @@ httpMethod?: string; |
@@ -65,4 +65,4 @@ import fetch from "node-fetch"; | ||
} | ||
let urlCache = new Set(); | ||
export default async function load(schema, options) { | ||
const urlCache = options.urlCache || new Set(); | ||
const isJSON = schema instanceof URL === false; | ||
@@ -136,3 +136,3 @@ let schemaID = isJSON ? new URL(VIRTUAL_JSON_URL).href : schema.href; | ||
const nextURL = isRemoteURL ? new URL(refURL) : new URL(slash(refURL), schema); | ||
refPromises.push(load(nextURL, options).then((subschemas) => { | ||
refPromises.push(load(nextURL, { ...options, urlCache }).then((subschemas) => { | ||
for (const subschemaURL of Object.keys(subschemas)) { | ||
@@ -139,0 +139,0 @@ schemas[subschemaURL] = subschemas[subschemaURL]; |
{ | ||
"name": "openapi-typescript", | ||
"description": "Generate TypeScript types from Swagger OpenAPI specs", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">= 12.0.0", |
@@ -6,3 +6,3 @@ [![version(scoped)](https://img.shields.io/npm/v/openapi-typescript.svg)](https://www.npmjs.com/package/openapi-typescript) | ||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-39-orange.svg?style=flat-square)](#contributors-) | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-40-orange.svg?style=flat-square)](#contributors-) | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
@@ -251,2 +251,3 @@ | ||
<td align="center"><a href="http://www.zornwebdev.com"><img src="https://avatars.githubusercontent.com/u/22532542?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eric Zorn</b></sub></a><br /><a href="https://github.com/drwpow/openapi-typescript/commits?author=ericzorn93" title="Code">💻</a> <a href="https://github.com/drwpow/openapi-typescript/commits?author=ericzorn93" title="Tests">⚠️</a> <a href="https://github.com/drwpow/openapi-typescript/commits?author=ericzorn93" title="Documentation">📖</a></td> | ||
<td align="center"><a href="https://www.mbelsky.com/"><img src="https://avatars.githubusercontent.com/u/3923527?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Max Belsky</b></sub></a><br /><a href="https://github.com/drwpow/openapi-typescript/commits?author=mbelsky" title="Code">💻</a> <a href="https://github.com/drwpow/openapi-typescript/issues?q=author%3Ambelsky" title="Bug reports">🐛</a></td> | ||
</tr> | ||
@@ -253,0 +254,0 @@ </table> |
@@ -91,2 +91,3 @@ import fetch from "node-fetch"; | ||
schemas: SchemaMap; | ||
urlCache?: Set<string>; // URL cache (prevent URLs from being loaded over and over) | ||
httpHeaders?: Headers; | ||
@@ -96,5 +97,2 @@ httpMethod?: string; | ||
// temporary cache for load() | ||
let urlCache = new Set<string>(); // URL cache (prevent URLs from being loaded over and over) | ||
/** Load a schema from local path or remote URL */ | ||
@@ -105,2 +103,4 @@ export default async function load( | ||
): Promise<{ [url: string]: PartialSchema }> { | ||
const urlCache = options.urlCache || new Set<string>(); | ||
const isJSON = schema instanceof URL === false; // if this is dynamically-passed-in JSON, we’ll have to change a few things | ||
@@ -188,3 +188,3 @@ let schemaID = isJSON ? new URL(VIRTUAL_JSON_URL).href : (schema.href as string); | ||
refPromises.push( | ||
load(nextURL, options).then((subschemas) => { | ||
load(nextURL, { ...options, urlCache }).then((subschemas) => { | ||
for (const subschemaURL of Object.keys(subschemas)) { | ||
@@ -191,0 +191,0 @@ schemas[subschemaURL] = subschemas[subschemaURL]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
244440
3629
261