Skip to content

Commit 6d1f2d6

Browse files
darrelmillercharjr
authored andcommitted
Added example of making overlays work like traits (OAI#2534)
1 parent 9fcfc4b commit 6d1f2d6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

proposals/004_Overlays.md

+37
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,43 @@ updates:
165165
remove: true
166166
```
167167

168+
##### Traits Examples
169+
170+
By annotating an OpenAPI description using extension such as `x-oai-traits` an author of OpenAPI description can identify where overlay updates should be applied.
171+
172+
```yaml
173+
openapi: 3.1.0
174+
info:
175+
title: Api with a paged collection
176+
version: 1.0.0
177+
paths:
178+
/items:
179+
get:
180+
x-oai-traits: ["paged"]
181+
responses:
182+
200:
183+
description: OK
184+
```
185+
186+
With the above OpenAPI description, following Overlay document will apply the necessary updates to describe how paging is implemented, where that trait has been applied.
187+
188+
```yaml
189+
overlay: 1.0.0
190+
info:
191+
title: Apply Traits
192+
version: 1.0.0
193+
updates:
194+
- target: $.paths[*].get[?contains(x-traits,'paged')]
195+
merge:
196+
parameters:
197+
- name: top
198+
in: query
199+
- name: skip
200+
in: query
201+
```
202+
203+
This approach allows flipping control of where Overlays apply updates to the OpenAPI description itself.
204+
168205
## Proposal Summary
169206

170207
### Benefits

0 commit comments

Comments
 (0)