Skip to content
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ It is meant to be language agnostic and should require only a JSON parser. The c

This suite covers the following OpenAPI Schema Object dialects:

- **OAS 3.0**: Highly customized subset/superset of JSON Schema Draft 4
- **OAS 3.1**: [`https://spec.openapis.org/oas/3.1/dialect/2024-11-10`](https://spec.openapis.org/oas/3.1/dialect/2024-11-10) (also compatible with [`https://spec.openapis.org/oas/3.1/dialect/base`](https://spec.openapis.org/oas/3.1/dialect/base))
- **OAS 3.2**: [`https://spec.openapis.org/oas/3.2/schema/2025-11-23`](https://spec.openapis.org/oas/3.2/schema/2025-11-23)

## Introduction to the Test Suite Structure

The tests in this suite are contained in the `tests` directory at the root of this repository. Inside that directory is a subdirectory for each supported version of the OpenAPI specification:

- `tests/oas30/` — Tests for the OpenAPI 3.0 Schema Object dialect
- `tests/oas31/` — Tests for the OpenAPI 3.1 Schema Object dialect
- `tests/oas32/` — Tests for the OpenAPI 3.2 Schema Object dialect

Expand Down
160 changes: 160 additions & 0 deletions tests/oas30/allOf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
[
{
"description": "allOf",
"schema": {
"allOf": [
{
"type": "string"
},
{
"minLength": 3
}
]
},
"tests": [
{
"description": "string with sufficient length is valid",
"data": "foobar",
"valid": true
},
{
"description": "short string is not valid",
"data": "ab",
"valid": false
},
{
"description": "integer is not valid",
"data": 1,
"valid": false
}
]
},
{
"description": "allOf with object schemas",
"schema": {
"allOf": [
{
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
]
},
{
"type": "object",
"properties": {
"age": {
"type": "integer"
}
},
"required": [
"age"
]
}
]
},
"tests": [
{
"description": "object with both required properties is valid",
"data": {
"name": "Alice",
"age": 30
},
"valid": true
},
{
"description": "object missing age is not valid",
"data": {
"name": "Alice"
},
"valid": false
},
{
"description": "object missing name is not valid",
"data": {
"age": 30
},
"valid": false
},
{
"description": "empty object is not valid",
"data": {},
"valid": false
}
]
},
{
"description": "allOf with base schema",
"schema": {
"type": "object",
"allOf": [
{
"properties": {
"bar": {
"type": "integer"
}
}
}
],
"properties": {
"foo": {
"type": "string"
}
}
},
"tests": [
{
"description": "valid with both properties",
"data": {
"foo": "quux",
"bar": 1
},
"valid": true
},
{
"description": "not valid, wrong type for bar",
"data": {
"foo": "quux",
"bar": "not-integer"
},
"valid": false
}
]
},
{
"description": "allOf with boolean schemas",
"schema": {
"allOf": [
true,
true
]
},
"tests": [
{
"description": "any value is valid when all subschemas are true",
"data": "foo",
"valid": true
}
]
},
{
"description": "allOf with one false schema always fails",
"schema": {
"allOf": [
true,
false
]
},
"tests": [
{
"description": "any value is invalid when any subschema is false",
"data": "foo",
"valid": false
}
]
}
]
123 changes: 123 additions & 0 deletions tests/oas30/anyOf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
[
{
"description": "anyOf",
"schema": {
"anyOf": [
{
"type": "integer"
},
{
"minimum": 2
}
]
},
"tests": [
{
"description": "an integer is valid",
"data": 1,
"valid": true
},
{
"description": "a number greater than 2 is valid",
"data": 2.5,
"valid": true
},
{
"description": "an integer and greater than 2 is valid",
"data": 3,
"valid": true
},
{
"description": "a float less than 2 is not valid",
"data": 1.5,
"valid": false
}
]
},
{
"description": "anyOf with base schema",
"schema": {
"type": "string",
"anyOf": [
{
"maxLength": 2
},
{
"minLength": 4
}
]
},
"tests": [
{
"description": "short string is valid",
"data": "hi",
"valid": true
},
{
"description": "long string is valid",
"data": "hello",
"valid": true
},
{
"description": "string of length 3 is not valid",
"data": "foo",
"valid": false
},
{
"description": "integer is not valid (fails base schema)",
"data": 1,
"valid": false
}
]
},
{
"description": "anyOf with object schemas",
"schema": {
"anyOf": [
{
"type": "object",
"required": [
"name"
]
},
{
"type": "object",
"required": [
"id"
]
}
]
},
"tests": [
{
"description": "object with name is valid",
"data": {
"name": "Alice"
},
"valid": true
},
{
"description": "object with id is valid",
"data": {
"id": 1
},
"valid": true
},
{
"description": "object with both is valid",
"data": {
"name": "Alice",
"id": 1
},
"valid": true
},
{
"description": "object with neither is not valid",
"data": {
"other": true
},
"valid": false
}
]
}
]
21 changes: 21 additions & 0 deletions tests/oas30/deprecated.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"description": "deprecated property",
"schema": {
"type": "string",
"deprecated": true
},
"tests": [
{
"description": "deprecated is merely an annotation, no validation effect by default",
"data": "foo",
"valid": true
},
{
"description": "invalid types still fail",
"data": 123,
"valid": false
}
]
}
]
Loading