Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.

Commit e87c2fb

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents b925051 + f459fd7 commit e87c2fb

File tree

123 files changed

+7288
-3761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+7288
-3761
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
build:
1010
uses: oapi-codegen/actions/.github/workflows/ci.yml@75566d848d25021f137594c947f26171094fb511 # v0.5.0
1111
with:
12+
excluding_versions: '["1.22", "1.23"]'
1213
lint_versions: '["1.25"]'
1314

1415
build-binaries:
@@ -21,10 +22,10 @@ jobs:
2122
- "oldstable"
2223
steps:
2324
- name: Check out source code
24-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2526

2627
- name: Set up Go
27-
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
28+
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
2829
with:
2930
go-version: ${{ matrix.version }}
3031

.github/workflows/govulncheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
# ... such as the Code Scanning tab (https://github.com/oapi-codegen/oapi-codegen/security/code-scanning?query=is%3Aopen+branch%3Amain+tool%3Agovulncheck)
3131
- name: Upload SARIF file
32-
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
32+
uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
3333
with:
3434
sarif_file: govulncheck.sarif
3535
category: govulncheck

.github/workflows/label-actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
reaction:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: dessant/label-actions@102faf474a544be75fbaf4df54e73d3c515a0e65 # v4.0.1
21+
- uses: dessant/label-actions@9e5fd757ffe1e065abf55e9f74d899dbe012922a # v5.0.0
2222
with:
2323
github-token: ${{ github.token }}

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
pull-requests: write
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6.1.0
19+
- uses: release-drafter/release-drafter@6db134d15f3909ccc9eefd369f02bd1e9cffdf97 # v6.2.0
2020
with:
2121
name: next
2222
tag: next

.github/workflows/scorecard.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
steps:
2222
- name: "Checkout code"
23-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
23+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2424
with:
2525
persist-credentials: false
2626
show-progress: false
@@ -33,14 +33,14 @@ jobs:
3333
publish_results: true
3434

3535
- name: "Upload artifact"
36-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
36+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
3737
with:
3838
name: SARIF file
3939
path: results.sarif
4040
retention-days: 5
4141

4242
# Upload the results to GitHub's code scanning dashboard
4343
- name: "Upload to code-scanning"
44-
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
44+
uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
4545
with:
4646
sarif_file: results.sarif

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ help:
1010
@echo " lint lint the project"
1111

1212
$(GOBIN)/golangci-lint:
13-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v2.6.0
13+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v2.10.1
1414

1515
.PHONY: tools
1616
tools: $(GOBIN)/golangci-lint

README.md

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ go install github.com/oapi-codegen/oapi-codegen-exp/v2/cmd/oapi-codegen@latest
5050

5151
## Install
5252

53-
### For Go 1.24+
54-
5553
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.
5654

5755
To do this, you run `go get -tool`:
@@ -67,29 +65,6 @@ From there, each invocation of `oapi-codegen` would be used like so:
6765
//go:generate go tool oapi-codegen -config cfg.yaml ../../api.yaml
6866
```
6967

70-
### Prior to Go 1.24
71-
72-
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.
73-
74-
This would give you a `tools/tools.go`:
75-
76-
```go
77-
//go:build tools
78-
// +build tools
79-
80-
package main
81-
82-
import (
83-
_ "github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen"
84-
)
85-
```
86-
87-
Then, each invocation of `oapi-codegen` would be used like so:
88-
89-
```go
90-
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
91-
```
92-
9368
Alternatively, you can install it as a binary with:
9469

9570
```sh
@@ -145,11 +120,13 @@ For full details of what is supported, it's worth checking out [the GoDoc for `c
145120
We also have [a JSON Schema](configuration-schema.json) that can be used by IDEs/editors with the Language Server Protocol (LSP) to perform intelligent suggestions, i.e.:
146121

147122
```yaml
148-
# yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/HEAD/configuration-schema.json
123+
# yaml-language-server: $schema=https://raw.githubusercontent.com/oapi-codegen/oapi-codegen/v2.6.0/configuration-schema.json
149124
package: api
150125
# ...
151126
```
152127

