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

JSONSchema bridge fails on object that is using allOf + #ref #722

Closed
hmvp opened this issue May 12, 2020 · 2 comments · Fixed by #725
Closed

JSONSchema bridge fails on object that is using allOf + #ref #722

hmvp opened this issue May 12, 2020 · 2 comments · Fixed by #725
Assignees
Labels
Type: Bug Bug reports and their fixes

Comments

@hmvp
Copy link

hmvp commented May 12, 2020

When adding the following test in packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts:

    it('returns correct definition (allOf with $ref)', () => {
      expect(bridge.getField('shippingAddress.street')).toEqual({
        type: 'string',
      });
    });

It fails with:

 FAIL  packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts
  ● JSONSchemaBridge › #getField › returns correct definition (allOf with $ref)

    Invariant Violation: Field not found in schema: "shippingAddress.street"

      162 |       }
      163 | 
    > 164 |       invariant(definition, 'Field not found in schema: "%s"', name);
          |       ^
      165 | 
      166 |       if (definition.$ref) {
      167 |         definition = resolveRef(definition.$ref, this.schema);

      at invariant (node_modules/invariant/invariant.js:40:15)
      at packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts:164:7
          at Array.reduce (<anonymous>)
      at JSONSchemaBridge.reduce [as getField] (packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts:123:33)
      at Object.getField (packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts:334:21)

I expect it to work and also see this happen while trying to implement uniform with a schema generated by pydantic

@hmvp
Copy link
Author

hmvp commented May 12, 2020

Happens both in v2 and in v3

@radekmie radekmie added this to Needs triage in Open Source (migrated) May 13, 2020
@radekmie radekmie added the Type: Bug Bug reports and their fixes label May 13, 2020
@radekmie radekmie moved this from Needs triage to To do in Open Source (migrated) May 13, 2020
@Monteth
Copy link
Member

Monteth commented May 13, 2020

Hi @hmvp,
Thank you for reporting, I'll take care of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug reports and their fixes
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants