From 76eae908485ffdd41e188bd953b1c21adfc40c52 Mon Sep 17 00:00:00 2001 From: Vilen Topchii <32271530+vtopc@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:27:45 +0200 Subject: [PATCH] DE-1138 Generate models (#370) --- .gitignore | 2 ++ Makefile | 18 ++++++++++++++++++ internal/types/inboxready/.gitkeep | 0 internal/types/inboxready_cfg.yaml | 6 ++++++ internal/types/mailgun/.gitkeep | 0 internal/types/mailgun_cfg.yaml | 6 ++++++ internal/types/validate/.gitkeep | 0 internal/types/validate_cfg.yaml | 6 ++++++ 8 files changed, 38 insertions(+) create mode 100644 internal/types/inboxready/.gitkeep create mode 100644 internal/types/inboxready_cfg.yaml create mode 100644 internal/types/mailgun/.gitkeep create mode 100644 internal/types/mailgun_cfg.yaml create mode 100644 internal/types/validate/.gitkeep create mode 100644 internal/types/validate_cfg.yaml diff --git a/.gitignore b/.gitignore index 4daa3427..a03f8d81 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .idea/ cmd/mailgun/mailgun /.env + +/internal/types/redocly-mailgun/ diff --git a/Makefile b/Makefile index 8756b1ee..ff1afe52 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ PACKAGE := github.com/mailgun/mailgun-go GOPATH=$(shell go env GOPATH) +TYPES_PATH=./internal/types NILAWAY = $(GOPATH)/bin/nilaway $(NILAWAY): @@ -36,3 +37,20 @@ $(GOLINT): .PHONY: lint lint: $(GOLINT) $(GOLINT) run + +# go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest +# +# mailgun/api-reference/openapi-final.yaml fails due to interface{} fields +# # generate mailgun models +# cd $(TYPES_PATH)/redocly-mailgun/docs/mailgun/api-reference/ && sed -i '' 's/openapi: 3.1.0/openapi: 3.0.0/' openapi-final.yaml +# oapi-codegen -config $(TYPES_PATH)/mailgun_cfg.yaml $(TYPES_PATH)/redocly-mailgun/docs/mailgun/api-reference/openapi-final.yaml +.PHONY: gen-models +gen-models: + cd $(TYPES_PATH) && git clone --depth 1 git@github.com:mailgun/redocly-mailgun.git + # generate inboxready models + sed -i '' 's/openapi: 3.1.0/openapi: 3.0.0/' $(TYPES_PATH)/redocly-mailgun/docs/inboxready/api-reference/openapi-final.yaml + oapi-codegen -config $(TYPES_PATH)/inboxready_cfg.yaml $(TYPES_PATH)/redocly-mailgun/docs/inboxready/api-reference/openapi-final.yaml + # generate validate models + sed -i '' 's/openapi: 3.1.0/openapi: 3.0.0/' $(TYPES_PATH)/redocly-mailgun/docs/inboxready/api-reference/openapi-validate-final.yaml + oapi-codegen -config $(TYPES_PATH)/validate_cfg.yaml $(TYPES_PATH)/redocly-mailgun/docs/inboxready/api-reference/openapi-validate-final.yaml + rm -rf $(TYPES_PATH)/redocly-mailgun diff --git a/internal/types/inboxready/.gitkeep b/internal/types/inboxready/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/internal/types/inboxready_cfg.yaml b/internal/types/inboxready_cfg.yaml new file mode 100644 index 00000000..5b0b0143 --- /dev/null +++ b/internal/types/inboxready_cfg.yaml @@ -0,0 +1,6 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/HEAD/configuration-schema.json +package: inboxready +output: ./internal/types/inboxready/model.gen.go +generate: + models: true + client: false diff --git a/internal/types/mailgun/.gitkeep b/internal/types/mailgun/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/internal/types/mailgun_cfg.yaml b/internal/types/mailgun_cfg.yaml new file mode 100644 index 00000000..c58873d0 --- /dev/null +++ b/internal/types/mailgun_cfg.yaml @@ -0,0 +1,6 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/HEAD/configuration-schema.json +package: mailgun +output: ./internal/types/mailgun/model.gen.go +generate: + models: true + client: false diff --git a/internal/types/validate/.gitkeep b/internal/types/validate/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/internal/types/validate_cfg.yaml b/internal/types/validate_cfg.yaml new file mode 100644 index 00000000..529f2db6 --- /dev/null +++ b/internal/types/validate_cfg.yaml @@ -0,0 +1,6 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/HEAD/configuration-schema.json +package: validate +output: ./internal/types/validate/model.gen.go +generate: + models: true + client: false