33  title : Sample OpenAPI 3.1 API 
44  description : A sample API demonstrating OpenAPI 3.1 features 
55  version : " 2.0.0" 
6-   summary : Sample OpenAPI 3.1 API with the latest features 
7- #  JSON Schema 2020-12 features
6+   summary : Sample OpenAPI 3.1 API with the latest features  #  OpenAPI 3.1 feature
7+   license :
8+     name : Apache 2.0 
9+     identifier : Apache-2.0  #  SPDX license identifier, a new 3.1 feature to define an API's SPDX license expression
10+     url : https://www.apache.org/licenses/LICENSE-2.0.html 
11+ 
12+ #  JSON Schema 2020-12 feature
813jsonSchemaDialect : " https://json-schema.org/draft/2020-12/schema" 
914
1015servers :
1116  - url : https://api.example.com/v2 
1217    description : Main production server 
1318
14- #  Example Webhooks (OpenAPI 3.1 feature)
19+ #  Example Webhooks (OpenAPI 3.1 feature)  
1520webhooks :
1621  newPetAlert :
1722    post :
@@ -21,7 +26,7 @@ webhooks:
2126        content :
2227          application/json :
2328            schema :
24-               $ref :  ' #/components/schemas/Pet ' 
29+               type :  string 
2530      responses :
2631        ' 200 '  :
2732          description : Webhook processed successfully 
@@ -39,118 +44,79 @@ paths:
3944          required : false 
4045          schema :
4146            type : integer 
42-             minimum : 1 
43-             maximum : 100 
47+             # exclusiveMinimum and exclusiveMaximum now represent distinct values
48+             exclusiveMinimum : 1 
49+             exclusiveMaximum : 100 
4450      responses :
4551        ' 200 '  :
4652          description : A paged array of pets 
4753          content :
4854            application/json :
4955              schema :
50-                 $ref : ' #/components/schemas/Pets' 
51-         default :
52-           description : Unexpected error 
53-           content :
54-             application/json :
55-               schema :
56-                 $ref : ' #/components/schemas/Error' 
57-     post :
58-       summary : Create a new pet 
59-       operationId : createPet 
60-       tags :
61-         - pets 
62-       requestBody :
63-         required : true 
64-         content :
65-           application/json :
66-             schema :
67-               $ref : ' #/components/schemas/NewPet' 
68-       responses :
69-         ' 201 '  :
70-           description : Pet created successfully 
71-         default :
72-           description : Unexpected error 
73-           content :
74-             application/json :
75-               schema :
76-                 $ref : ' #/components/schemas/Error' 
77- 
78-   /pets/{petId} :
56+                 #  3.1 feature where we can reference schemas using their identifier
57+                 $ref : ' https://example.com/schemas/pet.json'   
58+   /sample :
7959    get :
80-       summary : Get details of a specific pet 
81-       operationId : getPet 
82-       tags :
83-         - pets 
84-       parameters :
85-         - name : petId 
86-           in : path 
87-           required : true 
88-           description : The ID of the pet to retrieve 
89-           schema :
90-             type : string 
60+       summary : Sample endpoint 
9161      responses :
9262        ' 200 '  :
93-           description : Pet details 
63+           description : Sample response 
9464          content :
9565            application/json :
9666              schema :
97-                 $ref : ' #/components/schemas/Pet' 
98-         default :
99-           description : Unexpected error 
100-           content :
101-             application/json :
102-               schema :
103-                 $ref : ' #/components/schemas/Error' 
67+                 # JSON schema keywords
68+                 $schema : " https://json-schema.org/draft/2020-12/schema" 
69+                 $id : " https://example.com/schemas/person.schema.yaml" 
70+                 $comment : " A schema defining a pet object with optional references to dynamic components." 
71+                 $vocabulary :
72+                   " https://json-schema.org/draft/2020-12/vocab/core "  : true 
73+                   " https://json-schema.org/draft/2020-12/vocab/applicator "  : true 
74+                   " https://json-schema.org/draft/2020-12/vocab/validation "  : true 
75+                   " https://json-schema.org/draft/2020-12/vocab/meta-data "  : false 
76+                   " https://json-schema.org/draft/2020-12/vocab/format-annotation "  : false 
77+ 
78+                 title : " Pet" 
79+                 description : " Schema for a pet object" 
80+                 type : " object" 
81+                 properties :
82+                   name :
83+                     type : " string" 
84+                     $comment : " The pet's full name" 
85+                   address :
86+                     $dynamicRef : " #addressDef" 
87+                     $comment : " Reference to an address definition which can change dynamically"                    
88+                 required :
89+                   - name 
90+                 $dynamicAnchor : " addressDef" 
10491components :
10592  schemas :
10693    Pet :
94+       $id : ' https://example.com/schemas/pet.json' 
10795      type : object 
10896      required :
10997        - id 
11098        - weight 
11199      properties :
112100        id :
113-           type : string 
101+           type : str 
114102          format : uuid 
115103        weight :
116104          type : number 
117105          exclusiveMinimum : 0 
118106          description : Weight of the pet in kilograms 
119107        #  Pattern properties and Type array feature from JSON Schema
120108        attributes :
121-           type : [ object, "null"] 
109+           type : 
110+             - " object" 
111+             - " null" 
122112          description : Dynamic attributes for the pet 
123113          patternProperties :
124114            " ^attr_[A-Za-z]+$ "  :
125115              type : string 
126-       $comment : " This schema represents a pet in the system." 
127-       $defs :
116+       $comment : " This schema represents a pet in the system."   #  JSON Schema 2020-12 feature 
117+       $defs :  #  JSON Schema 2020-12 feature 
128118        ExtraInfo :
129119          type : string 
130120
131-     NewPet :
132-       allOf :
133-         - $ref : ' #/components/schemas/Pet' 
134-         - description : A pet to be added to the store 
135-         - required :
136-             - id 
137- 
138-     Pets :
139-       type : array 
140-       items :
141-         $ref : ' #/components/schemas/Pet' 
142- 
143-     Error :
144-       type : object 
145-       properties :
146-         code :
147-           type : integer 
148-         message :
149-           type : string 
150- 
151121security :
152-   - api_key : [] 
153- 
154- tags :
155-   - name : pets 
156-     description : Everything about your pets 
122+   - api_key : [] 
0 commit comments