Skip to content

Commit 8ab33a4

Browse files
committed
add Makefile
1 parent afbe47c commit 8ab33a4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
all: openapi.json openapi.min.json
2+
3+
clean:
4+
rm -f *.json
5+
6+
# This is the "extract" set of endpoints
7+
openapi-extract.json:
8+
curl -o openapi-extract.json https://docs.diffbot.com/openapi/638975592e00230010aaaa39
9+
10+
# The verbatim OpenAPI spec has a couple of issues:
11+
#
12+
# * It uses version 3.1.0 of the OpenAPI standard, but tooling only supports 3.0.x
13+
# * Its array items schema types use array instead of object (no idea why)
14+
# * It has an incompletely-specified "/{api}" endpoint
15+
#
16+
# We use jq to clean these issues up.
17+
#
18+
# Also, we're only handling the "extract" OpenAPI spec at this time.
19+
openapi.json: openapi-extract.json
20+
cat openapi-extract.json | jq 'walk(if (.|type) == "object" and .items? and (.items|type) == "array" then .items = .items[0] else . end)|del(.paths["/{api}"])|.openapi="3.0.2"' >openapi.json
21+
22+
# Create a minified version, while we're in here
23+
openapi.min.json: openapi.json
24+
cat openapi.json | jq -c >openapi.min.json
25+

0 commit comments

Comments
 (0)