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}
/>
))}
{parentCircularRef ? (
<OpenAPISchemaCircularRef id={parentCircularRef} schema={schema} />
) : null}
</InteractiveSection>
);
}
@@ -76,6 +79,9 @@ export function OpenAPISchemaProperty(
/>
</OpenAPIDisclosure>
) : null}
{parentCircularRef ? (
<OpenAPISchemaCircularRef id={parentCircularRef} schema={schema} />
) : null}
</InteractiveSection>
);
}
@@ -16,23 +16,27 @@ export function generateSchemaExample(
schema: OpenAPIV3.SchemaObject,
options?: GenerateSchemaExampleOptions,
): JSONValue | undefined {
return getExampleFromSchema(schema, {
emptyString: 'text',
variables: {
'date-time': new Date().toISOString(),
date: new Date().toISOString().split('T')[0],
email: 'name@gmail.com',
hostname: 'example.com',
ipv4: '0.0.0.0',
ipv6: '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
uri: 'https://example.com',
uuid: '123e4567-e89b-12d3-a456-426614174000',
binary: 'binary',
byte: 'Ynl0ZXM=',
password: 'password',
return getExampleFromSchema(
schema,
{
emptyString: 'text',
variables: {
'date-time': new Date().toISOString(),
date: new Date().toISOString().split('T')[0],
email: 'name@gmail.com',
hostname: 'example.com',
ipv4: '0.0.0.0',
ipv6: '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
uri: 'https://example.com',
uuid: '123e4567-e89b-12d3-a456-426614174000',
binary: 'binary',
byte: 'Ynl0ZXM=',
password: 'password',
},
...options,
},
...options,
});
3, // Max depth for circular references
);
}
/**