Open
Description
Describe the bug
I have a component schema (Body
) with a property (prop2
) that should be readonly
and its value can be either a number
or an enum
key. I declared it with oneOf
to accomplish the desired result, and the property is correctly hidden when I check the Request Body Schema in the preview doc. Unfortunately, the same is not true for the generated sample request in the sidebar.
To Reproduce
Steps to reproduce the behavior:
-
Given this
redocly.yaml
file
None -
And this OpenAPI file(s)
openapi: 3.1.0
info:
title: Test
version: 1.0.0
paths:
/test:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Body'
responses:
'200':
description: OK
components:
schemas:
Body:
type: object
properties:
prop1:
type: string
prop2:
readOnly: true
oneOf:
- $ref: '#/components/schemas/Enum'
- type: number
Enum:
type: string
enum:
- value1
- value2
- Run this command with these arguments...
redocly ...
redocly preview-docs openapi.yaml
- See error
The generated request sample payload contains the field that should bereadonly
{
"prop1": "string",
"prop2": "value1"
}
Expected behavior
The prop2
field should be omitted, in the same fashion it is in the Request Body Schema definition.
{
"prop1": "string"
}
Logs
-
OpenAPI description
-
Redocly Version(s)
1.19.0
Node.js
Version(s)
v20.13.1
Additional context
-