Skip to content

Commit e213b6b

Browse files
committed
Remove OpenAPI-Specific submodule in favour of example
We do not bother with a submodule again since we do not need the vast majority of the code from the source repo. Instead, we just manually copy it across. Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent cca8fc3 commit e213b6b

59 files changed

Lines changed: 5642 additions & 12 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "OpenAPI-Specification"]
2-
path = tests/OpenAPI-Specification
3-
url = https://github.com/OAI/OpenAPI-Specification.git

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ repos:
33
rev: v6.0.0
44
hooks:
55
- id: trailing-whitespace
6+
exclude: 'tests/examples'
67
- id: end-of-file-fixer
78
exclude: >
89
(?x)(
9-
tests/renderers/httpdomain/rendered
10+
tests/renderers/httpdomain/rendered |
11+
tests/examples/
1012
)
1113
- id: check-docstring-first
1214
- id: check-json

tests/OpenAPI-Specification

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/examples/.source

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/OAI/learn.openapis.org/tree/b46517f32fb3f03595232b03c85de6e48a90abd5/examples

tests/examples/README.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
OpenAPI Examples
2+
================
3+
4+
A copy of the examples taken from `github.com/OAI/learn.openapis.org`__
5+
6+
This can be updated like so:
7+
8+
.. code-block:: bash
9+
10+
# clone repo
11+
git clone --depth 1 https://github.com/OAI/learn.openapis.org.git /tmp/learn-openapis
12+
13+
# copy updates
14+
rm -rf tests/examples
15+
cp -r /tmp/learn-openapis/examples tests/examples
16+
17+
# store commit
18+
echo "https://github.com/OAI/learn.openapis.org/tree/$(git -C /tmp/learn-openapis rev-parse HEAD)/examples" > tests/examples/.source
19+
20+
# restore README and remove unnecessary index file
21+
git checkout -f HEAD -- tests/examples/README.rst
22+
rm tests/examples/index.md
23+
24+
# delete clone
25+
rm -rf /tmp/learn-openapis
26+
27+
.. __: https://github.com/OAI/learn.openapis.org.git

