Skip to content

feat: Add comprehensive API documentation with OpenAPI spec#233

Open
wangxiaofei860208-source wants to merge 1 commit intoANAVHEOBA:mainfrom
wangxiaofei860208-source:fix-issue-62
Open

feat: Add comprehensive API documentation with OpenAPI spec#233
wangxiaofei860208-source wants to merge 1 commit intoANAVHEOBA:mainfrom
wangxiaofei860208-source:fix-issue-62

Conversation

@wangxiaofei860208-source
Copy link
Copy Markdown

Summary

This PR adds comprehensive API documentation for the PrivacyLayer privacy pool smart contract, addressing issue #62.

Deliverables

OpenAPI 3.0.3 Specification (docs/openapi.yaml - 650+ lines)

  • All contract endpoints documented (initialize, deposit, withdraw, view functions, admin functions)
  • Complete request/response schemas
  • Error codes and descriptions
  • Authentication requirements
  • Interactive Swagger UI compatible

Postman Collection (docs/postman_collection.json)

  • Ready-to-import collection with all endpoints
  • Environment variables configured
  • Example requests for all operations

Code Examples (docs/examples/typescript-example.ts)

  • TypeScript/JavaScript integration examples
  • Deposit and withdrawal flows
  • View function queries
  • Error handling patterns

Documentation README (docs/README.md)

  • Setup instructions for Swagger UI and Redoc
  • Postman import guide
  • API versioning information
  • Security considerations

API Coverage

Initialization

  • POST /initialize - Initialize the privacy pool

Core Operations

  • POST /deposit - Deposit into shielded pool
  • POST /withdraw - Withdraw using ZK proof

View Functions

  • GET /get_root - Get current Merkle root
  • GET /deposit_count - Get total deposits
  • GET /is_known_root - Check root validity
  • GET /is_spent - Check nullifier status
  • GET /get_config - Get pool configuration

Admin Functions

  • POST /pause - Pause the pool
  • POST /unpause - Unpause the pool
  • POST /set_verifying_key - Update verifying key

Testing

View the OpenAPI spec:

  1. Visit https://editor.swagger.io/
  2. Paste contents of docs/openapi.yaml
  3. Explore interactive documentation

Import Postman collection:

  1. Open Postman
  2. Import docs/postman_collection.json
  3. Configure environment variables

Closes

Closes #62

🤖 Generated with Claude Code

- Add OpenAPI 3.0.3 specification (650+ lines)
- Add Postman collection for API testing
- Add TypeScript/JavaScript code examples
- Add documentation README with setup instructions
- Document all contract methods (initialize, deposit, withdraw, view, admin)
- Include request/response schemas and error codes
- Add interactive Swagger UI instructions

Closes ANAVHEOBA#62

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BOUNTY] Create API Documentation with OpenAPI

1 participant