Skip to content

Commit

Permalink
DE-1138 Generate models (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtopc authored Dec 18, 2024
1 parent 4190c05 commit 76eae90
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.idea/
cmd/mailgun/mailgun
/.env

/internal/types/redocly-mailgun/
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

PACKAGE := github.com/mailgun/mailgun-go
GOPATH=$(shell go env GOPATH)
TYPES_PATH=./internal/types

NILAWAY = $(GOPATH)/bin/nilaway
$(NILAWAY):
Expand Down Expand Up @@ -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 [email protected]: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
Empty file.
6 changes: 6 additions & 0 deletions internal/types/inboxready_cfg.yaml
Original file line number Diff line number Diff line change
@@ -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
Empty file added internal/types/mailgun/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions internal/types/mailgun_cfg.yaml
Original file line number Diff line number Diff line change
@@ -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
Empty file.
6 changes: 6 additions & 0 deletions internal/types/validate_cfg.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 76eae90

Please sign in to comment.