Backend API Documentation and OpenAPI Specification#521
Conversation
| ✅ Should be: POST /v0/markets/{marketId}/bets | ||
|
|
||
| ❌ Current: POST /v0/sell | ||
| ✅ Should be: DELETE /v0/markets/{marketId}/positions/{positionId} |
There was a problem hiding this comment.
ELI5 why change POST /v0/sell to an explicit DELETE?
There was a problem hiding this comment.
The whole thing about REST is, everything it is designed to manage is a Resource that can be affected using standard CRUD operations.
POST (as noted below) is used to create a new resource and DELETE is to make the resource no longer available.
Using POST /v0/sell implies that we are creating a new "sell" resource, but sell is not a resource in our data model; it's an action or activity which results in the market position being no longer available. Thus, DELETE makes more sense.
| ✅ Should be: POST /v0/markets | ||
|
|
||
| ❌ Current: POST /v0/resolve/{marketId} | ||
| ✅ Should be: PATCH /v0/markets/{marketId} |
There was a problem hiding this comment.
ELI5 what advantage does PATCH have over POST for market resolution?
There was a problem hiding this comment.
POST Method is used to create a resource.
PATCH Method is used to update a resource.
PUT Method is used to replace a resource.
DELETE Method is used to remove a resource.
This link has some nice info about the differences between them.
There was a problem hiding this comment.
PATCH /v0/markets/{marketId} will update one or more attributes of an existing market. Using POST here would create a new market resource, which is not our goal.
|
@raisch Why use OpenAPI 3.0 and not 3.1? |
|
@ntoufoudis happy to update to 3.1, though 3.0 is what most standards use. |
|
No need to update, just asking. |
|
I expect to update our backend API with the suggestions here, as a 'v1' release. |
Backend API Documentation and OpenAPI Specification
Summary
This PR adds comprehensive API documentation and OpenAPI specification for the SocialPredict backend, improving developer experience and API discoverability.
Changes Made
📚 Documentation Added
Complete OpenAPI 3.0.3 Specification (
openapi.yaml)Developer-Friendly API Documentation (
API-DOCS.md)API Design Analysis Report (
API-DESIGN-REPORT.md)🎯 Key Features
📋 Documentation Structure
Benefits
For Developers
For the Project
For API Consumers
Technical Details
OpenAPI Specification Highlights
API Categories Documented
Design Analysis Findings
Usage
For API Documentation
For Code Generation
# Generate client SDK (example) openapi-generator generate -i README/BACKEND/API/openapi.yaml -g python -o ./client-pythonFor API Testing
Future Work
Based on the design analysis, recommended next steps:
Testing
Breaking Changes
None. This is purely additive documentation work.
Review Notes
Ready for Review ✅
This PR provides the foundation for better API documentation and future API evolution planning.