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

fix: render empty extensions and bindings #502

Merged

Conversation

magicmatatjahu
Copy link
Member

Description

Changes proposed in this pull request:

Render empty extensions and bindings:

  • improve jsonFieldToSchema function to handle null and undefined values.
  • add unit tests for helper and also for Bindings and Extensions component

Related issue(s)
Resolves asyncapi/studio#221

@magicmatatjahu magicmatatjahu added the bug Something isn't working label Jan 3, 2022
Copy link

@paulRbr paulRbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok with this solution, but wdyt about “failing early” in the .map entries?

Something like:

const renderedBindings = Object.entries(bindings).map(
  ([bindingName, binding]) => {
    if (!binding) {
      return null;
    }
    ...

@magicmatatjahu
Copy link
Member Author

@paulRbr It can be done, but in 99.99% of cases there should be no null/undefined, so I gave this comparison at the end using the schema && ... guard :)

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to start generating studio previews on PRs 😅

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 4, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@magicmatatjahu magicmatatjahu merged commit 5412033 into asyncapi:next Jan 4, 2022
@magicmatatjahu magicmatatjahu deleted the next-branches/fix-nil-schemas branch January 4, 2022 10:14
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 1.0.0-next.27 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released on @next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants