Skip to content

Conversation

@masaya-osuga
Copy link
Member

Copy link
Contributor

Copilot AI left a 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")
},
},
}
Copy link

Copilot AI Jan 2, 2026

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.

Copilot uses AI. Check for mistakes.
Copy link

@hikaru-0602 hikaru-0602 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@masaya-osuga masaya-osuga merged commit 82ec557 into main Jan 4, 2026
7 checks passed
@masaya-osuga masaya-osuga deleted the refactor/strict-server branch January 4, 2026 13:03
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.

Strict Server化

3 participants