You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following error is thrown on a post body's example.
oas3-valid-media-example "example" property must have required property "id"
The field is indeed required, but it is marked as read only - hence it should not be required in the post body.
To Reproduce
# test.ymlopenapi: 3.0.0info:
title: Reproductionversion: 1.0.0servers:
- url: http://localhost:8080/api/v1description: Development serverpaths:
/test:
post:
summary: CreaterequestBody:
required: truecontent:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Payload'example:
foo: 1bar: 2responses:
'201':
description: Createdcontent:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Payload'example:
id: 1foo: 2bar: 3components:
schemas:
Payload:
type: objectrequired:
- id
- foo
- barproperties:
id:
type: numberdescription: Some idreadOnly: truefoo:
type: numberdescription: Some fieldbar:
type: numberdescription: Some other field
extends: spectral:oas
# .spectral.yml
spectral lint test.yml
3:6 warning info-contact Info object must have "contact" object. info
3:6 warning info-description Info "description" must be present and non-empty string. info
13:10 warning operation-description Operation "description" must be present and non-empty string. paths./test.post
13:10 warning operation-operationId Operation must have "operationId". paths./test.post
13:10 warning operation-tags Operation must have non-empty "tags" array. paths./test.post
22:21 error oas3-valid-media-example "example" property must have required property "id" paths./test.post.requestBody.content.application/json.example <-- unexpected
22:21 error oas3-valid-media-example "example" property must match exactly one schema in oneOf paths./test.post.requestBody.content.application/json.example <-- expected given the above error, but otherwise unexpected
Expected behavior
Read only fields that are marked required should not be required in an example when POSTing or PUTing the body.
3:6 warning info-contact Info object must have "contact" object. info
3:6 warning info-description Info "description" must be present and non-empty string. info
13:10 warning operation-description Operation "description" must be present and non-empty string. paths./test.post
13:10 warning operation-operationId Operation must have "operationId". paths./test.post
13:10 warning operation-tags Operation must have non-empty "tags" array. paths./test.post
Environment (remove any that are not applicable):
Library version: 6.3.0
OS: macOS Monterey
The text was updated successfully, but these errors were encountered:
Hey!
Thank you for reporting the issue!
We already have the same bug report #1274, so I'll close this issue out.
Please leave a thumbs up or subscribe to that issue, I'll keep you posted if we resolve the issue.
Describe the bug
The following error is thrown on a post body's example.
The field is indeed required, but it is marked as read only - hence it should not be required in the post body.
To Reproduce
# .spectral.yml spectral lint test.yml
Expected behavior
Read only fields that are marked required should not be required in an example when POSTing or PUTing the body.
Environment (remove any that are not applicable):
The text was updated successfully, but these errors were encountered: