Skip to content
Draft
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: 2 additions & 1 deletion demo/apis.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"APIC-758/APIC-758.yaml": "OAS 3.0",
"streetlights/streetlights.yaml": "ASYNC 2.0",
"W-11383870/W-11383870.json": { "type": "OAS 3.0", "mime": "application/json" },
"agents-api/agents-api.yaml": { "type": "OAS 3.0", "mime": "application/yaml" }
"agents-api/agents-api.yaml": { "type": "OAS 3.0", "mime": "application/yaml" },
"oas31-webhooks/oas31-webhooks.yaml": { "type": "OAS 3.1", "mime": "application/yaml" }
}
1 change: 1 addition & 0 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class ComponentDemo extends ApiDemoPage {
['APIC-650', 'APIC-650'],
['multiple-messages', 'multiple-messages'],
['streetlights', 'streetlights'],
['oas31-webhooks', 'OAS 3.1 webhooks'],
].map(([file, label]) => html`
<anypoint-item data-src="${file}-compact.json">${label} - compact model</anypoint-item>
<anypoint-item data-src="${file}.json">${label}</anypoint-item>
Expand Down
106 changes: 106 additions & 0 deletions demo/oas31-webhooks/oas31-webhooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
openapi: 3.1.0
info:
title: Webhooks + Schema Composition Spike
version: 1.0.0
paths:
/pets:
get:
operationId: listPets
summary: List pets
responses:
"200":
description: A list of pets
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Pet"

# Top-level `webhooks` map of Path Item Objects, confirmed in OAS 3.1.0 spec
# (versions/3.1.0.md, field `webhooks`, sibling to `paths`/`components`).
webhooks:
newPet:
post:
operationId: newPetWebhook
summary: Notify subscriber of a newly created pet
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
"200":
description: Webhook received successfully

components:
schemas:
Pet:
# allOf: base fields + discriminated extra fields
allOf:
- $ref: "#/components/schemas/PetBase"
- $ref: "#/components/schemas/PetKindFields"

PetBase:
type: object
required: [id, name]
properties:
id:
type: integer
name:
type: string
kind:
type: string
enum: [dog, cat]

# if/then/else conditional (JSON Schema 2020-12, dialect used by OAS 3.1)
PetKindFields:
if:
properties:
kind:
const: dog
then:
properties:
breed:
type: string
required: [breed]
else:
properties:
indoor:
type: boolean
required: [indoor]

# oneOf: mutually exclusive contact methods
ContactMethod:
oneOf:
- $ref: "#/components/schemas/EmailContact"
- $ref: "#/components/schemas/PhoneContact"

EmailContact:
type: object
required: [email]
properties:
email:
type: string
format: email

PhoneContact:
type: object
required: [phone]
properties:
phone:
type: string

# anyOf: owner may have one or more identifiers present
OwnerIdentifiers:
anyOf:
- required: [ownerId]
properties:
ownerId:
type: integer
- required: [ownerEmail]
properties:
ownerEmail:
type: string
format: email
Loading
Loading