Skip to content

Add API Documentation for Stellar Wallet Service [wallet - service]Β #141

@salazarsebas

Description

@salazarsebas

πŸ”‘ Add API Documentation for Stellar Wallet Service πŸ› οΈ

πŸ“ Description

Create comprehensive API documentation for all endpoints in the Stellar wallet service using Swagger/OpenAPI. The documentation will cover all existing routes (e.g., authentication, KYC, wallet operations) to provide clear guidance for developers and users, ensuring easy integration and understanding of the API’s functionality.

🎯 Objective

Generate an OpenAPI specification in services/stellar-wallet/docs/api.yaml and integrate Swagger UI to serve interactive documentation at /docs, with a unit test to verify accessibility.

πŸ—‚ Structure

  • Directory: services/stellar-wallet
  • Files:
    • docs/api.yaml
    • src/routes/docs.js
    • tests/routes/docs.test.js
    • package.json (updated)
  • Expected structure:
    services/stellar-wallet
    β”œβ”€β”€ src
    β”‚   β”œβ”€β”€ index.js
    β”‚   β”œβ”€β”€ stellar
    β”‚   β”‚   β”œβ”€β”€ client.js
    β”‚   β”‚   β”œβ”€β”€ keys.js
    β”‚   β”‚   β”œβ”€β”€ fund.js
    β”‚   β”‚   └── sign.js
    β”‚   β”œβ”€β”€ db
    β”‚   β”‚   └── kyc.js
    β”‚   β”œβ”€β”€ routes
    β”‚   β”‚   β”œβ”€β”€ kyc.js
    β”‚   β”‚   β”œβ”€β”€ kyc-verify.js
    β”‚   β”‚   β”œβ”€β”€ kyc-status.js
    β”‚   β”‚   β”œβ”€β”€ auth-register.js
    β”‚   β”‚   β”œβ”€β”€ auth-verify.js
    β”‚   β”‚   β”œβ”€β”€ auth-login.js
    β”‚   β”‚   β”œβ”€β”€ wallet.js
    β”‚   β”‚   └── docs.js
    β”‚   β”œβ”€β”€ kyc
    β”‚   β”‚   └── validate.js
    β”‚   β”œβ”€β”€ soroban
    β”‚   β”‚   β”œβ”€β”€ client.js
    β”‚   β”‚   β”œβ”€β”€ kyc-contract.rs
    β”‚   β”‚   └── deploy.js
    β”‚   β”œβ”€β”€ auth
    β”‚   β”‚   β”œβ”€β”€ webauthn.js
    β”‚   β”‚   └── jwt.js
    β”‚   └── middleware
    β”‚       └── rate-limit.js
    β”œβ”€β”€ config
    β”‚   └── db.sqlite
    β”œβ”€β”€ docs
    β”‚   └── api.yaml
    β”œβ”€β”€ tests
    β”‚   β”œβ”€β”€ stellar
    β”‚   β”‚   β”œβ”€β”€ client.test.js
    β”‚   β”‚   β”œβ”€β”€ keys.test.js
    β”‚   β”‚   β”œβ”€β”€ fund.test.js
    β”‚   β”‚   └── sign.test.js
    β”‚   β”œβ”€β”€ db
    β”‚   β”‚   └── kyc.test.js
    β”‚   β”œβ”€β”€ routes
    β”‚   β”‚   β”œβ”€β”€ kyc.test.js
    β”‚   β”‚   β”œβ”€β”€ kyc-verify.test.js
    β”‚   β”‚   β”œβ”€β”€ kyc-status.test.js
    β”‚   β”‚   β”œβ”€β”€ auth-register.test.js
    β”‚   β”‚   β”œβ”€β”€ auth-verify.test.js
    β”‚   β”‚   β”œβ”€β”€ auth-login.test.js
    β”‚   β”‚   β”œβ”€β”€ wallet.test.js
    β”‚   β”‚   └── docs.test.js
    β”‚   β”œβ”€β”€ kyc
    β”‚   β”‚   └── validate.test.js
    β”‚   β”œβ”€β”€ soroban
    β”‚   β”‚   β”œβ”€β”€ client.test.js
    β”‚   β”‚   └── deploy.test.js
    β”‚   β”œβ”€β”€ auth
    β”‚   β”‚   └── jwt.test.js
    β”‚   └── middleware
    β”‚       └── rate-limit.test.js
    β”œβ”€β”€ package.json
    β”œβ”€β”€ .env.example
    β”œβ”€β”€ .eslintrc.json
    β”œβ”€β”€ .eslintignore
    β”œβ”€β”€ .prettierrc.json
    β”œβ”€β”€ .prettierignore
    β”œβ”€β”€ .gitignore
    

