Skip to content

Commit fd33377

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature_refs_in_paths
2 parents 01f4163 + 157f5a5 commit fd33377

5 files changed

Lines changed: 43 additions & 26 deletions

File tree

bun.lock

Lines changed: 9 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@
6060
"type-fest": "^5.4.4",
6161
"typescript": "~5.9.3",
6262
"yaml": "^2.8.2",
63-
"yummies": "7.9.0"
63+
"yummies": "7.10.0"
6464
},
6565
"devDependencies": {
6666
"@biomejs/biome": "2.4.5",
6767
"@changesets/changelog-github": "0.5.2",
68-
"@changesets/cli": "2.29.8",
68+
"@changesets/cli": "2.30.0",
6969
"@tsconfig/node20": "20.1.9",
7070
"@tsconfig/strictest": "2.0.8",
7171
"@types/node": "25.3.3",

src/resolved-swagger-schema.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import * as fs from "node:fs";
2+
import path from "node:path";
13
import type { resolve } from "@apidevtools/swagger-parser";
24
import SwaggerParser from "@apidevtools/swagger-parser";
35
import consola from "consola";
4-
import * as fs from "node:fs";
5-
import path from "node:path";
66
import type { OpenAPI } from "openapi-types";
77
import * as YAML from "yaml";
88
import type { AnyObject, Maybe, Primitive } from "yummies/types";
@@ -86,8 +86,9 @@ export class ResolvedSwaggerSchema {
8686
Authorization: this.config.authorizationToken,
8787
}
8888
: {},
89-
(this.config.requestOptions?.headers as Record<string, string> | undefined) ||
90-
{},
89+
(this.config.requestOptions?.headers as
90+
| Record<string, string>
91+
| undefined) || {},
9192
);
9293
}
9394

@@ -124,7 +125,9 @@ export class ResolvedSwaggerSchema {
124125
return [...refs];
125126
}
126127

127-
private async fetchRemoteSchemaDocument(url: string): Promise<Maybe<AnyObject>> {
128+
private async fetchRemoteSchemaDocument(
129+
url: string,
130+
): Promise<Maybe<AnyObject>> {
128131
try {
129132
const response = await fetch(url, {
130133
headers: this.getRemoteRequestHeaders(),
@@ -155,7 +158,10 @@ export class ResolvedSwaggerSchema {
155158
}
156159

157160
private async warmUpRemoteSchemasCache() {
158-
if (typeof this.config.url !== "string" || !this.isHttpUrl(this.config.url)) {
161+
if (
162+
typeof this.config.url !== "string" ||
163+
!this.isHttpUrl(this.config.url)
164+
) {
159165
return;
160166
}
161167

@@ -212,7 +218,8 @@ export class ResolvedSwaggerSchema {
212218
return [];
213219
}
214220

215-
const [relativePath = "", rawPointer = ""] = this.normalizeRef(ref).split("#");
221+
const [relativePath = "", rawPointer = ""] =
222+
this.normalizeRef(ref).split("#");
216223
if (!relativePath) {
217224
return [];
218225
}
@@ -225,7 +232,10 @@ export class ResolvedSwaggerSchema {
225232

226233
const bases = new Set<string>();
227234

228-
if (typeof this.config.url === "string" && this.isHttpUrl(this.config.url)) {
235+
if (
236+
typeof this.config.url === "string" &&
237+
this.isHttpUrl(this.config.url)
238+
) {
229239
bases.add(this.config.url);
230240
}
231241

@@ -240,7 +250,10 @@ export class ResolvedSwaggerSchema {
240250
const resolverPaths =
241251
typeof resolver.paths === "function" ? resolver.paths() : [];
242252
for (const resolverPath of resolverPaths) {
243-
if (typeof resolverPath === "string" && this.isHttpUrl(resolverPath)) {
253+
if (
254+
typeof resolverPath === "string" &&
255+
this.isHttpUrl(resolverPath)
256+
) {
244257
bases.add(resolverPath);
245258
}
246259
}
@@ -398,15 +411,17 @@ export class ResolvedSwaggerSchema {
398411
}
399412
}
400413

401-
const remoteAbsoluteCandidates = this.collectRemoteAbsoluteRefCandidates(ref);
414+
const remoteAbsoluteCandidates =
415+
this.collectRemoteAbsoluteRefCandidates(ref);
402416
for (const remoteAbsoluteRef of remoteAbsoluteCandidates) {
403417
const resolvedFromRemoteCache =
404418
this.resolveFromRemoteSchemaCache(remoteAbsoluteRef);
405419
if (resolvedFromRemoteCache) {
406420
return resolvedFromRemoteCache;
407421
}
408422

409-
const resolvedByRemoteAbsoluteRef = this.tryToResolveRef(remoteAbsoluteRef);
423+
const resolvedByRemoteAbsoluteRef =
424+
this.tryToResolveRef(remoteAbsoluteRef);
410425
if (resolvedByRemoteAbsoluteRef) {
411426
return this.normalizeResolvedExternalSchemaRef(
412427
remoteAbsoluteRef,

tests/spec/paths-by-url/basic.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ describe("paths-by-url", async () => {
1313
let server: ReturnType<typeof createServer> | null = null;
1414

1515
beforeAll(async () => {
16-
tmpRoot = await fs.mkdtemp(path.join(os.tmpdir(), "swagger-typescript-api"));
16+
tmpRoot = await fs.mkdtemp(
17+
path.join(os.tmpdir(), "swagger-typescript-api"),
18+
);
1719
fixturesRoot = path.join(tmpRoot, "fixtures");
1820
outputRoot = path.join(tmpRoot, "output");
1921

tests/swagger-schema-resolver.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ describe("SwaggerSchemaResolver URL loading", () => {
120120
const host = req.headers.host || "127.0.0.1";
121121
const requestUrl = new URL(req.url || "/", `http://${host}`);
122122
const requestedPath = decodeURIComponent(requestUrl.pathname);
123-
const filePath = path.resolve(path.join(fixturesRoot, `.${requestedPath}`));
123+
const filePath = path.resolve(
124+
path.join(fixturesRoot, `.${requestedPath}`),
125+
);
124126
const file = await fs.readFile(filePath, { encoding: "utf8" });
125127
res.statusCode = 200;
126128
res.end(file);

0 commit comments

Comments
 (0)