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

Spectral treats wrongly specially named properties #2199

Open
petkostas opened this issue Jul 5, 2022 · 2 comments
Open

Spectral treats wrongly specially named properties #2199

petkostas opened this issue Jul 5, 2022 · 2 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed t/bug Something isn't working triaged

Comments

@petkostas
Copy link

petkostas commented Jul 5, 2022

Spectral wrongly raises an error when using "reserved" fields as properties

properties:
  enum:
    type: object
    description: An object whose properties are the only possible values of a functionality.

Now spectral fails to understand that this is treated as a field of our schema, and raises an error treating it as a type (some values have been replaced with xxxx as they are internal for demonstration purposes):

 683:28  warning  duplicated-entry-in-enum  "enum" property type must be array  paths./xxxx.get.responses[200].content.application/json.examples['xxxxx'].value.xxxxx.enum
 698:28  warning  duplicated-entry-in-enum  "enum" property type must be array  paths./xxxx.get.responses[200].content.application/json.examples['xxxx'].value.xxxxx.enum
 731:28  warning  duplicated-entry-in-enum  "enum" property type must be array  paths./xxxx.get.responses[200].content.application/json.examples['xxxx'].value.xxxxx.enum

✖ 154 problems (89 errors, 65 warnings, 0 infos, 0 hints)

On the other hand, redoc linting is able to detect that the enum above is treated as a property (the 154 errors reported from spectral relate to the enum used a property).

Warning was generated by the tag-description rule.


./v2/schemas/xxxx/openapi.yaml: validated in 88ms

Woohoo! Your OpenAPI definition is valid. 🎉
You have 1 warning.

To Reproduce
Create an object that uses enum (as an example) as it's property

properties:
  enum:
    type: object
    description: An object whose properties are the only possible values of a functionality.

Expected behavior
The linter should not treat enum as the type but as a property

@philsturgeon philsturgeon added the t/bug Something isn't working label Jul 6, 2022
@philsturgeon philsturgeon added help wanted Extra attention is needed good first issue Good for newcomers labels Jul 26, 2022
@LukeMccon
Copy link

@petkostas What version of spectral/ the individual spectral packages are you using?
I'm having trouble reproducing this in the latest version of spectral

@petkostas
Copy link
Author

Hello @LukeMccon, sorry for the late reply, I will run a test again today and get back to you if this has been solved in newer spectral versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed t/bug Something isn't working triaged
Projects
None yet
Development

No branches or pull requests

4 participants