Skip to content

Commit 9d68e42

Browse files
committed
fix(sample-gen): parameter array missing items fallback
* fixes swagger-api#7375
1 parent fd31ed0 commit 9d68e42

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/core/plugins/samples/fn.js

+4
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ export const sampleFromSchemaGeneric = (schema, config={}, exampleOverride = und
500500
}
501501

502502
if(type === "array") {
503+
if (!items) {
504+
return
505+
}
506+
503507
let sampleArray
504508
if(respectXML) {
505509
items.xml = items.xml || schema?.xml || {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
openapi: 3.0.0
2+
info:
3+
title: test
4+
version: "1.0.0"
5+
paths:
6+
/example1:
7+
get:
8+
description: test fetching
9+
parameters:
10+
- in: query
11+
name: basicName
12+
content:
13+
application/json:
14+
schema:
15+
type: object
16+
properties:
17+
color:
18+
oneOf:
19+
- type: array # invalid definition b/c type: array is missing 'items'
20+
- type: string
21+
- type: integer
22+
responses:
23+
'200':
24+
description: successfull fetch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
describe("Parameter - Invalid definition with missing array 'items' (#7375)", () => {
2+
it("should render gracefully with fallback to default value", () => {
3+
cy.visit("/?url=/documents/features/parameter-array-missing-items.yaml")
4+
.get("#operations-default-get_example1")
5+
.click()
6+
.get("tbody > tr > .parameters-col_description textarea")
7+
.should("exist")
8+
.should("contains.text", "{}")
9+
})
10+
})

0 commit comments

Comments
 (0)