Skip to content

core: generate OpenAPI/Swagger docs for all endpoints #39

Description

@EmeditWeb

Problem

There is no OpenAPI specification or Swagger UI for the
API. Developers integrating with StepFi must read source
code to understand endpoint shapes, request/response
schemas, and auth requirements.

What To Build

  1. Install @nestjs/swagger and configure SwaggerModule in
    main.ts with title "StepFi API", version from package.json,
    description, and bearer auth scheme.

  2. Add @apitags, @apioperation, @apiresponse decorators to
    every endpoint across all modules:

    • Auth (nonce, verify, refresh)
    • Learners (profile CRUD)
    • Loans (create, list, approve, assess, repay, check-default)
    • Sponsors (portfolio, yield, funded-loans)
    • Vendors (register, approve, dashboard stats, API keys)
    • Admin (parameters, audit logs, protocol stats)
    • Vouching (request, list, approve, revoke)
    • Pool (stats, deposit/withdraw XDR)
    • Health (indexer status, Stellar endpoint health)
    • Indexer (status, replay)
  3. Use @ApiBody, @ApiParam, @apiquery for input schemas.
    Use @ApiBearerAuth() on all protected endpoints.
    Use @ApiOkResponse, @ApiCreatedResponse, @ApiErrorResponse.

  4. Generate typed DTO classes with class-validator decorators
    and expose them via @ApiProperty.

  5. Add GET /docs and GET /docs-json routes:

    • /docs renders Swagger UI
    • /docs-json returns raw OpenAPI spec
  6. In development: enable Swagger UI.
    In production: serve under /docs with basic auth guard
    using DOCS_USERNAME and DOCS_PASSWORD env vars, or
    disable entirely via SWAGGER_ENABLED=false.

Files To Touch

  • src/main.ts
  • All controller files (add decorators)
  • All DTO files (add @ApiProperty)
  • src/common/decorators/api-paginated.decorator.ts (new)
  • src/common/dto/paginated-response.dto.ts (new)

Acceptance Criteria

  • /docs renders interactive Swagger UI
  • /docs-json returns valid OpenAPI 3.0 spec
  • Every endpoint documented with request/response schemas
  • Auth schemes documented (JWT Bearer, X-API-Key)
  • All error responses documented
  • Production access gated behind basic auth
  • npm run build passes

Mandatory Checks Before PR

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions