You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use the readOnly and writeOnly keywords to mark specific properties as read-only or write-only. This is useful, for example, when GET returns more properties than used in POST – you can use the same schema in both GET and POST and mark the extra properties as readOnly. readOnly properties are included in responses but not in requests, and writeOnly properties may be sent in requests but not in responses.
So writeOnly properties should not be rendered in responses.
Minimal Example Spec
openapi: "3.0.0"
info:
title: Sample API
description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
version: "0.1"
paths:
/users:
post:
summary: Create a user.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User'
responses:
'201':
description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
properties:
id:
type: integer
example: 1
readOnly: true
suggestedId:
type: integer
example: 100
writeOnly: true
Actual Behaviour
writeOnly properties are rendered in responses.
Steps to Reproduce
Just render the spec above. The write only suggestedId will be rendered also in the PATCH response also.
Environment
OS: Docker container
Python version: 3.6+
Swagger/OpenAPI version used: 3.0.0+
Backend: openapi-spec-validator
The text was updated successfully, but these errors were encountered:
Expected Behaviour
As stated on the docs:
So
writeOnly
properties should not be rendered in responses.Minimal Example Spec
Actual Behaviour
writeOnly
properties are rendered in responses.Steps to Reproduce
Just render the spec above. The write only
suggestedId
will be rendered also in thePATCH
response also.Environment
The text was updated successfully, but these errors were encountered: