From e8d7056ea95d8a0cf9aa0fcbb7bfc0591e940fbd Mon Sep 17 00:00:00 2001 From: Phong Thieu Date: Thu, 14 Sep 2023 14:20:35 -0400 Subject: [PATCH 1/2] Upgrade to openapi-generator@7 --- .openapi-generator/VERSION | 2 +- cmd/server/main.go | 8 ++++---- internal/service/api_email_service.go | 12 ++++++------ internal/service/api_health_service.go | 2 +- internal/service/api_notification_service.go | 2 +- internal/service/api_sms_service.go | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION index cd802a1..4122521 100644 --- a/.openapi-generator/VERSION +++ b/.openapi-generator/VERSION @@ -1 +1 @@ -6.6.0 \ No newline at end of file +7.0.0 \ No newline at end of file diff --git a/cmd/server/main.go b/cmd/server/main.go index 7fc7b22..9d16b5f 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -46,16 +46,16 @@ func main() { go heartbeat() EmailApiService := service.NewEmailApiService(config) - EmailApiController := server.NewEmailApiController(EmailApiService) + EmailApiController := server.NewEmailAPIController(EmailApiService) SmsApiService := service.NewSmsApiService(config) - SmsApiController := server.NewSmsApiController(SmsApiService) + SmsApiController := server.NewSmsAPIController(SmsApiService) HealthApiService := service.NewHealthApiService(config) - HealthApiController := server.NewHealthApiController(HealthApiService) + HealthApiController := server.NewHealthAPIController(HealthApiService) NotificationApiService := service.NewNotificationApiService(config) - NotificationApiController := server.NewNotificationApiController(NotificationApiService) + NotificationApiController := server.NewNotificationAPIController(NotificationApiService) router := server.NewRouter(EmailApiController, SmsApiController, HealthApiController, NotificationApiController) diff --git a/internal/service/api_email_service.go b/internal/service/api_email_service.go index d3ea438..3681135 100644 --- a/internal/service/api_email_service.go +++ b/internal/service/api_email_service.go @@ -20,7 +20,7 @@ type EmailApiService struct { } // NewEmailApiService creates a default api service -func NewEmailApiService(c *config.Config) server.EmailApiServicer { +func NewEmailApiService(c *config.Config) server.EmailAPIServicer { return &EmailApiService{c} } @@ -82,19 +82,19 @@ func (s *EmailApiService) SendBulk(ctx context.Context, sendBulkMailRequest serv mail.SendBulkMail(sendBulkMailRequest.ToAddresses, sendBulkMailRequest.FromAddress, sendBulkMailRequest.CcAddresses, sendBulkMailRequest.BccAddresses, sendBulkMailRequest.Headers, sendBulkMailRequest.Message, client, responseChannel) - var successful []server.SendBulkMailResponseSuccessful - var failed []server.SendBulkMailResponseFailed + var successful []server.SendBulkMailResponseSuccessfulInner + var failed []server.SendBulkMailResponseFailedInner // Read all the responses from the channel. This will block if responses aren't ready and the channel is not yet closed for r := range responseChannel { if r.Error != nil { zap.S().Errorf("Error sending bulk mail: %v", r.Error) - failed = append(failed, server.SendBulkMailResponseFailed{EmailAddress: r.EmailAddress, Error: fmt.Sprintf("Unable to send email: %v\n", r.Error)}) + failed = append(failed, server.SendBulkMailResponseFailedInner{EmailAddress: r.EmailAddress, Error: fmt.Sprintf("Unable to send email: %v\n", r.Error)}) } else if !(r.Response.StatusCode >= 200 && r.Response.StatusCode <= 299) { zap.S().Errorf("Failure from Sendgrid when sending bulk mail: %v", r.Response) - failed = append(failed, server.SendBulkMailResponseFailed{EmailAddress: r.EmailAddress, Error: fmt.Sprintf("Unable to send email: %v from mail provider: %v\n", r.Response.StatusCode, r.Response.Body)}) + failed = append(failed, server.SendBulkMailResponseFailedInner{EmailAddress: r.EmailAddress, Error: fmt.Sprintf("Unable to send email: %v from mail provider: %v\n", r.Response.StatusCode, r.Response.Body)}) } else { - successful = append(successful, server.SendBulkMailResponseSuccessful{EmailAddress: r.EmailAddress, TrackingId: r.Response.Headers["X-Message-Id"][0]}) + successful = append(successful, server.SendBulkMailResponseSuccessfulInner{EmailAddress: r.EmailAddress, TrackingId: r.Response.Headers["X-Message-Id"][0]}) } } responseCode := http.StatusOK diff --git a/internal/service/api_health_service.go b/internal/service/api_health_service.go index fb3101c..f039056 100644 --- a/internal/service/api_health_service.go +++ b/internal/service/api_health_service.go @@ -16,7 +16,7 @@ type HealthApiService struct { } // NewHealthApiService creates a default api service -func NewHealthApiService(c *config.Config) server.HealthApiServicer { +func NewHealthApiService(c *config.Config) server.HealthAPIServicer { return &HealthApiService{c} } diff --git a/internal/service/api_notification_service.go b/internal/service/api_notification_service.go index f06104c..f8807f7 100644 --- a/internal/service/api_notification_service.go +++ b/internal/service/api_notification_service.go @@ -20,7 +20,7 @@ type NotificationApiService struct { } // NewNotificationApiService creates a default api service -func NewNotificationApiService(c *config.Config) server.NotificationApiServicer { +func NewNotificationApiService(c *config.Config) server.NotificationAPIServicer { return &NotificationApiService{c} } diff --git a/internal/service/api_sms_service.go b/internal/service/api_sms_service.go index aa9d9ce..6cd7823 100644 --- a/internal/service/api_sms_service.go +++ b/internal/service/api_sms_service.go @@ -21,7 +21,7 @@ type SmsApiService struct { } // NewSmsApiService creates a default api service -func NewSmsApiService(c *config.Config) server.SmsApiServicer { +func NewSmsApiService(c *config.Config) server.SmsAPIServicer { return &SmsApiService{c} } From 69abb128372e19a486ef19b89f53aeb028f6ee0a Mon Sep 17 00:00:00 2001 From: David Cheung Date: Thu, 14 Sep 2023 15:08:29 -0400 Subject: [PATCH 2/2] fixup! Upgrade to openapi-generator@7 --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d88fcce..12586b6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -27,7 +27,7 @@ jobs: - name: Generate code run: | - docker run --rm -v ${GITHUB_WORKSPACE}:/local openapitools/openapi-generator:cli-5.3.x generate -i /local/api/notification-service.yaml -g go-server -o /local/ -p sourceFolder=internal/server -p packageName=server --git-user-id=commitdev --git-repo-id=zero-notification-service + docker run --rm -v ${GITHUB_WORKSPACE}:/local openapitools/openapi-generator-cli:v7.0.0 generate -i /local/api/notification-service.yaml -g go-server -o /local/ -p sourceFolder=internal/server -p packageName=server --git-user-id=commitdev --git-repo-id=zero-notification-service sudo chmod -R a+rw ${GITHUB_WORKSPACE} go install golang.org/x/tools/cmd/goimports@latest goimports -w ${GITHUB_WORKSPACE}/internal/server/