File tree Expand file tree Collapse file tree 1 file changed +18
-25
lines changed Expand file tree Collapse file tree 1 file changed +18
-25
lines changed Original file line number Diff line number Diff line change 3
3
set -o errexit
4
4
set -o pipefail
5
5
6
+ command -v swagger > /dev/null 2>&1 || { echo >&2 " swagger not installed. Aborting." ; exit 1; }
6
7
command -v yq > /dev/null 2>&1 || { echo >&2 " yq not installed. Aborting." ; exit 1; }
7
8
command -v jq > /dev/null 2>&1 || { echo >&2 " jq not installed. Aborting." ; exit 1; }
8
9
@@ -11,30 +12,22 @@ CN_COMMIT=$(go list -m github.com/haproxytech/client-native/v3 | sed 's/^.*-//')
11
12
if [ -z " $1 " ]; then echo >&2 " No model name supplied. Aborting." ; exit 1; fi
12
13
if [ -z " $CN_COMMIT " ]; then echo >&2 " Unable to get git commit for CN module. Aborting." ; exit 1; fi
13
14
14
- curl -sk https://raw.githubusercontent.com/haproxytech/client-native/$CN_COMMIT /specification/models/configuration .yaml |
15
+ swagger expand https://raw.githubusercontent.com/haproxytech/client-native/$CN_COMMIT /specification/build/haproxy_spec .yaml |
15
16
yq |
16
- jq --arg MODEL $1 ' .|
17
- reduce paths as $p(.;
18
- if $p[0] == $MODEL and $p[-1] == "$ref" then
19
- setpath($p[0:-1];getpath(getpath($p) | split("/")[-1]| split(" ")))
20
- else
21
- .
22
- end
23
- ) |
24
- .[$MODEL] |
25
- walk(
26
- if type == "object" then with_entries(
27
- if .key == "x-nullable" then
28
- if .value == false then
29
- empty
30
- else
31
- .key = "nullable"
32
- end
33
- elif (.key | contains("x-")) then
34
- empty
35
- else
36
- .
37
- end
38
- ) else . end
39
- )' |
17
+ jq --arg MODEL $1 ' .["definitions"][$MODEL]|
18
+ walk(
19
+ if type == "object" then with_entries(
20
+ if .key == "x-nullable" then
21
+ if .value == false then
22
+ empty
23
+ else
24
+ .key = "nullable"
25
+ end
26
+ elif (.key | contains("x-")) then
27
+ empty
28
+ else
29
+ .
30
+ end
31
+ ) else . end
32
+ )' |
40
33
yq -y
You can’t perform that action at this time.
0 commit comments