diff --git a/.gitignore b/.gitignore index 4daa342..a03f8d8 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 8756b1e..bf8fc34 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,15 @@ $(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 +# 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 + cd $(TYPES_PATH)/redocly-mailgun/docs/inboxready/api-reference/ && sed -i '' 's/openapi: 3.1.0/openapi: 3.0.0/' openapi-final.yaml + oapi-codegen -config $(TYPES_PATH)/inboxready_cfg.yaml $(TYPES_PATH)/redocly-mailgun/docs/inboxready/api-reference/openapi-final.yaml + rm -rf $(TYPES_PATH)/redocly-mailgun diff --git a/internal/types/inboxready_cfg.yaml b/internal/types/inboxready_cfg.yaml new file mode 100644 index 0000000..03de987 --- /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: types +output: ./internal/types/inboxready.gen.go +generate: + models: true + client: false diff --git a/internal/types/mailgun_cfg.yaml b/internal/types/mailgun_cfg.yaml new file mode 100644 index 0000000..3250c1c --- /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: types +output: ./internal/types/mailgun.gen.go +generate: + models: true + client: false