Add a `GET /api/v1/openapi.json` endpoint and remove the need for a build-time export to read the spec
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- github-actions, nodejs, openapi, typescript
- Domain
- backend-api-design, ci-cd
Research direction
Start with scripts/export-openapi.ts to see how the app is booted to build the spec, then with the document builder setup in src/main.ts. The CI stubs are at .github/workflows/build-check.yml lines 47-53. Done means /docs/openapi.json returns the same spec that npm run openapi:export writes, Swagger UI is off in production by default, and CI runs without fake DATABASE_URL and JWT_SECRET values.
Written by the indexing model from the issue text.
Description
Problem
The OpenAPI spec is only obtainable by running a build-time export script:
npm run openapi:export # scripts/export-openapi.ts, requires NODE_ENV and a bootable app
npm run openapi:validate # scripts/validate-openapi.ts
scripts/export-openapi.ts has to boot the Nest application, which is why CI has to supply DATABASE_URL, JWT_SECRET and PORT just to produce a spec (.github/workflows/build-check.yml:47-53), with the comment that the script "boots with abortOnError:false so it tolerates DB absence". Meanwhile there is no runtime route that serves the spec.
@nestjs/swagger v7 is already a dependency and the document builder is presumably configured in src/main.ts, which means the spec exists in memory at runtime — it is simply not exposed.
Why it matters
Anyone wanting to generate a client, inspect the API, or write an integration must clone the repo, install dependencies, and run a script that pretends to be a server. That is a significant barrier for an SDK-publishing project whose README advertises the spec at /docs/openapi.json — a path that does not currently exist at runtime.
The CI workaround is also a smell: the spec generation needs a fake database URL, which means a malformed environment produces a silently incomplete spec rather than a clear failure.
Suggested Direction
- Expose the document builder's output.
@nestjs/swaggergenerates the spec once the app has started. Either serve the pre-builtdocs/openapi.jsonas a static asset, or build the document without booting the full application (create an application context rather than a full app, if the version supports it — this avoids the database problem entirely). - Serve it at a stable URL, matching what the README already claims —
/docs/openapi.json— and serve Swagger UI alongside it.swagger-ui-expressandserve-faviconare already dependencies, so check whether UI setup exists. - Restrict in production. An unauthenticated, always-current spec is an information leak about internal routes. Gate it behind an env flag or restrict to non-production, consistent with how the README treats other internal endpoints.
- Simplify CI once the spec no longer needs a booted app — remove the
DATABASE_URL/JWT_SECRETstubs from.github/workflows/build-check.ymland letopenapi:exportrun cleanly.
Constraints
- The generated spec must stay byte-comparable with what the SDK pipeline consumes, or the published SDKs change shape.
- The spec is generated from controller decorators, so it inherits the existing gaps — 377 routes carry only 209
@ApiResponsedecorators. Do not fix that here; see the OpenAPI-documentation issue. - Swagger UI must not be exposed publicly by default.
Acceptance Criteria
- The OpenAPI spec is reachable at a documented URL without running an export script.
-
npm run openapi:exportstill produces a spec identical to the served one. - Swagger UI is available and gated appropriately for production.
- CI no longer needs fake database credentials to generate the spec.
- The README's
/docs/openapi.jsonclaim is now accurate.
- Dominant language
- TypeScript
- Stars
- 7
- Forks
- 55
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SourceXXL/alian_structure-api
-
good first issue help wanted security
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SourceXXL/alian_structure-api#266 ·
-
Parallelize the cache-warming loop in `cache-warming.service.ts` — warmers run strictly sequentiallyMay be free again @syntaxsuuvam-spec claimed this 16 days ago, and no pull request is open. Opengood first issue performance
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SourceXXL/alian_structure-api#240 ·
-
documentation help wanted intermediate refactor
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
SourceXXL/alian_structure-api#215 ·
-
good first issue refactor tooling
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
SourceXXL/alian_structure-api#199 ·
-
help wanted intermediate refactor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SourceXXL/alian_structure-api#196 ·
All issues in SourceXXL/alian_structure-api
Similar issues
-
verified
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anomalyco/opencode#59589 · 1 comment ·
Maintainers usually reply within 1 day
-
Bug: During run init command, finish the git initialize process without question to user('Initialize a new git repository?')Possibly taken @nishu-murmu claimed this today. Openpending-triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wxt-dev/wxt#2697 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
knaw-huc/textannoviz#739 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day