βœ… Requirements

  • Create a branch named feat/api-documentation for this task.
  • Install Swagger dependencies using npm install swagger-ui-express yamljs.
  • Update package.json to include swagger-ui-express and yamljs as dependencies.
  • Create docs/api.yaml to define an OpenAPI 3.0 specification for all API endpoints, including:
    • /auth/register (POST, Issue 17)
    • /auth/verify (POST, Issue 18)
    • /auth/login (POST, Issue 20)
    • /kyc/submit (POST, Issue 9)
    • /kyc/verify (POST, Issue 14)
    • /kyc/status/:id (GET, Issue 15)
    • /wallet/create (POST, Issue 19)
    • /wallet/send (POST, Issue 23)
    • /wallet/transactions/:user_id (GET, Issue 24)
  • Include in api.yaml:
    • Endpoint paths, methods, request/response schemas, and HTTP status codes.
    • Security schemes for JWT authentication (Bearer token) for protected endpoints.
    • Descriptions, parameters, and example responses for each endpoint.
  • Create src/routes/docs.js to serve Swagger UI at /docs using swagger-ui-express, loading the api.yaml specification.
  • Update src/index.js to mount the documentation route at /docs without JWT or rate-limiting middleware.
  • Create a unit test in tests/routes/docs.test.js to verify that the /docs endpoint returns HTTP 200 and serves the Swagger UI.
  • Mock the Express app in the unit test to avoid external dependencies.
  • Ensure the code adheres to ESLint and Prettier rules (from Issue 3).
  • Commit changes to the feat/api-documentation branch with a message like feat: add api documentation.
  • Verify that the CI pipeline (from Issue 1) passes, with linting and test jobs succeeding.

πŸ† Expected Outcomes

  • swagger-ui-express and yamljs are installed and listed in package.json.
  • docs/api.yaml contains a complete OpenAPI 3.0 specification for all API endpoints.
  • src/routes/docs.js serves Swagger UI at /docs, displaying interactive documentation.
  • /docs endpoint is accessible without authentication or rate limiting.
  • Unit test in tests/routes/docs.test.js confirms the /docs endpoint returns HTTP 200.
  • Code passes ESLint and Prettier checks.
  • Changes are committed to the feat/api-documentation branch with a descriptive lowercase commit message.
  • CI pipeline runs successfully, with linting passing for src/routes/docs.js and tests/routes/docs.test.js, and the unit test passing.

πŸ”— References

πŸ“‹ Notes

  • The OpenAPI specification should include detailed schemas for request bodies (e.g., JSON payloads for /kyc/submit) and responses.
  • Use examples in api.yaml to illustrate typical inputs and outputs.
  • The /docs endpoint should be publicly accessible to facilitate developer onboarding.
  • Mocking the Express app in tests ensures reliable CI execution.
  • Commit messages must be in lowercase and start with feat, change, fix, chore, or refactor.
  • The CI pipeline should validate the new code, ensuring ESLint passes and the unit test executes successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    onlydust-waveContribute to awesome OSS repos during OnlyDust's open source week

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions