spectral
spectral copied to clipboard
Spectral treats wrongly specially named properties
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
@petkostas What version of spectral/ the individual spectral packages are you using? I'm having trouble reproducing this in the latest version of spectral
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.