Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
build:
uses: oapi-codegen/actions/.github/workflows/ci.yml@75566d848d25021f137594c947f26171094fb511 # v0.5.0
with:
excluding_versions: '["1.22", "1.23"]'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do this upstream in the actions repo (after this change) and then that'll mean we can roll out minimum Go 1.24 across all our repos

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we have to update all the others first. I'll do that next.

lint_versions: '["1.25"]'

build-binaries:
Expand Down
25 changes: 0 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest

## Install

### For Go 1.24+

It is recommended to follow [the `go tool` support available from Go 1.24+](https://www.jvt.me/posts/2025/01/27/go-tools-124/) for managing the dependency of `oapi-codegen` alongside your core application.

To do this, you run `go get -tool`:
Expand All @@ -59,29 +57,6 @@ From there, each invocation of `oapi-codegen` would be used like so:
//go:generate go tool oapi-codegen -config cfg.yaml ../../api.yaml
```

### Prior to Go 1.24

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this pattern may still be used by folks - especially with a separate tools/go.mod, it can be better for the overall dependency tree - but not blocking this review


It is recommended to follow [the `tools.go` pattern](https://www.jvt.me/posts/2022/06/15/go-tools-dependency-management/) for managing the dependency of `oapi-codegen` alongside your core application.

This would give you a `tools/tools.go`:

```go
//go:build tools
// +build tools

package main

import (
_ "github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen"
)
```

Then, each invocation of `oapi-codegen` would be used like so:

```go
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
```

Alternatively, you can install it as a binary with:

```sh
Expand Down
2 changes: 0 additions & 2 deletions examples/authenticated-api/echo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/echo/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/echo/server"
)
Expand All @@ -28,7 +27,6 @@ func main() {
if err != nil {
log.Fatalln("error creating middleware:", err)
}
e.Use(middleware.Logger())
e.Use(mw...)

svr := server.NewServer()
Expand Down
31 changes: 6 additions & 25 deletions examples/authenticated-api/stdhttp/Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
SHELL:=/bin/bash

YELLOW := \e[0;33m
RESET := \e[0;0m

GOVER := $(shell go env GOVERSION)
GOMINOR := $(shell bash -c "cut -f1 -d' ' <<< \"$(GOVER)\" | cut -f2 -d.")

define execute-if-go-122
@{ \
if [[ 22 -le $(GOMINOR) ]]; then \
$1; \
else \
echo -e "$(YELLOW)Skipping task as you're running Go v1.$(GOMINOR).x which is < Go 1.22, which this module requires$(RESET)"; \
fi \
}
endef

lint:
$(call execute-if-go-122,$(GOBIN)/golangci-lint run ./...)
$(GOBIN)/golangci-lint run ./...

lint-ci:

$(call execute-if-go-122,$(GOBIN)/golangci-lint run ./... --output.text.path=stdout --timeout=5m)
$(GOBIN)/golangci-lint run ./... --output.text.path=stdout --timeout=5m

generate:
$(call execute-if-go-122,go generate ./...)
go generate ./...

test:
$(call execute-if-go-122,go test -cover ./...)
go test -cover ./...

tidy:
$(call execute-if-go-122,go mod tidy)
go mod tidy

tidy-ci:
$(call execute-if-go-122,tidied -verbose)
tidied -verbose
34 changes: 17 additions & 17 deletions examples/authenticated-api/stdhttp/go.mod
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
module github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/stdhttp

go 1.22.5
go 1.24.3

replace github.com/oapi-codegen/oapi-codegen/v2 => ../../../

require (
github.com/getkin/kin-openapi v0.133.0
github.com/lestrrat-go/jwx v1.2.29
github.com/oapi-codegen/nethttp-middleware v1.0.2
github.com/lestrrat-go/jwx v1.2.31
github.com/oapi-codegen/nethttp-middleware v1.1.2
github.com/oapi-codegen/oapi-codegen/v2 v2.0.0-00010101000000-000000000000
github.com/oapi-codegen/testutil v1.1.0
github.com/stretchr/testify v1.11.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/go-openapi/jsonpointer v0.22.4 // indirect
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mailru/easyjson v0.9.1 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/speakeasy-api/jsonpath v0.6.0 // indirect
github.com/speakeasy-api/openapi-overlay v0.10.2 // indirect
github.com/speakeasy-api/openapi-overlay v0.10.3 // indirect
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
github.com/woodsbury/decimal128 v1.3.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/mod v0.23.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.30.0 // indirect
github.com/woodsbury/decimal128 v1.4.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/mod v0.33.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/text v0.34.0 // indirect
golang.org/x/tools v0.42.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading