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 in synch with required raising an error on POST where it should not #2628

Closed
LasneF opened this issue May 31, 2024 · 2 comments
Closed
Labels
jira OpenAPI Issues related to the OpenAPI ruleset p/medium t/bug Something isn't working triaged

Comments

@LasneF
Copy link

LasneF commented May 31, 2024

Describe the bug

given an attribute set readOnly , and as part of the required list , Spectral raises an error
oas3-valid-media-example , property must have required property "XXX"

Looks the context of usage here in a POST is not taken into account

To Reproduce

leveraging the spec below just run spectral lint

it raises
39:13 error oas3-valid-media-example "value" property must have required property "id" components.examples.Medor.value

openapi: 3.1.0

info: 
  title: "sample"
  version: "sample"
  
paths:
  /dogs:
    post:
      requestBody:
        content:
          application/json:
            schema:
                $ref: '#/components/schemas/Dogs'
            examples:
              Simple:
                $ref: '#/components/examples/Medor' 
      responses:
        '200':
          description: nice Dog

  
components:
  schemas:
    Dogs:
        type: object
        required: 
          -  id
        properties:
            id: 
              readOnly: true
              type: integer
            name: 
              type: "string"
  examples: 
    Medor: 
      description: |
        A simple pricing request on a single product.
      value:
        name : "Medor le chien"

Expected behavior
looking on OAI/learn.openapis.org#101 ,
and the statement
" If the property is marked as readOnly being true and is in the required list, the required will take effect on the response only."

the field should not raise such error

Environment (remove any that are not applicable):
Tested leveraging spectral 6.11.1 on windows

Additional context
Add any other context about the problem here.

@daniel-white daniel-white added t/bug Something isn't working p/medium triaged OpenAPI Issues related to the OpenAPI ruleset jira labels Jun 14, 2024
Copy link
Contributor

This ticket has been labeled jira. A tracking ticket in Stoplight's Jira (STOP-647) has been created.

@LasneF LasneF closed this as completed Sep 23, 2024
@LasneF
Copy link
Author

LasneF commented Sep 23, 2024

cannot reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira OpenAPI Issues related to the OpenAPI ruleset p/medium t/bug Something isn't working triaged
Projects
None yet
Development

No branches or pull requests

2 participants