APIDevTools / swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser/validator
https://apitools.dev/swagger-parser
MIT License
1.1k stars 155 forks source link

Validate null value in enums #144

Closed mwxxhdb closed 1 year ago

mwxxhdb commented 4 years ago

Incorrect YAML

EnumObject:
  type: string
  enum:
    - NULL
    - ITEM1
    - ITEM2

Correct YAML

EnumObject:
  type: string
  enum:
    - 'NULL'
    - ITEM1
    - ITEM2

Issue: There are warnings if using the incorrect YAML in SwaggerHub, but swagger-cli said the document is valid.

Warnings from SwaggerHub: enum value should conform to its schema's type

Expect result: Same warning as SwaggerHub.

philsturgeon commented 3 years ago

If you want a really really good validator then give Spectral a go. I helped make it, it does loooooooads of stuff and has far more active development being done.

Otherwise, a PR for this would be appreciated. :D