-
Notifications
You must be signed in to change notification settings - Fork 0
feat(poc): generate tsoa openapi spec on deployment #252
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
59b1ecc
aa6d300
91a5474
6dad576
27f4a34
29fcea6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "position": 5, | ||
| "collapsed": true, | ||
| "collapsible": true, | ||
| "label": "Office API" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [build] | ||
| command = "bash scripts/generate-office-api.sh && yarn clean:api && yarn gen:api && yarn build" | ||
| publish = "build" | ||
|
|
||
| [build.environment] | ||
| NODE_VERSION = "24" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "openapi": "3.0.0", | ||
| "info": { | ||
| "title": "ABsmartly Office API", | ||
| "version": "0.0.0", | ||
| "description": "Auto-generated from the latest release branch. Run scripts/generate-office-api.sh with ABS_REPO_ACCESS_TOKEN to update locally." | ||
| }, | ||
| "paths": {} | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DOCS_DIR="$(pwd)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -z "${ABS_REPO_ACCESS_TOKEN:-}" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "No ABS_REPO_ACCESS_TOKEN set, skipping Office API spec generation" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| REPO_DIR=$(mktemp -d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| trap "rm -rf $REPO_DIR" EXIT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Cloning absmartly/abs..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git clone --no-checkout \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "https://x-access-token:${ABS_REPO_ACCESS_TOKEN}@github.com/absmartly/abs.git" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$REPO_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd "$REPO_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # TODO: Once tsoa is in a release branch, switch to auto-detecting latest release: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # LATEST=$(git branch -r \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | sed 's|origin/||; s/^[[:space:]]*//' \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | grep -E '^release/[0-9]+-[0-9]+$' \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | sed 's|release/||' \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | sort -t'-' -k1,1rn -k2,2rn \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | head -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # BRANCH="release/$LATEST" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BRANCH="vk/d96f-migrate-one-set" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Using branch: $BRANCH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git sparse-checkout set office/backend office/shared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git checkout "$BRANCH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid sourcing the published Office spec from Merging this as-is means the live docs are generated from whatever happens to be on 🛠️ Possible stopgap until auto-detection lands- BRANCH="main"
+ : "${ABS_OFFICE_API_BRANCH:?Set ABS_OFFICE_API_BRANCH to the Office release branch}"
+ BRANCH="$ABS_OFFICE_API_BRANCH"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd office/shared/lib | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| npm ci | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd ../../backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| npm ci --ignore-scripts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| npx tsoa spec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cp src/generated/openapi.json "${DOCS_DIR}/office-api-spec.json" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Office API spec generated successfully from $BRANCH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip only when missing-token generation is explicitly optional.
exit 0here turns a missing or revoked token into a green build. Becauseoffice-api-spec.jsonis committed, the rest of the pipeline can still publish stale or empty Office docs instead of failing loudly. Please only no-op for opt-in cases such as untrusted PRs.🛠️ Possible fix
if [ -z "${ABS_REPO_ACCESS_TOKEN:-}" ]; then - echo "No ABS_REPO_ACCESS_TOKEN set, skipping Office API spec generation" - exit 0 + echo "ABS_REPO_ACCESS_TOKEN is not set" + if [ "${ALLOW_MISSING_OFFICE_API_SPEC:-0}" = "1" ]; then + echo "Skipping Office API spec generation" + exit 0 + fi + exit 1 fi📝 Committable suggestion
🤖 Prompt for AI Agents