+
diff --git a/src/lib/document.ts b/src/lib/document.ts
index 8b2613acb..05c36da1d 100644
--- a/src/lib/document.ts
+++ b/src/lib/document.ts
@@ -21,20 +21,17 @@ export interface DocumentSection {
/**
* Check if the document contains one block that should be rendered in full-width mode.
*/
-export function hasFullWidthBlock(document: JSONDocument): { apiBlock: boolean } | false {
- let fullWidth = false;
-
+export function hasFullWidthBlock(document: JSONDocument): boolean {
for (const node of document.nodes) {
if (node.data && 'fullWidth' in node.data && node.data.fullWidth) {
- fullWidth = true;
+ return true;
}
-
if (node.type === 'swagger') {
- return { apiBlock: true };
+ return true;
}
}
- return fullWidth ? { apiBlock: false } : false;
+ return false;
}
/**
diff --git a/src/lib/openapi.ts b/src/lib/openapi.ts
index 365654b72..9c7cbf27a 100644
--- a/src/lib/openapi.ts
+++ b/src/lib/openapi.ts
@@ -67,14 +67,23 @@ const fetcher: OpenAPIFetcher = {
// @ts-ignore
if (data && data.swagger) {
- // Convert Swagger 2.0 to OpenAPI 3.0
- // @ts-ignore
- const result = (await swagger2openapi.convertObj(data, {
- resolve: false,
- resolveInternal: false,
- })) as ConvertOutputOptions;
+ try {
+ // Convert Swagger 2.0 to OpenAPI 3.0
+ // @ts-ignore
+ const result = (await swagger2openapi.convertObj(data, {
+ resolve: false,
+ resolveInternal: false,
+ laxDefaults: true,
+ laxurls: true,
+ lint: false,
+ prevalidate: false,
+ })) as ConvertOutputOptions;
- data = result.openapi;
+ data = result.openapi;
+ } catch (error) {
+ console.warn('Failed to convert Swagger 2.0 to OpenAPI 3.0', error);
+ data = null;
+ }
}
return {
diff --git a/tailwind.config.ts b/tailwind.config.ts
index 2b6d23e58..3dce27cde 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -208,7 +208,7 @@ const config: Config = {
/**
* Variant when the page contains an OpenAPI block.
*/
- addVariant('page-api-block', 'body:has(.page-api-block) &');
+ addVariant('page-api-block', 'body:has(.openapi-block) &');
/**
* Variant when the page is displayed in print mode.