-
Notifications
You must be signed in to change notification settings - Fork 0
Strict server化 #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strict server化 #27
Conversation
masaya-osuga
commented
Jan 2, 2026
- Close Strict Server化 #26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates the announcement API from using the standard OpenAPI server interface to the strict server interface pattern, enabling more type-safe handler implementations and centralizing error handling through generated middleware.
Key Changes
- Enabled strict server generation in the OpenAPI code generator configuration
- Refactored handler method signature to return typed response objects and errors instead of directly writing to the HTTP response
- Updated tests to work with the new request/response object pattern
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| openapi/config.yaml | Enabled strict-server generation in the OpenAPI configuration |
| generated/api.gen.go | Added strict server interface, request/response objects, and middleware implementation |
| internal/handler/announcement.go | Refactored handler to implement StrictServerInterface with typed request/response objects |
| internal/handler/announcement_test.go | Updated tests to use request objects and response visitors, removed gin.Context dependency |
| cmd/server/main.go | Wrapped handler with strict server middleware before registration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert.Contains(t, w.Body.String(), "database connection failed") | ||
| }, | ||
| }, | ||
| } |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test case for error handling has been removed during the migration to strict server. While the strict server middleware in the generated code automatically handles errors by returning HTTP 500 status, the error handling behavior should still be tested to ensure that errors from the service layer are properly propagated and result in the expected HTTP response. Consider adding a test case that verifies the handler correctly returns an error when the service layer fails, even though the final HTTP status code is now set by the middleware.
hikaru-0602
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM