Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/core/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ function validateValueBySchema(value, schema, requiredByParam, bypassRequiredChe
let stringCheck = type === "string" && value
let arrayCheck = type === "array" && Array.isArray(value) && value.length
let arrayListCheck = type === "array" && Im.List.isList(value) && value.count()
let arrayStringCheck = type === "array" && typeof value === "string" && value
let fileCheck = type === "file" && value instanceof win.File
let booleanCheck = type === "boolean" && (value || value === false)
let numberCheck = type === "number" && (value || value === 0)
Expand All @@ -475,7 +474,7 @@ function validateValueBySchema(value, schema, requiredByParam, bypassRequiredChe
let objectStringCheck = type === "object" && typeof value === "string" && value

const allChecks = [
stringCheck, arrayCheck, arrayListCheck, arrayStringCheck, fileCheck,
stringCheck, arrayCheck, arrayListCheck, fileCheck,
booleanCheck, numberCheck, integerCheck, objectCheck, objectStringCheck,
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe("Try it out with schema type array but example type string", () => {
it("shows a validation error message when Execute is clicked", () => {
cy
.visit("?tryItOutEnabled=true&url=/documents/features/try-it-out-schema-type-array-example-type-string.yaml")
.get("#operations-default-get_")
.click()
.get(".btn.execute")
.click()
.get(".validation-errors")
.should("exist")
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
openapi: 3.0.3
info:
title: test
version: 1.0.0
paths:
/:
get:
parameters:
- in: query
name: test
required: true
schema:
type: array
example: 'test1'
items:
type: string
enum:
- 'test1'
- 'test2'
- 'test3'
responses:
default:
description: ok
2 changes: 1 addition & 1 deletion test/unit/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ describe("utils", () => {
type: "array"
}
value = "[1]"
assertValidateParam(param, value, [])
assertValidateParam(param, value, ["Required field is not provided"])
Comment thread
lukaszzazulak marked this conversation as resolved.

// valid array, items match type
param = {
Expand Down