Skip to content

bugfix authority docs #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ DOCS_SRC = docs-src
DOCS = $(DOCS_SRC)/docs
DOCS_OUT = $(DOCS_SRC)/out
API_DOCS = $(BUILD)/api
DOCS_SERVER := "http://localhost:5000" # Use this value as the docserver for a locally hosted baldur instance
# DOCS_SERVER := "http://localhost:8080" # Use this value as the docserver for a locally hosted api gateway instance
DOCS_SERVER = "https://api.us.code42.com" # Use this value to run against production api-gateway
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this gets set by the developer portal deployment repo, for core-int + prod:
https://stash.corp.code42.com/projects/DT/repos/developer-portal-deployment/browse/terraform/main.tf#108

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im curious if this is set explicitly here, if that passed in param value from the developer portal deployment will still work? Suppose it would also be nice to throw a comment in this location saying ^ that

#DOCS_SERVER := "http://localhost:5000" # Use this value as the docserver for a locally hosted baldur instance
#DOCS_SERVER := "http://localhost:8080" # Use this value as the docserver for a locally hosted api-gateway instance
BUILD_SCRIPTS = build-scripts

all:: clean docs html locations download transform definitions unify
Expand Down
18 changes: 13 additions & 5 deletions build-scripts/transform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ main() {
local docs="${1:?Missing param docs at index 1.}"
TMP=.transform.tmp
ALERTS="${docs}/alerts"
AUTHORITY="${docs}/authority.json"
RULES_V1="${docs}/alert-rules"
RULES_V2="${docs}/alert-rules-v2"
TRUSTED_ACTIVITIES_V2="${docs}/trusted-activities.json"
Expand All @@ -16,14 +17,21 @@ main() {
### Audit log
echo "Transforming Audit Log docs..."
api-spec-converter -f openapi_3 -t swagger_2 -c ${docs}/audit > ${docs}/audit.json
rm ${docs}/audit

### Authority
echo "Transforming Authority docs..."
# The new api gateway lists the authority docs as "Authority" while Baldur lists them as "Core"
# This "if" check can be removed after Baldur has been removed
if [ -f "${docs}"/authority ]; then
api-spec-converter -f openapi_3 -t swagger_2 -c ${docs}/authority > ${docs}/authority.json
fi
api-spec-converter -f openapi_3 -t swagger_2 -c ${docs}/authority > $AUTHORITY
# The authority's File component schema overwrites FFS', rename it
### SWAGGER 2 ###
jq '.definitions |= with_entries( if .key == "File" then .key |= "AuthorityFile" else . end)' < $AUTHORITY > $TMP && mv $TMP $AUTHORITY
jq '.definitions.RestoreGroup.properties.files.items."$ref" |= "#/definitions/AuthorityFile"' < $AUTHORITY > $TMP && mv $TMP $AUTHORITY

### OPENAPI 3 ###
# jq '.components.schemas |= with_entries( if .key == "File" then .key |= "AuthorityFile" else . end)' < ${docs}/authority > $AUTHORITY
# jq '.components.schemas.RestoreGroup.properties.files.items."$ref" |= "#/components/schemas/AuthorityFile"' < $AUTHORITY > $TMP && mv $TMP $AUTHORITY

rm ${docs}/authority

### Trusted Activities v2
echo "Transforming Trusted Activities docs..."
Expand Down
Loading