PaloAltoNetworks / PaloAltoNetworks/docusaurus-openapi-docs
generate mdx of circular $ref failed
Open
Nobody has claimed this yet.
bug
question
reviewing :eyes:
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 315
- Avg merge
- 7d 5h
- Merged PRs (30d)
- 7
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running yarn docusaurus gen-api-docs all against the linked Gravitino OAS and capture the full error. Inspect the generation path that processes circular $ref and compare it with the reported workaround. Done means the command completes and generates MDX successfully for circular references without breaking non-circular schemas.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- documentation, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100