Skip to content

Commit cb1c037

Browse files
committed
Add one example to the docs
1 parent b80fa7a commit cb1c037

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Example: `overlayjs --openapi openapi.yml --overlay add-sparkle.yaml`
2828

2929
Use `overlayjs --help` to see the usage information.
3030

31+
See [docs/examples](docs/examples/index.md) for more examples.
32+
3133
## Project status
3234

3335
This project is very much at idea stage but feedback, comments and questions are all very welcome as issues on this repository - and pull requests are also gratefully received. It would be excellent to hear what problem this tool can solve, and how you get on with it. Bonus points if you can share examples (working or broken) of what you tried.

docs/examples/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Overlays examples
2+
3+
- [Update `info.description`](./update-info-description.md)
4+
5+
## About examples
6+
7+
These are examples of common tasks.
8+
Issues to request/suggest more example use cases, or pull requests to add your own examples, are all gratefully received.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Update `info.description`
2+
3+
A common task, to update a description in an OpenAPI document.
4+
This is useful to add a meaningful description to a generated OpenAPI file, or to adjust a description to match a transformed OpenAPI document (perhaps after doing some overlay-powered surgery).
5+
6+
> [!TIP]
7+
> Overlays operate on objects, not single primitive fields such as strings.
8+
> So to update the `info.description`, target `info` and update `description` within it.
9+
10+
## Overlay
11+
12+
An overlay that targets the `info` section and updates it with a new multiline Markdown `description` field.
13+
14+
```yaml
15+
overlay: 1.0.0
16+
info:
17+
title: Overlay to update the description
18+
version: 0.1.0
19+
actions:
20+
- target: $.info
21+
update:
22+
description: >-
23+
A meaningful description for your API helps users to understand how to
24+
get started with your platform. Description fields support Markdown and
25+
the `>-` notation at the start makes this multiline Markdown.
26+
27+
You can link to your [project README](https://github.com/lornajane/openapi-overlays-js)
28+
or other resources from here as well.
29+
```
30+
31+
## OpenAPI
32+
33+
Simplest OpenAPI file I can think of:
34+
35+
```yaml
36+
openapi: 3.1.0
37+
info:
38+
title: Example API
39+
version: 1.0.0
40+
paths:
41+
/example:
42+
get:
43+
responses:
44+
'200':
45+
description: A simple example response
46+
content:
47+
application/json:
48+
schema:
49+
type: object
50+
properties:
51+
message:
52+
type: string
53+
```
54+
55+
## Updated OpenAPI
56+
57+
After overlaying:
58+
59+
```yaml
60+
openapi: 3.1.0
61+
info:
62+
title: Example API
63+
version: 1.0.0
64+
description: >-
65+
A meaningful description for your API helps users to understand how to get
66+
started with your platform. Description fields support Markdown and the `>-`
67+
notation at the start makes this multiline Markdown.
68+
69+
You can link to your [project
70+
README](https://github.com/lornajane/openapi-overlays-js) or other resources
71+
from here as well.
72+
paths:
73+
/example:
74+
get:
75+
responses:
76+
'200':
77+
description: A simple example response
78+
content:
79+
application/json:
80+
schema:
81+
type: object
82+
properties:
83+
message:
84+
type: string
85+
```

0 commit comments

Comments
 (0)