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-required properties are being marked as breaking changes #126

Closed
gssbzn opened this issue Aug 2, 2022 · 2 comments · Fixed by #130
Closed

Readonly-required properties are being marked as breaking changes #126

gssbzn opened this issue Aug 2, 2022 · 2 comments · Fixed by #130

Comments

@gssbzn
Copy link
Contributor

gssbzn commented Aug 2, 2022

Describe the bug
Oasdiff ignores readOnly: true for required fields marking them as breaking changes when they are not

To Reproduce
Steps to reproduce the behavior:
base example

openapi: 3.0.1
info:  
  version: "1.0"
servers:
- url: https://localhost:9080
paths:
  /api/v1.0/groups:    
    post:     
      operationId: createOneGroup
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GroupView'
        description: Creates one project.
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GroupView'
          description: OK        
      summary: Create One Project
  /api/v1.0/groups/{groupId}:
    get:      
      operationId: returnOneGroup
      parameters:      
      - $ref: '#/components/parameters/groupId'      
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GroupView'
          description: OK
      summary: Return One Project
components:
  parameters:
    groupId:      
      in: path
      name: groupId
      required: true
      schema:
        type: string        
  schemas:
    GroupView:
      type: object
      properties:        
        created:
          type: string
          format: date-time          
          readOnly: true
        id:
          type: string          
          readOnly: true        
        name:
          type: string                  
      required:    
      - name

revision example

openapi: 3.0.1
info:  
  version: "1.0"
servers:
- url: https://localhost:9080
paths:
  /api/v1.0/groups:    
    post:     
      operationId: createOneGroup
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GroupView'
        description: Creates one project.
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GroupView'
          description: OK        
      summary: Create One Project
  /api/v1.0/groups/{groupId}:
    get:      
      operationId: returnOneGroup
      parameters:      
      - $ref: '#/components/parameters/groupId'      
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GroupView'
          description: OK
      summary: Return One Project
components:
  parameters:
    groupId:      
      in: path
      name: groupId
      required: true
      schema:
        type: string        
  schemas:
    GroupView:
      type: object
      properties:        
        created:
          type: string
          format: date-time          
          readOnly: true
        id:
          type: string          
          readOnly: true        
        name:
          type: string                  
      required:    
      - name
      - created
      - id
  1. Run oasdiff -breaking-only -base base.yaml -revision revision.yaml
  2. Receive
    modified:
        ?   method: POST
            path: /api/atlas/v1.0/groups
        :   requestBody:
                content:
                    mediaTypeModified:
                        application/json:
                            schema:
                                required:
                                    stringsdiff:
                                        added:
                                            - id
                                            - created

Expected behavior
It should not be a diff for POST, only GET and not a breaking change

Screenshots
redocly safely ignores read_only fields

Screenshot 2022-08-02 at 14 17 29

Desktop (please complete the following information):

  • OS: macOS
  • Version 1.1.39

Additional context
From the OAS definition

Relevant only for Schema "properties" definitions. Declares the property as "read only". This means that it MAY be sent as part of a response but SHOULD NOT be sent as part of the request. If the property is marked as readOnly being true and is in the required list, the required will take effect on the response only. A property MUST NOT be marked as both readOnly and writeOnly being true. Default value is false.

@gssbzn
Copy link
Contributor Author

gssbzn commented Aug 2, 2022

If we agree this is a bug to be fixed I'm happy to take some time to look into possible fixes

@reuvenharrison
Copy link
Collaborator

Hi Gustavo,
I agree with your assessment.
Please go ahead with a fix and let me know if you have any questions.
Thanks,
Reuven

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants