docusaurus-openapi-docs
docusaurus-openapi-docs copied to clipboard
generate mdx of circular $ref failed
Describe the bug
OAS including circular $ref, use yarn docusaurus gen-api-docs all encounter error
Expected behavior
successfully
Current behavior
fail
Possible solution
I tried my best to work around by modifying the lib file:
function replaceOneOfWithValue(obj, parent, keyInParent) {
if (obj && typeof obj === 'object') {
// If the current property is an object, recursively traverse its properties
Object.keys(obj).forEach(key => {
if (key === 'oneOf' && !Array.isArray(obj[key])) {
// If the 'oneOf' property is found and its value is not an array
// Then replace the corresponding property value of the parent object with the string 'circular(DataType)'
parent[keyInParent] = 'circular(DataType)';
} else {
// Recursively traverse the current property
replaceOneOfWithValue(obj[key], obj, key);
}
});
} else if (Array.isArray(obj)) {
// If the current property is an array, recursively traverse each element of the array
obj.forEach((item, index) => {
replaceOneOfWithValue(item, obj, index);
});
}
}
Steps to reproduce
use the OAS of the project Gravitino
Screenshots
Context
Your Environment
- Version used:
- docusaurus 3.1.0, "docusaurus-plugin-openapi-docs": "v3.0.0-beta.4"
- Operating System and version (desktop or mobile): macOS 13.6.1
- Link to your project: https://github.com/datastrato/gravitino/tree/main/docs/open-api
Hi @mchades, thanks for reporting this issue. If your proposed changes address the issue would you mind opening a PR so we can work toward merging it into the code base?
Hi @mchades, thanks for reporting this issue. If your proposed changes address the issue would you mind opening a PR so we can work toward merging it into the code base?
Hi @sserrata , Thank you for your response, and sorry for the late reply.
I only proposed a hard-coded work around, I am not good at TS and JS, and I do not know how to fix this problem from the source. My description just provides a way to reproduce it.