Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pages for OAD examples #105

Merged
merged 15 commits into from
Aug 21, 2024
3 changes: 3 additions & 0 deletions .github/workflows/convert-examples-to-json.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- name: convert YAML examples to JSON
run: find examples/v3* -type f -name "*.yaml" | xargs node scripts/yaml2json/yaml2json.js

- name: pretty-print JSON examples
run: npx prettier --write examples/**/*.json

- name: git diff
run: |
git add examples/**/*.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: schema-test
name: examples-test

# Author: @MikeRalphson / runs @jdesrosiers tests
# Issue: https://github.com/OAI/OpenAPI-Specification/pull/2489
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ GEM

PLATFORMS
arm64-darwin-21
arm64-darwin-23
x86_64-darwin-23
x86_64-linux

Expand Down
15 changes: 15 additions & 0 deletions _includes/example-api-description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# {{ include.name }}

{{ include.description }}

## JSON

```json
{% include_relative {{ include.name | append: ".json" }} %}
```

## YAML

```yaml
{% include_relative {{ include.name | append: ".yaml" }} %}
```
8 changes: 6 additions & 2 deletions _sass/custom/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ object {
width: 100%;
}


.nav-list .nav-list-item .nav-list-expander {
color: #1d781d !important;
}
}

.highlight .err {
color: inherit;
background-color: inherit;
}
9 changes: 9 additions & 0 deletions examples/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: default
title: Example API Descriptions
nav_order: 6
has_children: true
has_toc: true
---

# Example API Descriptions
29 changes: 27 additions & 2 deletions examples/v3.0/api-with-examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,32 @@
"application/json": {
"examples": {
"foo": {
"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"
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
},
{
"status": "EXPERIMENTAL",
"updated": "2013-07-23T11:33:21Z",
"id": "v3.0",
"links": [
{
"href": "http://127.0.0.1:8774/v3/",
"rel": "self"
}
]
}
]
}
}
}
}
Expand Down Expand Up @@ -164,4 +189,4 @@
}
}
}
}
}
13 changes: 13 additions & 0 deletions examples/v3.0/api-with-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
layout: default
title: api-with-examples
parent: Example API Descriptions
---

{% comment %}
{% capture description %}
Insert description here, then remove comment tag above and endcomment tag below
ralfhandl marked this conversation as resolved.
Show resolved Hide resolved
{% endcapture %}
{% endcomment %}

{% include example-api-description.md name=page.title description=description %}
Loading