mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
Handle Errors from Unresolved Refs (#2810)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@gitbook/react-openapi': patch
|
||||
---
|
||||
|
||||
Fix error on unresolvable refs by replacing with property name and any type
|
||||
@@ -5,7 +5,7 @@ import React, { useId } from 'react';
|
||||
import { InteractiveSection } from './InteractiveSection';
|
||||
import { Markdown } from './Markdown';
|
||||
import { OpenAPIClientContext } from './types';
|
||||
import { noReference } from './utils';
|
||||
import { checkIsReference, noReference } from './utils';
|
||||
import { stringifyOpenAPI } from './stringifyOpenAPI';
|
||||
|
||||
type CircularRefsIds = Map<OpenAPIV3.SchemaObject, string>;
|
||||
@@ -278,7 +278,10 @@ function getSchemaProperties(schema: OpenAPIV3.SchemaObject): null | OpenAPISche
|
||||
|
||||
if (schema.properties) {
|
||||
Object.entries(schema.properties).forEach(([propertyName, rawPropertySchema]) => {
|
||||
const propertySchema = noReference(rawPropertySchema);
|
||||
const isReference = checkIsReference(rawPropertySchema);
|
||||
const propertySchema: OpenAPIV3.SchemaObject = isReference
|
||||
? { propertyName }
|
||||
: rawPropertySchema;
|
||||
if (propertySchema.deprecated) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export function noReference<T>(input: T | OpenAPIV3.ReferenceObject): T {
|
||||
return input;
|
||||
}
|
||||
|
||||
function checkIsReference(input: unknown): input is OpenAPIV3.ReferenceObject {
|
||||
export function checkIsReference(input: unknown): input is OpenAPIV3.ReferenceObject {
|
||||
return typeof input === 'object' && !!input && '$ref' in input;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user