sylvainlaurent / swagger-validator-maven-plugin

A maven plugin that validates swagger files in yaml and json formats
Apache License 2.0
11 stars 6 forks source link

required attributes of a definition not validated correctly #4

Closed giuliopulina closed 6 years ago

giuliopulina commented 6 years ago

Hello,

I noticed that the validator doesn't work well in case of not existing properties defined in 'required' sections. Let me explain better with an example:

Address:
  type: object
  properties:
    name:
      type: string
    surname:
      type: string
    addressLine:
      type: string
  required:
    - not_existing_property

This definition passes the validation, and I think it's not correct (swagger editor, in such cases, says: "Missing required property definition: not_existing_property".

Do you know where I can look to fix it? Could it be linked to this issue https://github.com/swagger-api/swagger-parser/issues/452?

Thanks Giulio

sylvainlaurent commented 6 years ago

the maven plugin just uses a json schema and the swagger-parser lib. So, I guess the swagger-parser issue you found is the problem... Once it is fixed I can make a new release that uses the updated swagger-parser version...

giuliopulina commented 6 years ago

I don't know if the swagger-parser will be ever modified to include these validations :(

I noticed that the swagger-editor uses an additional set of semantic validation rules, implemented in javascript. Also, I found a list of semantic validation rules from apigee.

Instead of relying on swagger-parser, do you think it will be a good idea to introduce 'semantic validation' also in this project, to be executed after schema validation? I'm interested in trying to implement and I can create a PR when I've finished

sylvainlaurent commented 6 years ago

I'd be happy to review and merge your PR.

sylvainlaurent commented 6 years ago

thanks for the PR #5 , it's now merged to master.

sylvainlaurent commented 6 years ago

thanks @giuliopulina I released 1.1.0 with your contribution. It should be available in Maven Central in a few hours...