Skip to content
101 changes: 60 additions & 41 deletions src/schemas/validation/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ $defs:
additionalProperties:
$ref: '#/$defs/media-type-or-reference'
patternProperties:
'^(schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems|mediaTypes)$':
'^(?:schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems|mediaTypes)$':
$comment: Enumerating all of the property names in the regex above is necessary for unevaluatedProperties to work as expected
propertyNames:
pattern: '^[a-zA-Z0-9._-]+$'
Expand Down Expand Up @@ -236,9 +236,7 @@ $defs:
items:
$ref: '#/$defs/server'
parameters:
type: array
items:
$ref: '#/$defs/parameter-or-reference'
$ref: '#/$defs/parameters'
additionalOperations:
type: object
additionalProperties:
Expand Down Expand Up @@ -295,9 +293,7 @@ $defs:
operationId:
type: string
parameters:
type: array
items:
$ref: '#/$defs/parameter-or-reference'
$ref: '#/$defs/parameters'
requestBody:
$ref: '#/$defs/request-body-or-reference'
responses:
Expand Down Expand Up @@ -334,6 +330,36 @@ $defs:
$ref: '#/$defs/specification-extensions'
unevaluatedProperties: false

parameters:
type: array
items:
$ref: '#/$defs/parameter-or-reference'
not:
allOf:
- contains:
type: object
properties:
in:
const: query
required:
- in
- contains:
type: object
properties:
in:
const: querystring
required:
- in
contains:
type: object
properties:
in:
const: querystring
required:
- in
minContains: 0
maxContains: 1

parameter:
$comment: https://spec.openapis.org/oas/v3.2#parameter-object
type: object
Expand Down Expand Up @@ -376,8 +402,6 @@ $defs:
properties:
in:
const: query
required:
- in
then:
properties:
allowEmptyValue:
Expand All @@ -387,8 +411,6 @@ $defs:
properties:
in:
const: querystring
required:
- in
then:
required:
- content
Expand All @@ -415,8 +437,6 @@ $defs:
properties:
in:
const: path
required:
- in
then:
properties:
style:
Expand All @@ -435,8 +455,6 @@ $defs:
properties:
in:
const: header
required:
- in
then:
properties:
style:
Expand All @@ -448,8 +466,6 @@ $defs:
properties:
in:
const: query
required:
- in
then:
properties:
style:
Expand All @@ -465,13 +481,13 @@ $defs:
properties:
in:
const: cookie
required:
- in
then:
properties:
style:
default: form
const: form
enum:
- form
- cookie

unevaluatedProperties: false

Expand Down Expand Up @@ -539,14 +555,14 @@ $defs:
$ref: '#/$defs/encoding'
itemEncoding:
$ref: '#/$defs/encoding'
dependentSchemas:
encoding:
properties:
prefixEncoding: false
itemEncoding: false
allOf:
- $ref: '#/$defs/examples'
- $ref: '#/$defs/specification-extensions'
- dependentSchemas:
encoding:
properties:
prefixEncoding: false
itemEncoding: false
unevaluatedProperties: false

media-type-or-reference:
Expand All @@ -571,7 +587,6 @@ $defs:
additionalProperties:
$ref: '#/$defs/header-or-reference'
style:
default: form
enum:
- form
- spaceDelimited
Expand All @@ -580,7 +595,6 @@ $defs:
explode:
type: boolean
allowReserved:
default: false
type: boolean
encoding:
type: object
Expand All @@ -592,14 +606,28 @@ $defs:
$ref: '#/$defs/encoding'
itemEncoding:
$ref: '#/$defs/encoding'
dependentSchemas:
encoding:
properties:
prefixEncoding: false
itemEncoding: false
style:
properties:
allowReserved:
default: false
explode:
properties:
style:
default: form
allowReserved:
default: false
allowReserved:
properties:
style:
default: form
allOf:
- $ref: '#/$defs/specification-extensions'
- $ref: '#/$defs/styles-for-form'
- dependentSchemas:
encoding:
properties:
prefixEncoding: false
itemEncoding: false
unevaluatedProperties: false

