Skip to content

[backend] Swagger / OpenAPI Documentation for All Endpoints #24

Description

@josueazc

DESCRIPTION

The NestJS API has no auto-generated documentation. Contributors and frontend developers must read raw TypeScript source to discover available endpoints, required headers, request bodies, and response shapes. NestJS ships with @nestjs/swagger which generates an interactive Swagger UI and an openapi.json spec from decorators — zero separate doc-writing required.

GOAL

A Swagger UI is served at /api/docs when the API runs locally. Every endpoint shows its HTTP method, path, required auth, request body schema, and possible response codes. Developers can explore and test the API from the browser without reading source code.

REQUIREMENTS

  • Install @nestjs/swagger and swagger-ui-express in apps/api
  • Bootstrap the SwaggerModule in apps/api/src/main.ts with project metadata (title: VELAR API, version, description)
  • Mount the UI at /api/docs (only in non-production environments)
  • Add @ApiTags() to every controller: auth, bonds, transfers, audit, users, parties, reports
  • Add @ApiBearerAuth() to every controller or route guarded by AuthGuard
  • Decorate the main DTOs / input classes with @ApiProperty() so request body schemas appear in the UI:
    • RegisterDto (or current RegisterInput)
    • RegisterBondInput and BondRequestInput from @velar/types
  • Add @ApiResponse() on at least the most important responses (200, 201, 400, 401, 403)
  • Export the openapi.json spec as a static file under apps/api/public/openapi.json so it can be consumed by external tools

ACCEPTANCE CRITERIA

  • GET /api/docs returns the Swagger UI when running npm run start:dev in apps/api
  • All controllers appear as tagged sections in the UI
  • Authenticated routes show the lock icon and require a Bearer token to be tested
  • Request body schemas for /auth/register and /bonds are fully described (no {} body)
  • npm run build passes in apps/api
  • npm run lint without new errors
  • Swagger UI is not exposed in production (NODE_ENV === 'production' guard in main.ts)

NOTES

Relevant files: apps/api/src/main.ts, apps/api/src/auth/auth.controller.ts, apps/api/src/bonds/bonds.controller.ts, apps/api/src/transfers/transfers.controller.ts, apps/api/src/audit/audit.controller.ts.
Reference: https://docs.nestjs.com/openapi/introduction

Good first task — no blockchain or Stellar knowledge required. Purely additive change with no risk of breaking existing behavior.


Difficulty: Beginner
Priority: Medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions