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

Add a test for combinators and pass resolved subschema to createLabel #2165

Merged

Conversation

DrewHoo
Copy link
Contributor

@DrewHoo DrewHoo commented Jul 18, 2023

Resolves #2164

  • Passes resolved subschema to createLabel so that label can actually use the title of the subschema
  • Adds a test for combinators that fails if the resolved schema isn't passed

@netlify
Copy link

netlify bot commented Jul 18, 2023

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 155c88b
🔍 Latest deploy log https://app.netlify.com/sites/jsonforms-examples/deploys/64d2c37e35412600080aff97
😎 Deploy Preview https://deploy-preview-2165--jsonforms-examples.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 configuration.

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2023

CLA assistant check
All committers have signed the CLA.

@DrewHoo
Copy link
Contributor Author

DrewHoo commented Jul 26, 2023

Hi @sdirix do I need to do anything additional to get this PR reviewed?

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Hi @DrewHoo,

Thanks for the contribution!

While this fixes the use case of the test case, another use case is now broken:

{
  type: 'object',
  properties: {
    widget: {
      anyOf: [
        {
          title: 'DuaOverride',
          $ref: '#/definitions/Dua',
        },
        {
          title: 'LipaOverride',
          $ref: '#/definitions/Lipa',
        },
      ],
    },
  },
  definitions: {
    Dua: {
      title: 'Dua',
      type: 'object',
      properties: { name: { type: 'string' } },
    },
    Lipa: {
      title: 'Lipa',
      type: 'object',
      properties: { name: { type: 'string' } },
    },
  },
};

DuaOverride and LipaOverride are no longer considered.

We should check both title and use the outer one in case both exist.

@coveralls
Copy link

coveralls commented Jul 26, 2023

Coverage Status

coverage: 84.469% (+0.2%) from 84.254% when pulling 155c88b on DrewHoo:2164-fix-renderinfo-labels-for-anyOf-refs into d6f1fda on eclipsesource:master.

@DrewHoo
Copy link
Contributor Author

DrewHoo commented Jul 27, 2023

@sdirix Thanks for the suggestion! I added the test case you described and merged the two schemas before passing them to createLabel, giving the outer properties preference -- not sure if merged schema would also be appropriate for other places the sub-schema is used within the combinators function, so I only modified what's passed to createLabel.

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

looks good! one more small suggestion ;)

packages/core/src/util/combinators.ts Outdated Show resolved Hide resolved
@sdirix sdirix merged commit 22d14d3 into eclipsesource:master Aug 8, 2023
7 checks passed
@sdirix
Copy link
Member

sdirix commented Aug 8, 2023

@DrewHoo Thanks a lot for the contribution ❤️

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.

AnyOf subschemas defined in refs don't get correct labels from createCombinatorRenderInfos
4 participants