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

External schema always true #163

Open
uLan08 opened this issue Jun 20, 2018 · 0 comments
Open

External schema always true #163

uLan08 opened this issue Jun 20, 2018 · 0 comments

Comments

@uLan08
Copy link

uLan08 commented Jun 20, 2018

Hi, I am using an external schema from a swagger file but when I validate data, it always return true.

The code

	const swagger = YAML.load('./src/swagger.yaml')
	const validate = validator({
		required: true,
		type: 'array',
		items: {
			$ref: '#/definitions/PostItem'
		}
	}, { verbose: true, schemas: { definitions: swagger.definitions })
	const result = validate(items)
	return { result, errors: validate.errors}

I also have tried loading in the whole swagger file with schemas: swagger.

This is PostItem definition in yaml format

  PostItem:
    allOf:
      - $ref: '#/definitions/Item'
      - type: object
        required:
          - type
          - quantity
        properties:
          type:
            $ref: '#/definitions/Type'
          quantity:
            type: integer
            minimum: 0 

I have tried putting in the schema manually and it was validating it correctly. I really don't want to rewrite parts of my schema just for this.

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

No branches or pull requests

1 participant