128+
Note that it's recommended to pin to a specific version of the configuration schema, so it matches the version of `oapi-codegen` you're using. For instance, if you're using [Renovate](https://docs.renovatebot.com/), you can [have Renovate automagically update this version for you](https://www.jvt.me/posts/2026/03/01/oapi-codegen-config-renovate/).
129+
153130
### Backwards compatibility
154131

155132
Although we strive to retain backwards compatibility - as a project that's using a stable API per SemVer - there are sometimes opportunities we must take to fix a bug that could cause a breaking change for [people relying upon the behaviour](https://xkcd.com/1172/).
@@ -3452,6 +3429,8 @@ It is also possible to use HTTPS URLs.
34523429
>
34533430
> See [this blog post](https://www.jvt.me/posts/2024/04/27/github-actions-update-file/) for an example of how to use GitHub Actions to manage the updates of files across repos
34543431
>
3432+
> See [this blog post](https://www.jvt.me/posts/2026/02/27/renovate-update-file) for an example of how to use Renovate to manage the updates of files across repos
3433+
>
34553434
> This will be disabled by default (but possible to turn back on via configuration) [in the future](https://github.com/oapi-codegen/oapi-codegen/issues/1564)
34563435

34573436
To use it, you can use the following configuration:

configuration-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
},
256256
"resolve-type-name-collisions": {
257257
"type": "boolean",
258-
"description": "When set to true, automatically renames types that collide across different OpenAPI component sections (schemas, parameters, requestBodies, responses, headers) by appending a suffix based on the component section (e.g., 'Parameter', 'Response', 'RequestBody'). Without this, the codegen will error on duplicate type names, requiring manual resolution via x-go-name.",
258+
"description": "When set to true, automatically renames types that collide across different OpenAPI component sections (schemas, parameters, requestBodies, responses, headers) by appending a suffix based on the component section. Also detects collisions between component types and client response wrapper types. Without this, the codegen will error on duplicate type names, requiring manual resolution via x-go-name.",
259259
"default": false
260260
},
261261
"type-mapping": {

examples/authenticated-api/echo/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"net"
77

88
"github.com/labstack/echo/v4"
9-
"github.com/labstack/echo/v4/middleware"
109
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/echo/api"
1110
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/echo/server"
1211
)
@@ -28,7 +27,6 @@ func main() {
2827
if err != nil {
2928
log.Fatalln("error creating middleware:", err)
3029
}
31-
e.Use(middleware.Logger())
3230
e.Use(mw...)
3331

3432
svr := server.NewServer()
Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
1-
SHELL:=/bin/bash
2-
3-
YELLOW := \e[0;33m
4-
RESET := \e[0;0m
5-
6-
GOVER := $(shell go env GOVERSION)
7-
GOMINOR := $(shell bash -c "cut -f1 -d' ' <<< \"$(GOVER)\" | cut -f2 -d.")
8-
9-
define execute-if-go-122
10-
@{ \
11-
if [[ 22 -le $(GOMINOR) ]]; then \
12-
$1; \
13-
else \
14-
echo -e "$(YELLOW)Skipping task as you're running Go v1.$(GOMINOR).x which is < Go 1.22, which this module requires$(RESET)"; \
15-
fi \
16-
}
17-
endef
18-
191
lint:
20-
$(call execute-if-go-122,$(GOBIN)/golangci-lint run ./...)
2+
$(GOBIN)/golangci-lint run ./...
213

224
lint-ci:
23-
24-
$(call execute-if-go-122,$(GOBIN)/golangci-lint run ./... --output.text.path=stdout --timeout=5m)
5+
$(GOBIN)/golangci-lint run ./... --output.text.path=stdout --timeout=5m
256

267
generate:
27-
$(call execute-if-go-122,go generate ./...)
8+
go generate ./...
289

2910
test:
30-
$(call execute-if-go-122,go test -cover ./...)
11+
go test -cover ./...
3112

3213
tidy:
33-
$(call execute-if-go-122,go mod tidy)
14+
go mod tidy
3415

3516
tidy-ci:
36-
$(call execute-if-go-122,tidied -verbose)
17+
tidied -verbose

0 commit comments

Comments
 (0)