Skip to content

Add Pydantic response models for OpenAPI/Swagger docs#10

Open
HaraldeRoessler wants to merge 1 commit intoMoltyCel:mainfrom
HaraldeRoessler:fix/add-response-models
Open

Add Pydantic response models for OpenAPI/Swagger docs#10
HaraldeRoessler wants to merge 1 commit intoMoltyCel:mainfrom
HaraldeRoessler:fix/add-response-models

Conversation

@HaraldeRoessler
Copy link
Copy Markdown
Contributor

Summary

The Swagger docs at /docs show empty response schemas ({}) for all endpoints because no response_model is set on the FastAPI route decorators. This makes it impossible for plugin/SDK developers to know what fields the API returns.

The problem

All three sources tell a different story:

Endpoint API returns Swagger shows Plugin expects
/identity/verify/{did} {did, verified, reputation} {} {did, verified, message, trustScore}
/skill/trust-score/{did} {did, trust_score, grade, breakdown, ...} {} {did, score, grade, sybilRisk}
/reputation/query/{did} {did, score, total_ratings} {} not used

This caused the moltrust-openclaw plugin to show 'undefined' — fixed in MoltyCel/moltrust-openclaw#1.

Changes

Adds Pydantic response models for 6 core endpoints:

  • VerifyResponse for GET /identity/verify/{did}
  • ReputationResponse for GET /reputation/query/{did}
  • TrustScoreResponse + TrustScoreBreakdown for GET /skill/trust-score/{did}
  • DIDDocumentResponse + DIDDocumentMetadata for GET /identity/resolve/{did}
  • HealthResponse for GET /health
  • RateResponse for POST /reputation/rate

Test plan

  • Verify /docs shows populated response schemas
  • Verify endpoints still return correct data

Generated with Claude Code

The OpenAPI/Swagger docs show empty response schemas for all endpoints
because no response_model is set on the FastAPI route decorators.

Adds response models for:
- GET /identity/verify/{did} -> VerifyResponse
- GET /reputation/query/{did} -> ReputationResponse
- GET /skill/trust-score/{did} -> TrustScoreResponse
- GET /identity/resolve/{did} -> DIDDocumentResponse
- GET /health -> HealthResponse
- POST /reputation/rate -> RateResponse

Discovered while debugging moltrust-openclaw plugin showing undefined
(see MoltyCel/moltrust-openclaw#1).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.

1 participant