Skip to content
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"classnames": "^2.3.1",
"css.escape": "1.5.1",
"deep-extend": "0.6.0",
"dompurify": "^2.2.7",
"dompurify": "^2.2.8",
"ieee754": "^1.2.1",
"immutable": "^3.x.x",
"js-file-download": "^0.4.12",
Expand Down Expand Up @@ -155,7 +155,7 @@
"npm-audit-ci-wrapper": "^3.0.0",
"npm-run-all": "^4.1.5",
"oauth2-server": "^2.4.1",
"open": "^8.0.6",
"open": "^8.0.7",
"postcss": "=8.2.13",
"postcss-loader": "=4.2.0",
"postcss-preset-env": "=6.7.0",
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ function validateValueBySchema(value, schema, requiredByParam, bypassRequiredChe
let minItems = schema.get("minItems")
let pattern = schema.get("pattern")

const schemaRequiresValue = requiredByParam || requiredBySchema
const schemaRequiresValue = requiredByParam || requiredBySchema === true
const hasValue = value !== undefined && value !== null
const isValidEmpty = !schemaRequiresValue && !hasValue

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
swagger: '2.0'
info:
version: '1.0'
title: "schema required properties should not be treated like required: true"
paths:
'/v1/any-path':
put:
summary: lorem
operationId: setDeliveryLocation
produces:
- application/json
parameters:
- in: body
name: body
description: ipsum
required: false
schema:
$ref: '#/definitions/TopModel'
responses:
'200':
description: successful operation
definitions:
TopModel:
type: object
properties:
testProperty:
$ref: '#/definitions/NestedModel'
NestedModel:
type: object
required:
- validated
properties:
validated:
type: boolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe("Try It Out: schema required properties can be overriden", () => {
it("should execute", () => {
cy
.visit("?tryItOutEnabled=true&url=/documents/features/try-it-out-schema-required-override-allowed.yaml")
.get("#operations-default-setDeliveryLocation")
.click()
.get(".body-param__text")
.should("include.value", "testProperty")
.clear() // swagger-ui will auto insert "{}" into textarea
.get(".execute-wrapper > .btn")
.click()
.get(".curl-command")
.should("exist")
})
})