Skip to content

Add comprehensive test examples #1168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
9 changes: 0 additions & 9 deletions demo/examples/tests/allOf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,6 @@ paths:

components:
schemas:
# Your existing schemas are integrated here.
ExistingSchema1:
type: object
properties: ...

ExistingSchema2:
type: object
properties: ...

# New schemas for Books demonstration
BookBase:
type: object
Expand Down
68 changes: 68 additions & 0 deletions demo/examples/tests/callbacks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
openapi: 3.0.1
info:
title: Callback Example API
description: Demonstrates callback usage.
version: 1.0.0
tags:
- name: callbacks
description: callback tests
paths:
/streams:
post:
tags:
- callbacks
summary: Subscribe for stream events
description: |
This endpoint registers for stream events.

Schema:
```yaml
callbacks:
onEvent:
'{$request.body#/callbackUrl}':
post:
requestBody:
description: Callback payload
required: true
content:
application/json:
schema:
type: object
properties:
message:
type: string
responses:
'200':
description: Callback accepted
```
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
callbackUrl:
type: string
required:
- callbackUrl
callbacks:
onEvent:
"{$request.body#/callbackUrl}":
post:
requestBody:
description: Callback payload
required: true
content:
application/json:
schema:
type: object
properties:
message:
type: string
responses:
"200":
description: Callback accepted
responses:
"201":
description: Subscription created
100 changes: 100 additions & 0 deletions demo/examples/tests/conditionals.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
openapi: 3.1.0
info:
title: Conditional and Prefix Items API
description: Demonstrates if/then/else and prefixItems usage.
version: 1.0.0
tags:
- name: advanced
description: conditional and array tests
paths:
/conditional-object:
get:
tags:
- advanced
summary: Conditional schema with if/then/else
description: |
This endpoint validates an object with conditional logic.

Schema:
```yaml
type: object
properties:
type:
type: string
if:
properties:
type:
const: special
then:
required: [specialProp]
properties:
specialProp:
type: string
else:
properties:
otherProp:
type: integer
example:
type: special
specialProp: "value"
```
responses:
"200":
description: Successful response
content:
application/json:
schema:
type: object
properties:
type:
type: string
if:
properties:
type:
const: special
then:
required:
- specialProp
properties:
specialProp:
type: string
else:
properties:
otherProp:
type: integer
example:
type: special
specialProp: "value"
/fixed-array:
get:
tags:
- advanced
summary: Array with prefixItems
description: |
This endpoint demonstrates the prefixItems feature.

Schema:
```yaml
type: array
prefixItems:
- type: string
- type: integer
items: false
example:
- "name"
- 1
```
responses:
"200":
description: Successful response
content:
application/json:
schema:
type: array
prefixItems:
- type: string
- type: integer
items: false
example:
- "name"
- 1
42 changes: 40 additions & 2 deletions demo/examples/tests/enumDescriptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,25 @@ paths:
tags:
- enumDescriptions
summary: Get entities by status
description: Get all entities or search by status
description: |
Get all entities or search by status.

Schema:
```yaml
status:
in: query
required: true
schema:
type: string
enum:
- active
- inactive
- pending
x-enumDescriptions:
active: The entity is active
inactive: The entity is inactive
pending: The entity is pending approval
```
parameters:
- name: status
in: query
Expand All @@ -39,7 +57,27 @@ paths:
tags:
- enumDescriptions
summary: Get entities by multiple status
description: Get all entities or search by multiple status
description: |
Get all entities or search by multiple status.

Schema:
```yaml
status:
in: query
required: true
schema:
type: array
items:
type: string
enum:
- active
- inactive
- pending
x-enumDescriptions:
active: The entity is active
inactive: The entity is inactive
pending: The entity is pending approval
```
parameters:
- name: status
in: query
Expand Down
57 changes: 57 additions & 0 deletions demo/examples/tests/examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
openapi: 3.0.2
info:
title: Multiple Examples API
description: Demonstrates the `examples` field.
version: 1.0.0
tags:
- name: examples
description: examples tests
paths:
/color:
get:
tags:
- examples
summary: Parameter with multiple examples
description: |
Provides color information.

Schema:
```yaml
parameters:
- name: palette
in: query
schema:
type: string
examples:
primary:
value: red
secondary:
value: blue
```
parameters:
- name: palette
in: query
schema:
type: string
examples:
primary:
value: red
secondary:
value: blue
responses:
"200":
description: OK
content:
application/json:
schema:
type: object
properties:
palette:
type: string
examples:
primary:
value:
palette: red
secondary:
value:
palette: blue
48 changes: 48 additions & 0 deletions demo/examples/tests/formatStrings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
openapi: 3.0.3
info:
title: Format Strings API
description: Demonstrates various string formats.
version: 1.0.0
tags:
- name: formats
description: format tests
paths:
/string-formats:
get:
tags:
- formats
summary: Strings with format validation
description: |
This endpoint returns strings in different formats.

Schema:
```yaml
type: object
properties:
uuid:
type: string
format: uuid
email:
type: string
format: email
example:
uuid: "123e4567-e89b-12d3-a456-426614174000"
email: "user@example.com"
```
responses:
"200":
description: Successful response
content:
application/json:
schema:
type: object
properties:
uuid:
type: string
format: uuid
email:
type: string
format: email
example:
uuid: "123e4567-e89b-12d3-a456-426614174000"
email: "user@example.com"
Loading
Loading