File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ openapi-extract.json:
21
21
#
22
22
# Also, we're only handling the "extract" OpenAPI spec at this time.
23
23
openapi.json : openapi-extract.json
24
- 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.3" ' > openapi.json
24
+ cat openapi-extract.json | jq -f extract.jq > openapi.json
25
25
26
26
# Create a minified version, while we're in here
27
27
openapi.min.json : openapi.json
Original file line number Diff line number Diff line change
1
+ # This jq file is used to process openapi-extract.json into a proper
2
+ # OpenAPI spec.
3
+
4
+ # This "spec" has array items as a list instead of an object. I have
5
+ # no idea why. Here, we walk the whole spec and replace any entry with
6
+ # key "items" and an array value with the first element of the array.
7
+ walk (if (.| type ) == "object" and .items ? and (.items | type ) == "array" then .items = .items [0 ] else . end )
8
+
9
+ # The "/{api}" path is underspecified. It's custom anyway. Just get
10
+ # rid of it.
11
+ | del (.paths ["/{api}" ])
12
+
13
+ # The various analyze endpoints are missing an important field in
14
+ # their response, "resolvedPageUrl". Add it.
15
+ | .paths ["/analyze" ].get.responses ["200" ].content ["application/json" ].schema.properties.objects.items.properties.resolvedPageUrl = {"type" : "string" }
16
+ | .paths ["/article" ].get.responses ["200" ].content ["application/json" ].schema.properties.objects.items.properties.resolvedPageUrl = {"type" : "string" }
17
+ | .paths ["/product" ].get.responses ["200" ].content ["application/json" ].schema.properties.objects.items.properties.resolvedPageUrl = {"type" : "string" }
18
+ | .paths ["/discussion" ].get.responses ["200" ].content ["application/json" ].schema.properties.objects.items.properties.resolvedPageUrl = {"type" : "string" }
19
+ | .paths ["/job" ].get.responses ["200" ].content ["application/json" ].schema.properties.objects.items.properties.resolvedPageUrl = {"type" : "string" }
20
+ | .paths ["/image" ].get.responses ["200" ].content ["application/json" ].schema.properties.objects.items.properties.resolvedPageUrl = {"type" : "string" }
21
+ | .paths ["/video" ].get.responses ["200" ].content ["application/json" ].schema.properties.objects.items.properties.resolvedPageUrl = {"type" : "string" }
22
+ | .paths ["/list" ].get.responses ["200" ].content ["application/json" ].schema.properties.objects.items.properties.resolvedPageUrl = {"type" : "string" }
23
+ | .paths ["/event" ].get.responses ["200" ].content ["application/json" ].schema.properties.objects.items.properties.resolvedPageUrl = {"type" : "string" }
24
+
25
+ # This "spec" is v3.1.0, but tooling only really takes v3.0.x at the
26
+ # moment. Just rewrite the version.
27
+ | .openapi = "3.0.3"
You can’t perform that action at this time.
0 commit comments