Fix circularRef in schema + examples OpenAPI (#2872)

This commit is contained in:
Nolann B.
2025-02-24 21:26:26 +01:00
committed by GitHub
parent a0545545d7
commit b4a12d606e
3 changed files with 31 additions and 16 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@gitbook/react-openapi': patch
---
Fix circularRef in schema + examples OpenAPI
@@ -59,6 +59,9 @@ export function OpenAPISchemaProperty(
context={context} context={context}
/> />
))} ))}
{parentCircularRef ? (
<OpenAPISchemaCircularRef id={parentCircularRef} schema={schema} />
) : null}
</InteractiveSection> </InteractiveSection>
); );
} }
@@ -76,6 +79,9 @@ export function OpenAPISchemaProperty(
/> />
</OpenAPIDisclosure> </OpenAPIDisclosure>
) : null} ) : null}
{parentCircularRef ? (
<OpenAPISchemaCircularRef id={parentCircularRef} schema={schema} />
) : null}
</InteractiveSection> </InteractiveSection>
); );
} }
@@ -16,23 +16,27 @@ export function generateSchemaExample(
schema: OpenAPIV3.SchemaObject, schema: OpenAPIV3.SchemaObject,
options?: GenerateSchemaExampleOptions, options?: GenerateSchemaExampleOptions,
): JSONValue | undefined { ): JSONValue | undefined {
return getExampleFromSchema(schema, { return getExampleFromSchema(
emptyString: 'text', schema,
variables: { {
'date-time': new Date().toISOString(), emptyString: 'text',
date: new Date().toISOString().split('T')[0], variables: {
email: 'name@gmail.com', 'date-time': new Date().toISOString(),
hostname: 'example.com', date: new Date().toISOString().split('T')[0],
ipv4: '0.0.0.0', email: 'name@gmail.com',
ipv6: '2001:0db8:85a3:0000:0000:8a2e:0370:7334', hostname: 'example.com',
uri: 'https://example.com', ipv4: '0.0.0.0',
uuid: '123e4567-e89b-12d3-a456-426614174000', ipv6: '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
binary: 'binary', uri: 'https://example.com',
byte: 'Ynl0ZXM=', uuid: '123e4567-e89b-12d3-a456-426614174000',
password: 'password', binary: 'binary',
byte: 'Ynl0ZXM=',
password: 'password',
},
...options,
}, },
...options, 3, // Max depth for circular references
}); );
} }
/** /**