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

Nullable enum warning for null value in example section #1353

Closed
sergle opened this issue Sep 24, 2020 · 6 comments · Fixed by #1376
Closed

Nullable enum warning for null value in example section #1353

sergle opened this issue Sep 24, 2020 · 6 comments · Fixed by #1376
Assignees
Labels
t/bug Something isn't working

Comments

@sergle
Copy link

sergle commented Sep 24, 2020

I receive warning when trying to use null value in example section for property with enum.

To Reproduce

  1. Given this OpenAPI/AsyncAPI document:
    nullable_enum.yaml

  2. Run this CLI command:

spectral lint -v nullable_enum.yaml

  1. See error

Found 82 rules (66 enabled)
Linting nullable_enum.yaml
OpenAPI 3.x detected

nullable_enum.yaml
39:23 warning typed-enum Enum value null does not respect the specified type string.
✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints)

Expected behavior
No warnings produced

Environment:

  • Library version: 5.5.0
  • OS: Debian 9 (image node:14.11-slim from Docker Hub)

Additional context
FROM node:14.11-slim
RUN yarn global add @stoplight/spectral
ADD nullable_enum.yaml nullable_enum.yaml
RUN spectral lint -v nullable_enum.yaml

@sergle sergle added the t/bug Something isn't working label Sep 24, 2020
@philsturgeon
Copy link
Contributor

Do you even need to have that null in there? Isn't that redundant?

@sergle
Copy link
Author

sergle commented Sep 28, 2020

Yes, it's redundant. But I'm trying to document existing API which is already used in such way.

@philsturgeon
Copy link
Contributor

philsturgeon commented Sep 28, 2020 via email

@sergle
Copy link
Author

sergle commented Sep 28, 2020

A literal null.

@philsturgeon
Copy link
Contributor

philsturgeon commented Sep 28, 2020 via email

@sergle
Copy link
Author

sergle commented Sep 30, 2020

When I remove result:null from example, output is:

Found 82 rules (66 enabled)
Linting /tmp/nullable_enum.yaml
OpenAPI 3.x detected

/tmp/nullable_enum.yaml
39:23 warning typed-enum Enum value null does not respect the specified type string.

✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints)

When I remove null from enum values, output is:

Found 82 rules (66 enabled)
Linting /tmp/nullable_enum.yaml
OpenAPI 3.x detected

/tmp/nullable_enum.yaml
41:25 error oas3-valid-schema-example result property should be equal to one of the allowed values: OK, FAILED

✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints)

When I remove both result:null and null from enum values, no problem found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants