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

readOnly and writeOnly required properties incorrectly validated in examples #486

Closed
rliebz opened this issue Aug 26, 2022 · 3 comments
Closed
Labels
spectral Waiting for fix to be released in Spectral

Comments

@rliebz
Copy link

rliebz commented Aug 26, 2022

Version: 0.88.3

When defining a readOnly or writeOnly property on a component, the linter does not take that into consideration when validating examples for request bodies or response bodies.

For example, if I defined a component with an id property that was defined as readOnly, I would expect that:

  • In a requestBody, the id field is disallowed in the examples, because it is "read only"
  • In a response, the id field is required to be present in examples, because it is "required"

What I actually see is that the property is required in both the request body and the response, with the following error:

  Message :   "example" property must have required property "id"
  Rule    :   oas3-valid-media-example
  Path    :   components.requestBodies.ReplaceEntityRequest.content.application/json.example
@dpopp07
Copy link
Member

dpopp07 commented Aug 29, 2022

@rliebz I think you're correct, I would expect the same behavior you've described above. I hadn't noticed this before. Unfortunately, the rule oas3-valid-media-example is coming from Spectral's own ruleset, which we import into ours. You might want to open up an issue against their repo for their awareness

@dpopp07 dpopp07 added the spectral Waiting for fix to be released in Spectral label Aug 29, 2022
@rliebz
Copy link
Author

rliebz commented Sep 29, 2022

Looks like a known issue: stoplightio/spectral#1274

@padamstx
Copy link
Member

Closing this issue since the problem is occurring in the spectral ruleset which we inherit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spectral Waiting for fix to be released in Spectral
Projects
None yet
Development

No branches or pull requests

3 participants