Skip to content

Add support for readOnly and writeOnly properties #30

Open
@jormaechea

Description

@jormaechea

Summary
Apisprout does not support readOnly and writeOnly attributes of properties.

Steps to reproduce
Mock this schema:

paths:
  /foo:
    get:
      operationId: getFoo
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/fooSchema"
    post:
      operationId: postFoo
      requestBody:
        description: The state to set to the alarm
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/fooSchema"

components:
  schemas:
    fooSchema:
      type: object
      properties:
        normalProp:
          type: string
        readOnlyProp:
          readOnly: true
        writeOnlyProp:
          writeOnly: true
      required:
        - normalProp
        - readOnlyProp
        - writeOnlyProp

Actual result
In GET operation, the example includes writeOnlyProp. In POST operation it requires readOnlyProp.

Expected result

  1. It shouldn't include writeOnly properties in auto-generated examples. The response should be:
{
  "normalProp": "string",
  "readOnlyProp": "string"
}
  1. It shouldn't require readOnly properties in the request body. This request body should be valid:
{
  "normalProp": "foo",
  "writeOnlyProp": "bar"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstream

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions