fix(requestBody): hide read only properties (#6490)
This commit is contained in:
@@ -135,6 +135,8 @@ const RequestBody = ({
|
||||
<tbody>
|
||||
{
|
||||
Map.isMap(bodyProperties) && bodyProperties.entrySeq().map(([key, prop]) => {
|
||||
if (prop.get("readOnly")) return
|
||||
|
||||
let commonExt = showCommonExtensions ? getCommonExtensions(prop) : null
|
||||
const required = schemaForMediaType.get("required", List()).includes(key)
|
||||
const type = prop.get("type")
|
||||
|
||||
57
test/e2e-cypress/static/documents/bugs/6158.yaml
Normal file
57
test/e2e-cypress/static/documents/bugs/6158.yaml
Normal file
@@ -0,0 +1,57 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: "Swagger Test"
|
||||
version: "1.0.0"
|
||||
servers:
|
||||
- url: https://api.example.com/v1
|
||||
paths:
|
||||
/users:
|
||||
get:
|
||||
tags:
|
||||
- User
|
||||
summary: Get Users
|
||||
responses:
|
||||
200:
|
||||
description: User List
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
post:
|
||||
tags:
|
||||
- User
|
||||
summary: Create a user
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
responses:
|
||||
201:
|
||||
description: Created successfully
|
||||
put:
|
||||
tags:
|
||||
- User
|
||||
summary: Update user
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
responses:
|
||||
201:
|
||||
description: Created successfully
|
||||
components:
|
||||
schemas:
|
||||
User:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
readOnly: true
|
||||
name:
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
54
test/e2e-cypress/tests/bugs/6158.js
Normal file
54
test/e2e-cypress/tests/bugs/6158.js
Normal file
@@ -0,0 +1,54 @@
|
||||
describe("#6158: read-only property is not hidden in `POST/PUT`", () => {
|
||||
describe("POST", () => {
|
||||
it("should hide property 'id'", () => {
|
||||
cy.visit("/?url=/documents/bugs/6158.yaml")
|
||||
.get("#operations-User-post_users")
|
||||
.click()
|
||||
.get(".parameters[data-property-name='id']")
|
||||
.should("not.exist")
|
||||
.get(".parameters[data-property-name='name']")
|
||||
.should("exist")
|
||||
})
|
||||
it("should hide property 'id' when trying it out", () => {
|
||||
cy.visit("/?url=/documents/bugs/6158.yaml")
|
||||
.get("#operations-User-post_users")
|
||||
.click()
|
||||
.get(".try-out__btn")
|
||||
.click()
|
||||
.get(".parameters[data-property-name='id']")
|
||||
.should("not.exist")
|
||||
.get("input[placeholder='id']")
|
||||
.should("not.exist")
|
||||
.get(".parameters[data-property-name='name']")
|
||||
.should("exist")
|
||||
.get("input[placeholder='name']")
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
describe("PUT", () => {
|
||||
it("should hide property 'id'", () => {
|
||||
cy.visit("/?url=/documents/bugs/6158.yaml")
|
||||
.get("#operations-User-put_users")
|
||||
.click()
|
||||
.get(".parameters[data-property-name='id']")
|
||||
.should("not.exist")
|
||||
.get(".parameters[data-property-name='name']")
|
||||
.should("exist")
|
||||
})
|
||||
it("should hide property 'id' when trying it out", () => {
|
||||
cy.visit("/?url=/documents/bugs/6158.yaml")
|
||||
.get("#operations-User-put_users")
|
||||
.click()
|
||||
.get(".try-out__btn")
|
||||
.click()
|
||||
.get(".parameters[data-property-name='id']")
|
||||
.should("not.exist")
|
||||
.get("input[placeholder='id']")
|
||||
.should("not.exist")
|
||||
.get(".parameters[data-property-name='name']")
|
||||
.should("exist")
|
||||
.get("input[placeholder='name']")
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user