Skip to content

Commit

Permalink
Upgrade OpenAPI Codegen (#129)
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 cde4609 commit 8c155cb
Show file tree
Hide file tree
Showing 5 changed files with 351 additions and 291 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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 @@ -175,19 +175,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.

Loading

0 comments on commit 8c155cb

Please sign in to comment.