chore: Add automatic api doc generation (#1397)

Fixes: HDX-2888
This commit is contained in:
Tom Alexander 2025-11-21 16:14:02 -05:00 committed by GitHub
parent c1b45abfca
commit e3643ccfc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 1794 additions and 5 deletions

3
.gitignore vendored
View file

@ -35,9 +35,6 @@ packages/app/.vercel
packages/app/coverage packages/app/coverage
packages/app/out packages/app/out
# OpenAPI spec
packages/public/openapi.json
# optional npm cache directory # optional npm cache directory
**/.npm **/.npm

View file

@ -1,4 +1,6 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -e
. "$(dirname -- "$0")/_/husky.sh" . "$(dirname -- "$0")/_/husky.sh"
npx lint-staged npx lint-staged

View file

@ -41,6 +41,11 @@
"release": "npx changeset tag && npx changeset publish" "release": "npx changeset tag && npx changeset publish"
}, },
"lint-staged": { "lint-staged": {
"packages/api/src/routers/external-api/**/*.ts": [
"prettier --write --ignore-unknown",
"eslint --fix --quiet",
"sh -c 'cd packages/api && yarn run docgen && git add openapi.json'"
],
"**/*.{ts,tsx}": [ "**/*.{ts,tsx}": [
"prettier --write --ignore-unknown", "prettier --write --ignore-unknown",
"eslint --fix --quiet" "eslint --fix --quiet"

1785
packages/api/openapi.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@ import swaggerJsdoc from 'swagger-jsdoc';
import { swaggerOptions } from '../src/utils/swagger'; import { swaggerOptions } from '../src/utils/swagger';
const specs = swaggerJsdoc(swaggerOptions); const specs = swaggerJsdoc(swaggerOptions);
const outputPath = path.resolve(__dirname, '../../public/openapi.json'); const outputPath = path.resolve(__dirname, '../openapi.json');
fs.mkdirSync(path.dirname(outputPath), { recursive: true }); fs.mkdirSync(path.dirname(outputPath), { recursive: true });
fs.writeFileSync(outputPath, JSON.stringify(specs, null, 2)); fs.writeFileSync(outputPath, JSON.stringify(specs, null, 2));

View file

@ -64,7 +64,7 @@ export function setupSwagger(app: Application) {
}); });
// Optionally save the spec to a file // Optionally save the spec to a file
const outputPath = path.resolve(__dirname, '../../../public/openapi.json'); const outputPath = path.resolve(__dirname, '../../openapi.json');
fs.mkdirSync(path.dirname(outputPath), { recursive: true }); fs.mkdirSync(path.dirname(outputPath), { recursive: true });
fs.writeFileSync(outputPath, JSON.stringify(specs, null, 2)); fs.writeFileSync(outputPath, JSON.stringify(specs, null, 2));
} }