Skip to content

Commit

Permalink
Upgrade OpenAPI Codegen (#10)
Browse files Browse the repository at this point in the history
v1 is deprecated so we need to upgrade to v2 in order to avoid a bunch
of warnings all over the show.
  • Loading branch information
spjmurray authored Oct 31, 2024
1 parent b3dc4ad commit db4c3e0
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 93 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CONTROLLER_TOOLS_VERSION=v0.16.3
# This should be kept in sync with the Kubenetes library versions defined in go.mod.
CODEGEN_VERSION=v0.27.3

OPENAPI_CODEGEN_VERSION=v1.16.2
OPENAPI_CODEGEN_VERSION=v2.4.1
OPENAPI_CODEGEN_FLAGS=-package openapi -config pkg/openapi/config.yaml
OPENAPI_SCHEMA=pkg/openapi/server.spec.yaml
OPENAPI_FILES = \
Expand Down Expand Up @@ -160,19 +160,19 @@ $(GENDIR): $(APISRC)

# Generate the server schema, types and router boilerplate.
pkg/openapi/types.go: $(OPENAPI_SCHEMA)
@go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@$(OPENAPI_CODEGEN_VERSION)
@go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OPENAPI_CODEGEN_VERSION)
oapi-codegen -generate types $(OPENAPI_CODEGEN_FLAGS) -o $@ $<

pkg/openapi/schema.go: $(OPENAPI_SCHEMA)
@go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@$(OPENAPI_CODEGEN_VERSION)
@go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OPENAPI_CODEGEN_VERSION)
oapi-codegen -generate spec $(OPENAPI_CODEGEN_FLAGS) -o $@ $<

pkg/openapi/client.go: $(OPENAPI_SCHEMA)
@go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@$(OPENAPI_CODEGEN_VERSION)
@go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OPENAPI_CODEGEN_VERSION)
oapi-codegen -generate client $(OPENAPI_CODEGEN_FLAGS) -o $@ $<

pkg/openapi/router.go: $(OPENAPI_SCHEMA)
@go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@$(OPENAPI_CODEGEN_VERSION)
@go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OPENAPI_CODEGEN_VERSION)
oapi-codegen -generate chi-server $(OPENAPI_CODEGEN_FLAGS) -o $@ $<

# When checking out, the files timestamps are pretty much random, and make cause
Expand Down
2 changes: 1 addition & 1 deletion pkg/openapi/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 30 additions & 18 deletions pkg/openapi/router.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit db4c3e0

Please sign in to comment.