Skip to content

Commit e25ecef

Browse files
authored
bugfix: prevent the authroity's File object definition from clobbering ffs' (#128)
1 parent eb7d86e commit e25ecef

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ DOCS_SRC = docs-src
33
DOCS = $(DOCS_SRC)/docs
44
DOCS_OUT = $(DOCS_SRC)/out
55
API_DOCS = $(BUILD)/api
6-
DOCS_SERVER := "http://localhost:5000" # Use this value as the docserver for a locally hosted baldur instance
7-
# DOCS_SERVER := "http://localhost:8080" # Use this value as the docserver for a locally hosted api gateway instance
6+
DOCS_SERVER = "https://api.us.code42.com" # Use this value to run against production api-gateway
7+
#DOCS_SERVER := "http://localhost:5000" # Use this value as the docserver for a locally hosted baldur instance
8+
#DOCS_SERVER := "http://localhost:8080" # Use this value as the docserver for a locally hosted api-gateway instance
89
BUILD_SCRIPTS = build-scripts
910

1011
all:: clean docs html locations download transform definitions unify

build-scripts/transform.sh

+13-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ main() {
44
local docs="${1:?Missing param docs at index 1.}"
55
TMP=.transform.tmp
66
ALERTS="${docs}/alerts"
7+
AUTHORITY="${docs}/authority.json"
78
RULES_V1="${docs}/alert-rules"
89
RULES_V2="${docs}/alert-rules-v2"
910
TRUSTED_ACTIVITIES_V2="${docs}/trusted-activities.json"
@@ -16,14 +17,21 @@ main() {
1617
### Audit log
1718
echo "Transforming Audit Log docs..."
1819
api-spec-converter -f openapi_3 -t swagger_2 -c ${docs}/audit > ${docs}/audit.json
20+
rm ${docs}/audit
1921

2022
### Authority
2123
echo "Transforming Authority docs..."
22-
# The new api gateway lists the authority docs as "Authority" while Baldur lists them as "Core"
23-
# This "if" check can be removed after Baldur has been removed
24-
if [ -f "${docs}"/authority ]; then
25-
api-spec-converter -f openapi_3 -t swagger_2 -c ${docs}/authority > ${docs}/authority.json
26-
fi
24+
api-spec-converter -f openapi_3 -t swagger_2 -c ${docs}/authority > $AUTHORITY
25+
# The authority's File component schema overwrites FFS', rename it
26+
### SWAGGER 2 ###
27+
jq '.definitions |= with_entries( if .key == "File" then .key |= "AuthorityFile" else . end)' < $AUTHORITY > $TMP && mv $TMP $AUTHORITY
28+
jq '.definitions.RestoreGroup.properties.files.items."$ref" |= "#/definitions/AuthorityFile"' < $AUTHORITY > $TMP && mv $TMP $AUTHORITY
29+
30+
### OPENAPI 3 ###
31+
# jq '.components.schemas |= with_entries( if .key == "File" then .key |= "AuthorityFile" else . end)' < ${docs}/authority > $AUTHORITY
32+
# jq '.components.schemas.RestoreGroup.properties.files.items."$ref" |= "#/components/schemas/AuthorityFile"' < $AUTHORITY > $TMP && mv $TMP $AUTHORITY
33+
34+
rm ${docs}/authority
2735

2836
### Trusted Activities v2
2937
echo "Transforming Trusted Activities docs..."

0 commit comments

Comments
 (0)