cnheric
5 years agoNew Contributor
readOnly properties do not display correctly with Swagger UI in python-flask
Using this example yaml:
openapi: 3.0.0
info:
version: 0.0.0
title: test
paths:
/users:
post:
summary: Create a user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/User'
components:
schemas:
User:
type: object
properties:
id:
type: integer
example: 5
readOnly: true
name:
type: string
example: Bob
I expect to see this in the request body:
{
"name": "Bob"
}
However, I can also see the id property:
{
"id": 5,
"name": "Bob"
}
This occurs whenever I generate code, through both the Swagger Editor and Swagger Codegen in python-flask.
However, it displays correctly in the Swagger Editor's preview:
Swagger Editor preview is correct
I'm likely somehow generating it incorrectly, so any help would be greatly appreciated!