Skip to content

readOnly, writeOnly should work properly when properties are required #281

@pytlesk4

Description

@pytlesk4

Here's an example spec:

openapi: 3.1.0
paths:
  /users/123:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/userObject'
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/userObject'
components:
  schemas:
    userObject:
      type: object
      required:
        - password
      properties:
        name:
          type: string
        password:
          type: string
          writeOnly: true

The following response body should pass validation, because password is write only. password is only required on the request body.

{
    "name": "John"
}

But currently the validator returns the following error:

[Error: 201 response body for '/users/123' failed to validate schema, Reason: The response body for status code '201' is defined as an object. However, it does not meet the schema requirements of the specification, Validation Errors: [Reason: missing property 'password'], Line: 19, Column: 7]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions