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

Add support for readOnly and writeOnly properties #30

Open
jormaechea opened this issue Mar 11, 2019 · 5 comments
Open

Add support for readOnly and writeOnly properties #30

jormaechea opened this issue Mar 11, 2019 · 5 comments
Labels
bug Something isn't working upstream

Comments

@jormaechea
Copy link

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"
}
@danielgtaylor danielgtaylor added the bug Something isn't working label Mar 12, 2019
@danielgtaylor
Copy link
Owner

Link to specification

@danielgtaylor
Copy link
Owner

@jormaechea for the two parts:

  1. I will update the example generator to take these into account.

  2. This is actually an upstream issue, and I have opened Request Validator Checks readOnly Properties getkin/kin-openapi#71 so that it can be handled in the correct repo.

Thanks for these awesome bug reports!

@jormaechea
Copy link
Author

jormaechea commented Mar 13, 2019

  1. Great!
  2. Just subscribed to the upstream issue.

Glad to help with issue reporting! I'd also contribute, but I'm not familiar with go.. 😞

@jormaechea
Copy link
Author

@danielgtaylor you had no news about the upstream issue yet? 😞

@fenollp
Copy link

fenollp commented Oct 21, 2020

FYI getkin/kin-openapi#71 is closed and a new release pushed, please take a look :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

3 participants