tests/examples/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
layout: default
3+
title: Example API Descriptions
4+
nav_order: 8
5+
has_children: true
6+
has_toc: true
7+
---
8+
9+
# Example API Descriptions
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "Simple API overview",
5+
"version": "v2"
6+
},
7+
"paths": {
8+
"/": {
9+
"get": {
10+
"operationId": "listVersionsv2",
11+
"summary": "List API versions",
12+
"produces": [
13+
"application/json"
14+
],
15+
"responses": {
16+
"200": {
17+
"description": "200 300 response",
18+
"examples": {
19+
"application/json": "{\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}"
20+
}
21+
},
22+
"300": {
23+
"description": "200 300 response",
24+
"examples": {
25+
"application/json": "{\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}"
26+
}
27+
}
28+
}
29+
}
30+
},
31+
"/v2": {
32+
"get": {
33+
"operationId": "getVersionDetailsv2",
34+
"summary": "Show API version details",
35+
"produces": [
36+
"application/json"
37+
],
38+
"responses": {
39+
"200": {
40+
"description": "200 203 response",
41+
"examples": {
42+
"application/json": "{\n \"version\": {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"media-types\": [\n {\n \"base\": \"application/xml\",\n \"type\": \"application/vnd.openstack.compute+xml;version=2\"\n },\n {\n \"base\": \"application/json\",\n \"type\": \"application/vnd.openstack.compute+json;version=2\"\n }\n ],\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf\",\n \"type\": \"application/pdf\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n }\n ]\n }\n}"
43+
}
44+
},
45+
"203": {
46+
"description": "200 203 response",
47+
"examples": {
48+
"application/json": "{\n \"version\": {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"media-types\": [\n {\n \"base\": \"application/xml\",\n \"type\": \"application/vnd.openstack.compute+xml;version=2\"\n },\n {\n \"base\": \"application/json\",\n \"type\": \"application/vnd.openstack.compute+json;version=2\"\n }\n ],\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://23.253.228.211:8774/v2/\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf\",\n \"type\": \"application/pdf\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n }\n ]\n }\n}"
49+
}
50+
}
51+
}
52+
}
53+
}
54+
},
55+
"consumes": [
56+
"application/json"
57+
]
58+
}
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"version": "1.0.0",
5+
"title": "Swagger Petstore",
6+
"description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7+
"termsOfService": "http://swagger.io/terms/",
8+
"contact": {
9+
"name": "Swagger API Team",
10+
"email": "apiteam@swagger.io",
11+
"url": "http://swagger.io"
12+
},
13+
"license": {
14+
"name": "Apache 2.0",
15+
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
16+
}
17+
},
18+
"host": "petstore.swagger.io",
19+
"basePath": "/api",
20+
"schemes": [
21+
"http"
22+
],
23+
"consumes": [
24+
"application/json"
25+
],
26+
"produces": [
27+
"application/json"
28+
],
29+
"paths": {
30+
"/pets": {
31+
"get": {
32+
"description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n",
33+
"operationId": "findPets",
34+
"parameters": [
35+
{
36+
"name": "tags",
37+
"in": "query",
38+
"description": "tags to filter by",
39+
"required": false,
40+
"type": "array",
41+
"collectionFormat": "csv",
42+
"items": {
43+
"type": "string"
44+
}
45+
},
46+
{
47+
"name": "limit",
48+
"in": "query",
49+
"description": "maximum number of results to return",
50+
"required": false,
51+
"type": "integer",
52+
"format": "int32"
53+
}
54+
],
55+
"responses": {
56+
"200": {
57+
"description": "pet response",
58+
"schema": {
59+
"type": "array",
60+
"items": {
61+
"$ref": "#/definitions/Pet"
62+
}
63+
}
64+
},
65+
"default": {
66+
"description": "unexpected error",
67+
"schema": {
68+
"$ref": "#/definitions/Error"
69+
}
70+
}
71+
}
72+
},
73+
"post": {
74+
"description": "Creates a new pet in the store. Duplicates are allowed",
75+
"operationId": "addPet",
76+
"parameters": [
77+
{
78+
"name": "pet",
79+
"in": "body",
80+
"description": "Pet to add to the store",
81+
"required": true,
82+
"schema": {
83+
"$ref": "#/definitions/NewPet"
84+
}
85+
}
86+
],
87+
"responses": {
88+
"200": {
89+
"description": "pet response",
90+
"schema": {
91+
"$ref": "#/definitions/Pet"
92+
}
93+
},
94+
"default": {
95+
"description": "unexpected error",
96+
"schema": {
97+
"$ref": "#/definitions/Error"
98+
}
99+
}
100+
}
101+
}
102+
},
103+
"/pets/{id}": {
104+
"get": {
105+
"description": "Returns a user based on a single ID, if the user does not have access to the pet",
106+
"operationId": "find pet by id",
107+
"parameters": [
108+
{
109+
"name": "id",
110+
"in": "path",
111+
"description": "ID of pet to fetch",
112+
"required": true,
113+
"type": "integer",
114+
"format": "int64"
115+
}
116+
],
117+
"responses": {
118+
"200": {
119+
"description": "pet response",
120+
"schema": {
121+
"$ref": "#/definitions/Pet"
122+
}
123+
},
124+
"default": {
125+
"description": "unexpected error",
126+
"schema": {
127+
"$ref": "#/definitions/Error"
128+
}
129+
}
130+
}
131+
},
132+
"delete": {
133+
"description": "deletes a single pet based on the ID supplied",
134+
"operationId": "deletePet",
135+
"parameters": [
136+
{
137+
"name": "id",
138+
"in": "path",
139+
"description": "ID of pet to delete",
140+
"required": true,
141+
"type": "integer",
142+
"format": "int64"
143+
}
144+
],
145+
"responses": {
146+
"204": {
147+
"description": "pet deleted"
148+
},
149+
"default": {
150+
"description": "unexpected error",
151+
"schema": {
152+
"$ref": "#/definitions/Error"
153+
}
154+
}
155+
}
156+
}
157+
}
158+
},
159+
"definitions": {
160+
"Pet": {
161+
"type": "object",
162+
"allOf": [
163+
{
164+
"$ref": "#/definitions/NewPet"
165+
},
166+
{
167+
"required": [
168+
"id"
169+
],
170+
"properties": {
171+
"id": {
172+
"type": "integer",
173+
"format": "int64"
174+
}
175+
}
176+
}
177+
]
178+
},
179+
"NewPet": {
180+
"type": "object",
181+
"required": [
182+
"name"
183+
],
184+
"properties": {
185+
"name": {
186+
"type": "string"
187+
},
188+
"tag": {
189+
"type": "string"
190+
}
191+
}
192+
},
193+
"Error": {
194+
"type": "object",
195+
"required": [
196+
"code",
197+
"message"
198+
],
199+
"properties": {
200+
"code": {
201+
"type": "integer",
202+
"format": "int32"
203+
},
204+
"message": {
205+
"type": "string"
206+
}
207+
}
208+
}
209+
}
210+
}

0 commit comments

Comments
 (0)