responses:
Expand Down Expand Up @@ -783,7 +811,6 @@ $defs:
allowReserved:
default: false
type: boolean
$ref: '#/$defs/examples'
allOf:
- $ref: '#/$defs/examples'
- $ref: '#/$defs/specification-extensions'
Expand Down Expand Up @@ -872,8 +899,6 @@ $defs:
properties:
type:
const: apiKey
required:
- type
then:
properties:
name:
Expand All @@ -892,8 +917,6 @@ $defs:
properties:
type:
const: http
required:
- type
then:
properties:
scheme:
Expand Down Expand Up @@ -922,8 +945,6 @@ $defs:
properties:
type:
const: oauth2
required:
- type
then:
properties:
flows:
Expand All @@ -939,8 +960,6 @@ $defs:
properties:
type:
const: openIdConnect
required:
- type
then:
properties:
openIdConnectUrl:
Expand Down
3 changes: 0 additions & 3 deletions tests/schema/fail/example-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ components:
examples:
a mammalian example:
dataValue: bear



1 change: 0 additions & 1 deletion tests/schema/fail/invalid_schema_types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ components:
invalid_null: null
invalid_number: 0
invalid_array: []

20 changes: 20 additions & 0 deletions tests/schema/fail/operation-object-query-with-querystring.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
openapi: 3.2.0
info:
title: API
version: 1.0.0
components:
pathItems:
my-path-item:
get:
description: a query parameter cannot be used together with a querystring parameter
parameters:
- name: myquerystring
in: querystring
content:
application/json:
schema:
type: string
- name: myquery
in: query
schema:
type: string
20 changes: 20 additions & 0 deletions tests/schema/fail/operation-object-two-querystrings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
openapi: 3.2.0
info:
title: API
version: 1.0.0
components:
pathItems:
my-path-item:
get:
description: querystring cannot be used twice
parameters:
- name: myquerystring1
in: querystring
content:
application/json:
schema: {}
- name: myquerystring2
in: querystring
content:
application/json:
schema: {}
19 changes: 19 additions & 0 deletions tests/schema/fail/path-item-object-query-with-querystring.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
openapi: 3.2.0
info:
title: API
version: 1.0.0
components:
pathItems:
my-path-item:
parameters:
- name: myquerystring
in: querystring
content:
application/json:
schema:
type: string
- name: myquery
in: query
schema:
type: string
get: {}
20 changes: 20 additions & 0 deletions tests/schema/fail/path-item-object-two-querystrings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
openapi: 3.2.0
info:
title: API
version: 1.0.0
components:
pathItems:
my-path-item:
description: querystring cannot be used twice
parameters:
- name: myquerystring1
in: querystring
content:
application/json:
schema: {}
- name: myquerystring2
in: querystring
content:
application/json:
schema: {}
get: {}
2 changes: 1 addition & 1 deletion tests/schema/pass/example-object-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ components:
summary: This is a text example
externalValue: https://foo.bar/examples/address-example.txt
parameters:
with-example:
with-example:
name: zipCode
in: query
schema:
Expand Down
15 changes: 11 additions & 4 deletions tests/schema/pass/parameter-object-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ paths:
type: number
long:
type: number
- in: cookie
name: my_cookie1
style: form
schema: {}
- in: cookie
name: my_cookie2
style: cookie
schema: {}
/user:
parameters:
- in: querystring
Expand All @@ -62,7 +70,6 @@ paths:
# Allow an arbitrary JSON object to keep
# the example simple
type: object
example: {
"numbers": [1, 2],
"flag": null
}
example:
numbers: [1, 2]
flag: null
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ paths:
# the example simple
type: object
# DEPRECATED: don't use example keyword inside Schema Object
example: {
"numbers": [1, 2],
"flag": null
}
example:
numbers: [1, 2]
flag: null