fix(sample-gen): parameter array missing items fallback (#7376)

* fixes #7375
This commit is contained in:
Tim Lai
2021-06-24 16:25:54 -07:00
committed by GitHub
parent 96d5218e9c
commit de3d063ca3
3 changed files with 38 additions and 0 deletions

View File

@@ -500,6 +500,10 @@ export const sampleFromSchemaGeneric = (schema, config={}, exampleOverride = und
} }
if(type === "array") { if(type === "array") {
if (!items) {
return
}
let sampleArray let sampleArray
if(respectXML) { if(respectXML) {
items.xml = items.xml || schema?.xml || {} items.xml = items.xml || schema?.xml || {}

View File

@@ -0,0 +1,24 @@
openapi: 3.0.0
info:
title: test
version: "1.0.0"
paths:
/example1:
get:
description: test fetching
parameters:
- in: query
name: basicName
content:
application/json:
schema:
type: object
properties:
color:
oneOf:
- type: array # invalid definition b/c type: array is missing 'items'
- type: string
- type: integer
responses:
'200':
description: successfull fetch

View File

@@ -0,0 +1,10 @@
describe("Parameter - Invalid definition with missing array 'items' (#7375)", () => {
it("should render gracefully with fallback to default value", () => {
cy.visit("/?url=/documents/features/parameter-array-missing-items.yaml")
.get("#operations-default-get_example1")
.click()
.get("tbody > tr > .parameters-col_description textarea")
.should("exist")
.should("contains.text", "{}")
})
})