Skip to content

Commit f1a6dec

Browse files
Less strict OpenAPI parser (#3529)
Co-authored-by: Nolann Biron <[email protected]>
1 parent 44f4151 commit f1a6dec

File tree

13 files changed

+2192
-98
lines changed

13 files changed

+2192
-98
lines changed

.changeset/smooth-apes-smell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Update OpenAPI parser

.changeset/two-apples-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@gitbook/openapi-parser": major
3+
---
4+
5+
Less strict OpenAPI parser, now returns { errors, filesystem }

packages/gitbook/src/lib/openapi/enrich.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const spec = await Bun.file(new URL('./fixtures/multiline-spec.yaml', import.met
77

88
describe('#enrichFilesystem', () => {
99
it('supports multiline descriptions', async () => {
10-
const filesystem = await parseOpenAPI({
10+
const { filesystem } = await parseOpenAPI({
1111
value: spec,
1212
rootURL: null,
1313
});

packages/gitbook/src/lib/openapi/fetch.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,7 @@ async function fetchFilesystemUncached(
108108
}
109109

110110
const text = await response.text();
111-
const filesystem = await parseOpenAPI({
112-
value: text,
113-
rootURL: url,
114-
// If we fetch the OpenAPI specification
115-
// it's the legacy system, it means the spec can be trusted here.
116-
trust: true,
117-
});
111+
const { filesystem } = await parseOpenAPI({ value: text, rootURL: url });
118112
const richFilesystem = await enrichFilesystem(filesystem);
119113

120114
return richFilesystem;

0 commit comments

Comments
 (0)