Skip to content

Commit 87c005c

Browse files
authored
Merge pull request #105 from ralfhandl/add-examples
Add pages for OAD examples
2 parents 0b247d8 + 8d257cb commit 87c005c

34 files changed

+517
-381
lines changed

.github/workflows/convert-examples-to-json.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
- name: convert YAML examples to JSON
3737
run: find examples/v3* -type f -name "*.yaml" | xargs node scripts/yaml2json/yaml2json.js
3838

39+
- name: pretty-print JSON examples
40+
run: npx prettier --write examples/**/*.json
41+
3942
- name: git diff
4043
run: |
4144
git add examples/**/*.json

.github/workflows/examples-tests.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: schema-test
1+
name: examples-test
22

33
# Author: @MikeRalphson / runs @jdesrosiers tests
44
# Issue: https://github.com/OAI/OpenAPI-Specification/pull/2489

Gemfile.lock

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ GEM
7777

7878
PLATFORMS
7979
arm64-darwin-21
80+
arm64-darwin-23
8081
x86_64-darwin-23
8182
x86_64-linux
8283

_includes/example-api-description.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# {{ include.name }}
2+
3+
{{ include.description }}
4+
5+
## JSON
6+
7+
```json
8+
{% include_relative {{ include.name | append: ".json" }} %}
9+
```
10+
11+
## YAML
12+
13+
```yaml
14+
{% include_relative {{ include.name | append: ".yaml" }} %}
15+
```

_sass/custom/custom.scss

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ object {
22
width: 100%;
33
}
44

5-
65
.nav-list .nav-list-item .nav-list-expander {
76
color: #1d781d !important;
8-
}
7+
}
8+
9+
.highlight .err {
10+
color: inherit;
11+
background-color: inherit;
12+
}

examples/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
layout: default
3+
title: Example API Descriptions
4+
nav_order: 6
5+
has_children: true
6+
has_toc: true
7+
---
8+
9+
# Example API Descriptions

examples/v3.0/api-with-examples.json

+27-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,32 @@
5353
"application/json": {
5454
"examples": {
5555
"foo": {
56-
"value": "{\n \"versions\": [\n {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n }\n ]\n },\n {\n \"status\": \"EXPERIMENTAL\",\n \"updated\": \"2013-07-23T11:33:21Z\",\n \"id\": \"v3.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v3/\",\n \"rel\": \"self\"\n }\n ]\n }\n ]\n}\n"
56+
"value": {
57+
"versions": [
58+
{
59+
"status": "CURRENT",
60+
"updated": "2011-01-21T11:33:21Z",
61+
"id": "v2.0",
62+
"links": [
63+
{
64+
"href": "http://127.0.0.1:8774/v2/",
65+
"rel": "self"
66+
}
67+
]
68+
},
69+
{
70+
"status": "EXPERIMENTAL",
71+
"updated": "2013-07-23T11:33:21Z",
72+
"id": "v3.0",
73+
"links": [
74+
{
75+
"href": "http://127.0.0.1:8774/v3/",
76+
"rel": "self"
77+
}
78+
]
79+
}
80+
]
81+
}
5782
}
5883
}
5984
}
@@ -164,4 +189,4 @@
164189
}
165190
}
166191
}
167-
}
192+
}

examples/v3.0/api-with-examples.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
layout: default
3+
title: api-with-examples
4+
parent: Example API Descriptions
5+
---
6+
7+
{% comment %}
8+
{% capture description %}
9+
Insert description here, then remove comment tag above and endcomment tag below
10+
{% endcapture %}
11+
{% endcomment %}
12+
13+
{% include example-api-description.md name=page.title description=description %}

0 commit comments

Comments
 (0)