Skip to content

Commit db20ecd

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pr/68
2 parents ef9a89b + c9909ff commit db20ecd

29 files changed

+1958
-310
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
name: Build project
2-
on: [ push, pull_request ]
1+
name: CI
2+
on:
3+
push: {}
4+
pull_request: {}
5+
workflow_dispatch: {}
6+
permissions:
7+
contents: read
38
jobs:
49
build:
5-
name: Build
6-
runs-on: ubuntu-latest
7-
strategy:
8-
fail-fast: false
9-
# perform matrix testing to give us an earlier insight into issues with different versions of supported major versions of Go
10-
matrix:
11-
version:
12-
- "1.20"
13-
- "1.21"
14-
- "1.22"
15-
steps:
16-
- name: Check out source code
17-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
18-
19-
- name: Set up Go
20-
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
21-
with:
22-
go-version: ${{ matrix.version }}
23-
24-
- name: Test
25-
run: make test
10+
uses: oapi-codegen/actions/.github/workflows/ci.yml@75566d848d25021f137594c947f26171094fb511 # v0.5.0
11+
with:
12+
lint_versions: '["1.25"]'

.github/workflows/generate.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/govulncheck.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Determine known CVEs through `govulncheck`
2+
on:
3+
push:
4+
branches:
5+
- main
6+
schedule:
7+
# Mondays at 0000
8+
- cron: "0 0 * * 1"
9+
jobs:
10+
check-for-vulnerabilities:
11+
name: Check for vulnerabilities using `govulncheck`
12+
runs-on: ubuntu-latest
13+
permissions:
14+
security-events: write
15+
contents: read
16+
steps:
17+
- uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
18+
with:
19+
go-package: ./...
20+
# NOTE that we want to produce the SARIF-formatted report, which can then be consumed by other tools ...
21+
output-format: sarif
22+
output-file: govulncheck.sarif
23+
24+
# ... such as the Code Scanning tab (https://github.com/oapi-codegen/runtime/security/code-scanning?query=is%3Aopen+branch%3Amain+tool%3Agovulncheck)
25+
- name: Upload SARIF file
26+
uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.2
27+
with:
28+
sarif_file: govulncheck.sarif
29+
category: govulncheck
30+
31+
- name: Print code scanning results URL
32+
run: |
33+
echo "Results: https://github.com/${{ github.repository }}/security/code-scanning?query=is%3Aopen+branch%3Amain+tool%3Agovulncheck"

.github/workflows/lint.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.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@09c613e259eb8d4e7c81c2cb00618eb5fc4575a7 # v5
19+
- uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6
2020
with:
2121
name: next
2222
tag: next

.github/workflows/tidy.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

Makefile

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
11
GOBASE=$(shell pwd)
22
GOBIN=$(GOBASE)/bin
33

4-
help:
5-
@echo "This is a helper makefile for oapi-codegen"
6-
@echo "Targets:"
7-
@echo " generate: regenerate all generated files"
8-
@echo " test: run all tests"
9-
@echo " gin_example generate gin example server code"
10-
@echo " tidy tidy go mod"
11-
124
$(GOBIN)/golangci-lint:
13-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.55.2
5+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v2.10.1
146

157
.PHONY: tools
168
tools: $(GOBIN)/golangci-lint
179

1810
lint: tools
11+
# run the root module explicitly, to prevent recursive calls by re-invoking `make ...` top-level
1912
$(GOBIN)/golangci-lint run ./...
13+
# then, for all child modules, use a module-managed `Makefile`
14+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && env GOBIN=$(GOBIN) make lint'
2015

2116
lint-ci: tools
22-
$(GOBIN)/golangci-lint run ./... --out-format=github-actions --timeout=5m
17+
# for the root module, explicitly run the step, to prevent recursive calls
18+
$(GOBIN)/golangci-lint run ./... --output.text.path=stdout --timeout=5m
19+
# then, for all child modules, use a module-managed `Makefile`
20+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && env GOBIN=$(GOBIN) make lint-ci'
2321

2422
generate:
23+
# for the root module, explicitly run the step, to prevent recursive calls
2524
go generate ./...
25+
# then, for all child modules, use a module-managed `Makefile`
26+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && make generate'
2627

2728
test:
29+
# for the root module, explicitly run the step, to prevent recursive calls
2830
go test -cover ./...
31+
# then, for all child modules, use a module-managed `Makefile`
32+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && make test'
2933

3034
tidy:
31-
@echo "tidy..."
35+
# for the root module, explicitly run the step, to prevent recursive calls
3236
go mod tidy
37+
# then, for all child modules, use a module-managed `Makefile`
38+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && make tidy'
39+
40+
tidy-ci:
41+
# for the root module, explicitly run the step, to prevent recursive calls
42+
tidied -verbose
43+
# then, for all child modules, use a module-managed `Makefile`
44+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && make tidy-ci'

bindform.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,12 @@ func bindAdditionalProperties(additionalProperties reflect.Value, parentStruct r
288288

289289
func marshalFormImpl(v reflect.Value, result url.Values, name string) {
290290
switch v.Kind() {
291-
case reflect.Interface, reflect.Ptr:
291+
case reflect.Ptr:
292+
if v.IsNil() {
293+
break
294+
}
295+
fallthrough
296+
case reflect.Interface:
292297
marshalFormImpl(v.Elem(), result, name)
293298
case reflect.Slice:
294299
for i := 0; i < v.Len(); i++ {

bindform_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func TestMarshalForm(t *testing.T) {
133133
StructSlice []testSubStruct `json:"struct_slice,omitempty"`
134134
OptInt *int `json:"opt_int,omitempty"`
135135
OptBool *bool `json:"opt_bool,omitempty"`
136+
OptBoolNullable *bool `json:"opt_bool_nullable"`
136137
OptString *string `json:"opt_string,omitempty"`
137138
OptStruct *testSubStruct `json:"opt_struct,omitempty"`
138139
OptStructSlice *[]testSubStruct `json:"opt_struct_slice,omitempty"`
@@ -151,6 +152,7 @@ func TestMarshalForm(t *testing.T) {
151152
},
152153
"opt_int=456": {OptInt: func(v int) *int { return &v }(456)},
153154
"opt_bool=true": {OptBool: func(v bool) *bool { return &v }(true)},
155+
"": {OptBoolNullable: nil},
154156
"opt_string=def": {OptString: func(v string) *string { return &v }("def")},
155157
"opt_struct[int]=456&opt_struct[string]=def": {OptStruct: &testSubStruct{Int: 456, String: "def"}},
156158
"opt_struct_slice[0][int]=123&opt_struct_slice[0][string]=abc&opt_struct_slice[1][int]=456&opt_struct_slice[1][string]=def": {

0 commit comments

Comments
 (0)