Redocly/redoc
Vedi su GitHubProperties marked as readOnly are shown in POST payload examples
Open
#1238 aperta il 21 apr 2020
Type: Bughelp wanted
Metriche repository
- Star
- (21.877 star)
- Metriche merge PR
- (Merge medio 3h 40m) (11 PR mergiate in 30 g)
Descrizione
I am using the latest version from I am trying to mark some of my properties in the schema as readOnly:
openapi: 3.0.0
info:
title: Readonly Example
version: 0.0.1
servers:
- url: https://myserver.com/api/v1
description: Test Environment
paths:
/backend/article:
get:
summary: Returns a list with all articles in the system
responses:
'200':
description: A list of all event series
content:
application/json:
schema:
$ref: '#/components/schemas/ArrayOfArticles'
tags:
- Backend/Article
post:
summary: Creates a new article
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Article'
required: true
responses:
'200':
description: Success
tags:
- Backend/Article
components:
schemas:
ArrayOfArticles:
type: array
items:
$ref: '#/components/schemas/Article'
Article:
type: object
properties:
id:
type: string
readOnly: true
title:
type: string
content:
type: string
createdAt:
type: string
readOnly: true
updatedAt:
type: string
readOnly: true
required:
- id
- title
- content
- createdAt
- updatedAt
example:
id: 1e8b472d03s6ae24457f15a2
title: My Article 01
content: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean arcu arcu, finibus sed mattis in, placerat in justo. Proin feugiat semper laoreet.
updatedAt: 2020-04-06T17:14:37+02:00
createdAt: 2020-04-06T17:14:37+02:00
This gets rendered as follows:

In the POST request body schema the properties id, updatedAt, createdAt are correctly stripped out.

Unfortunately the sample values are getting displayed in the sample payload of the POST request.

My expectation would be that those properties are getting stripped out from the sample payload in the POST request aswell. Am I missing something?