apisprout
apisprout copied to clipboard
Add support for readOnly and writeOnly properties
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
- It shouldn't include
writeOnlyproperties in auto-generated examples. The response should be:
{
"normalProp": "string",
"readOnlyProp": "string"
}
- It shouldn't require
readOnlyproperties in the request body. This request body should be valid:
{
"normalProp": "foo",
"writeOnlyProp": "bar"
}
Link to specification
@jormaechea for the two parts:
-
I will update the example generator to take these into account.
-
This is actually an upstream issue, and I have opened getkin/kin-openapi#71 so that it can be handled in the correct repo.
Thanks for these awesome bug reports!
- Great!
- Just subscribed to the upstream issue.
Glad to help with issue reporting! I'd also contribute, but I'm not familiar with go.. :disappointed:
@danielgtaylor you had no news about the upstream issue yet? :disappointed:
FYI https://github.com/getkin/kin-openapi/issues/71 is closed and a new release pushed, please take a look :)