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

Enum validation should not flag null values in nullable enums #2098

Closed
hkosova opened this issue Jan 31, 2020 · 0 comments · Fixed by #2101
Closed

Enum validation should not flag null values in nullable enums #2098

hkosova opened this issue Jan 31, 2020 · 0 comments · Fixed by #2101

Comments

@hkosova
Copy link
Contributor

hkosova commented Jan 31, 2020

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: Chrome latest
  • Method of installation: https://editor.swagger.io
  • Swagger-Editor version: 3.8.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.2
info:
  version: 1.0.0
  title: Nullable enum
paths: {}
components:
  schemas:
    Myschema:
      type: object
      properties:
        nullableProp:
          type: string
          nullable: true
          enum:
            - null
            - 'value1'
            - 'value2'

Describe the bug you're encountering

This is a follow-up to PR #2079.

According to OpenAPI Specification maintainers (1, 2), nullable enums are defined as shown above. That is, the schema should have nullable: true AND also include null (not "null") in the list of enum values.

The issue is that the editor flags the null value and says "enum value should conform to its schema's type". But in this example, null does conform to the schema type, because nullable: true acts as a type modifier.

Expected behavior

null in the definition above should NOT trigger warnings.

@hkosova hkosova changed the title Enum validation flags null values in nullable enums Enum validation should not flag null values in nullable enums Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant