fix(sample-gen): oas3 form-data object should generate example (#7355)
This commit is contained in:
@@ -167,12 +167,14 @@ const RequestBody = ({
|
||||
let initialValue = ""
|
||||
if (type === "array" && !useInitialValue) {
|
||||
initialValue = []
|
||||
} else if (useInitialValue) {
|
||||
}
|
||||
if (type === "object" || useInitialValue) {
|
||||
// TODO: what about example or examples from requestBody could be passed as exampleOverride
|
||||
initialValue = getSampleSchema(prop, false, {
|
||||
includeWriteOnly: true
|
||||
})
|
||||
}
|
||||
|
||||
if (typeof initialValue !== "string" && type === "object") {
|
||||
initialValue = stringify(initialValue)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: multipart/form-data schema object
|
||||
version: 0.0.1
|
||||
paths:
|
||||
/test:
|
||||
post:
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
file:
|
||||
type: string
|
||||
format: binary
|
||||
parameters:
|
||||
"$ref": "#/components/schemas/TestBody"
|
||||
responses:
|
||||
200:
|
||||
description: ok
|
||||
components:
|
||||
schemas:
|
||||
TestBody:
|
||||
type: object
|
||||
properties:
|
||||
stuff:
|
||||
type: string
|
||||
@@ -0,0 +1,16 @@
|
||||
describe("OAS3 default views", () => {
|
||||
describe("multipart/form-data", () => {
|
||||
it("should display calculated object string, when no examples provided (#7268)", () => {
|
||||
cy.visit(
|
||||
"/?url=/documents/features/request-body/multipart/default-views.yaml",
|
||||
)
|
||||
.get("#operations-default-post_test")
|
||||
.click()
|
||||
// Expand Try It Out
|
||||
.get(".try-out__btn")
|
||||
.click()
|
||||
.get(".parameters-col_description textarea")
|
||||
.should("contains.text", "\"stuff\": \"string\"")
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user