Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DE-1138 Generate models #370

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading