Skip to content
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

Merged
merged 8 commits into from
Mar 14, 2023

Conversation

chris48s
Copy link
Contributor

This PR is a bit of a mixed bag of related things.

  1. There is an infinite render loop on pages that use query params, causing a Maximum Update Depth Exceeded error.

  2. Respect the maxItems property for array query params.

  3. OpenAPI supports number of different styles for array query params via the style and explode properties. This PR adds compatibility for those.

@netlify
Copy link

netlify bot commented Feb 20, 2023

Deploy Preview for docusaurus-openapi ready!

Name Link
🔨 Latest commit 0298434
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-openapi/deploys/6410d2e7d6b0dd000884c529
😎 Deploy Preview https://deploy-preview-241--docusaurus-openapi.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@chris48s
Copy link
Contributor Author

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?

Comment on lines 246 to 255
{((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>
)}
Copy link
Member

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>

@bourdakos1 bourdakos1 merged commit 54f2b56 into cloud-annotations:main Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants