-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes and enhancements for array query param handling #241
Fixes and enhancements for array query param handling #241
Conversation
✅ Deploy Preview for docusaurus-openapi ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
packages/docusaurus-theme-openapi/src/theme/ApiDemoPanel/ParamOptions/index.tsx
Outdated
Show resolved
Hide resolved
packages/docusaurus-theme-openapi/src/theme/ApiDemoPanel/ParamOptions/index.tsx
Outdated
Show resolved
Hide resolved
I've circled back to this and pushed another commit which takes a different approach to fixing the infinite render loop. This gets rid of the loop without introducing any ESLint errors. Would it be possible to get a review on this? |
packages/docusaurus-theme-openapi/src/theme/ApiDemoPanel/ParamOptions/index.tsx
Outdated
Show resolved
Hide resolved
packages/docusaurus-theme-openapi/src/theme/ApiDemoPanel/ParamOptions/index.tsx
Show resolved
Hide resolved
{((param?.schema?.maxItems == null || | ||
items.length < param.schema.maxItems) && ( | ||
<button className={styles.buttonThin} onClick={handleAddItem}> | ||
Add item | ||
</button> | ||
)) || ( | ||
<button className={styles.buttonThin} disabled> | ||
Add item | ||
</button> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit hard to follow. Can we do something like:
<button
className={styles.buttonThin}
onClick={handleAddItem}
disabled={param?.schema?.maxItems != null && param.schema.maxItems <= items.length}
>
Add item
</button>
This PR is a bit of a mixed bag of related things.
There is an infinite render loop on pages that use query params, causing a
Maximum Update Depth Exceeded
error.Respect the
maxItems
property for array query params.OpenAPI supports number of different styles for array query params via the
style
andexplode
properties. This PR adds compatibility for those.