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

Must add all child schemas to the Ajv if at least one of them should be validated #555

Closed
2 tasks done
ivan-tymoshenko opened this issue Nov 5, 2022 · 0 comments · Fixed by #556
Closed
2 tasks done
Assignees
Labels
bug Confirmed bug

Comments

@ivan-tymoshenko
Copy link
Member

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

test('object with ref and validated properties', (t) => {
  t.plan(1)

  const externalSchemas = {
    RefSchema: {
      $id: 'RefSchema',
      type: 'string'
    }
  }

  const schema = {
    $id: 'root',
    type: 'object',
    properties: {
      id: {
        anyOf: [
          { type: 'string' },
          { type: 'number' }
        ]
      },
      reference: { $ref: 'RefSchema' }
    }
  }

  const stringify = build(schema, { schema: externalSchemas })
  t.equal(stringify({ id: 1, reference: 'hi' }), '{"id":"foo","reference":"hi"}')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant