Skip to content

Commit

Permalink
Add external/plugin docs reference for core API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisreimann committed Nov 2, 2023
1 parent c776cab commit 84fcd59
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
61 changes: 33 additions & 28 deletions setup-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,6 @@ for file in "$DOCS_DIR"/BTCPayServer/*.md; do
update_external "$file" https://github.com/btcpayserver/btcpayserver "$DOCS_DIR"/BTCPayServer/
done

# Checkout latest release tag, so that we do not publish docs for unreleased APIs yet.
git checkout $(git tag --sort -version:refname | awk 'match($0, /^v[0-9]+\.[0-9]+\.[0-9]+$/)' | head -n 1)

# Swagger
if command -v jq >/dev/null 2>&1; then
swagger_file="$PUBLIC_DIR/API/Greenfield/v1/swagger.json"
jq -rs 'def deepmerge(a;b):
reduce b[] as $item (a;
reduce ($item | keys_unsorted[]) as $key (.;
$item[$key] as $val | ($val | type) as $type | .[$key] = if ($type == "object") then
deepmerge({}; [if .[$key] == null then {} else .[$key] end, $val])
elif ($type == "array") then
(.[$key] + $val | unique)
else
$val
end)
);
deepmerge({}; .)' BTCPayServer/wwwroot/swagger/v1/*.json > $swagger_file

# report but don't stop on error
set +e
REDOCLY_TELEMETRY=off npx @redocly/cli lint $swagger_file
set -e
fi

# We need the base file to be able to generate the swagger for the plugins
cp BTCPayServer/wwwroot/swagger/v1/swagger.template.json $BASE_DIR/swagger/plugins/btcpay.json

# NBXplorer

echo "Setup dependency: NBXplorer"
Expand Down Expand Up @@ -325,6 +297,39 @@ for file in "$DOCS_DIR"/Nostr/*.md; do
update_external "$file" https://github.com/Kukks/BTCPayServerPlugins/tree/master/Plugins/BTCPayServer.Plugins.NIP05 "$DOCS_DIR"/Nostr/
done

# Swagger

# BTCPay Swagger: Checkout latest release tag, so that we do not publish docs for unreleased APIs yet

cd "$BTCPAYSERVER_DIR"

git checkout $(git tag --sort -version:refname | awk 'match($0, /^v[0-9]+\.[0-9]+\.[0-9]+$/)' | head -n 1)

# Swagger
if command -v jq >/dev/null 2>&1; then
swagger_file="$PUBLIC_DIR/API/Greenfield/v1/swagger.json"
jq -rs 'def deepmerge(a;b):
reduce b[] as $item (a;
reduce ($item | keys_unsorted[]) as $key (.;
$item[$key] as $val | ($val | type) as $type | .[$key] = if ($type == "object") then
deepmerge({}; [if .[$key] == null then {} else .[$key] end, $val])
elif ($type == "array") then
(.[$key] + $val | unique)
else
$val
end)
);
deepmerge({}; .)' BTCPayServer/wwwroot/swagger/v1/*.json $BASE_DIR/swagger/btcpay.json > $swagger_file

# report but don't stop on error
set +e
REDOCLY_TELEMETRY=off npx @redocly/cli lint $swagger_file
set -e
fi

# We need the base file to be able to generate the swagger for the plugins
cp BTCPayServer/wwwroot/swagger/v1/swagger.template.json $BASE_DIR/swagger/plugins/btcpay.json

# Plugin Swagger

cd $BASE_DIR
Expand Down
6 changes: 6 additions & 0 deletions swagger/btcpay.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"externalDocs": {
"description": "BTCPay Greenfield Plugins API",
"url": "https://docs.btcpayserver.org/API/Greenfield/Plugins/"
}
}

0 comments on commit 84fcd59

Please sign in to comment.