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
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
go-version: stable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6.5.0
uses: golangci/golangci-lint-action@v8.0.0
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.64.5
version: v2.5.0

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ jobs:
curl -sLO https://github.com/vearutop/gocovdiff/releases/download/v1.4.2/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz && rm linux_amd64.tar.gz
gocovdiff_hash=$(git hash-object ./gocovdiff)
[ "$gocovdiff_hash" == "c37862c73a677e5a9c069470287823ab5bbf0244" ] || (echo "::error::unexpected hash for gocovdiff, possible tampering: $gocovdiff_hash" && exit 1)
git fetch origin master ${{ github.event.pull_request.base.sha }}
REP=$(./gocovdiff -mod github.com/$GITHUB_REPOSITORY -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
# Fetch PR diff from GitHub API.
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} > pull_request.diff
REP=$(./gocovdiff -diff pull_request.diff -mod github.com/$GITHUB_REPOSITORY -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
echo "${REP}"
cat gha-unit.txt
DIFF=$(test -e unit-base.txt && ./gocovdiff -mod github.com/$GITHUB_REPOSITORY -func-cov unit.txt -func-base-cov unit-base.txt || echo "Missing base coverage file")
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@
/.vscode
/bench-*.txt
/vendor
go.work
go.work.sum
126 changes: 72 additions & 54 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
# See https://golangci-lint.run/docs/linters/configuration/
version: "2"
run:
tests: true

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
gocyclo:
min-complexity: 20
dupl:
threshold: 100
misspell:
locale: US
unparam:
check-exported: true

linters:
enable-all: true
default: all
disable:
- nilnil
- err113
Expand All @@ -26,48 +13,79 @@ linters:
- gocognit
- musttag
- intrange
- noinlineerr
- wsl_v5
- funcorder
- copyloopvar
- lll
- gochecknoglobals
- wrapcheck
- paralleltest
- depguard
- dupword
- errname
- exhaustruct
- forbidigo
- forcetypeassert
- varnamelen
- tagliatelle
- errname
- gochecknoglobals
- intrange
- ireturn
- exhaustruct
- lll
- mnd
- nonamedreturns
- testableexamples
- dupword
- depguard
- paralleltest
- recvcheck
- tagalign
- mnd
- tagliatelle
- testableexamples
- testifylint
- recvcheck

issues:
exclude-use-default: false
exclude-rules:
- linters:
- staticcheck
text: "SA1019: strings.Title .+ deprecated"

- linters:
- mnd
- goconst
- noctx
- funlen
- dupl
- unused
- unparam
path: "_test.go"
- linters:
- errcheck # Error checking omitted for brevity.
- gosec
path: "example_"
- linters:
- revive
text: "unused-parameter: parameter"

- varnamelen
- wrapcheck
settings:
dupl:
threshold: 100
errcheck:
check-type-assertions: true
check-blank: true
gocyclo:
min-complexity: 20
misspell:
locale: US
unparam:
check-exported: true
exclusions:
generated: lax
rules:
- linters:
- embeddedstructfieldcheck
- gosec
- dupl
- funlen
- goconst
- mnd
- noctx
- unparam
- unused
path: _test.go
- linters:
- errcheck
- gosec
path: example_
- linters:
- revive
text: 'unused-parameter: parameter'
- linters:
- staticcheck
text: "SA1019: strings.Title .+ deprecated"
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#GOLANGCI_LINT_VERSION := "v1.64.5" # Optional configuration to pinpoint golangci-lint version.
#GOLANGCI_LINT_VERSION := "v2.5.0" # Optional configuration to pinpoint golangci-lint version.

# The head of Makefile determines location of dev-go to include standard targets.
GO ?= go
Expand Down Expand Up @@ -27,9 +27,6 @@ ifeq ($(DEVGO_PATH),)
endif
endif

JSON_CLI_VERSION := "v1.8.6"
JSON_CLI_VERSION_31 := "v1.11.1"

-include $(DEVGO_PATH)/makefiles/main.mk
-include $(DEVGO_PATH)/makefiles/lint.mk
-include $(DEVGO_PATH)/makefiles/test-unit.mk
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/swaggest/openapi-go
go 1.18

require (
github.com/bool64/dev v0.2.39
github.com/bool64/dev v0.2.43
github.com/stretchr/testify v1.8.2
github.com/swaggest/assertjson v1.9.0
github.com/swaggest/jsonschema-go v0.3.74
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE=
github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/bool64/dev v0.2.43 h1:yQ7qiZVef6WtCl2vDYU0Y+qSq+0aBrQzY8KXkklk9cQ=
github.com/bool64/dev v0.2.43/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E=
github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
1 change: 0 additions & 1 deletion openapi3/entities.go

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

2 changes: 1 addition & 1 deletion openapi3/example_misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func ExampleReflector_options() {
r := openapi3.Reflector{}

// Reflector embeds jsonschema.Reflector and it is possible to configure optional behavior.
r.Reflector.DefaultOptions = append(r.Reflector.DefaultOptions,
r.DefaultOptions = append(r.DefaultOptions,
jsonschema.InterceptNullability(func(params jsonschema.InterceptNullabilityParams) {
// Removing nullability from non-pointer slices (regardless of omitempty).
if params.Type.Kind() != reflect.Ptr && params.Schema.HasType(jsonschema.Null) && params.Schema.HasType(jsonschema.Array) {
Expand Down
1 change: 1 addition & 0 deletions openapi3/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
// Reflector builds OpenAPI Schema with reflected structures.
type Reflector struct {
jsonschema.Reflector

Spec *Spec
}

Expand Down
1 change: 0 additions & 1 deletion openapi31/entities.go

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

2 changes: 1 addition & 1 deletion openapi31/example_misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func ExampleReflector_options() {
r := openapi31.Reflector{}

// Reflector embeds jsonschema.Reflector and it is possible to configure optional behavior.
r.Reflector.DefaultOptions = append(r.Reflector.DefaultOptions,
r.DefaultOptions = append(r.DefaultOptions,
jsonschema.InterceptNullability(func(params jsonschema.InterceptNullabilityParams) {
// Removing nullability from non-pointer slices (regardless of omitempty).
if params.Type.Kind() != reflect.Ptr && params.Schema.HasType(jsonschema.Null) && params.Schema.HasType(jsonschema.Array) {
Expand Down
1 change: 1 addition & 0 deletions openapi31/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
// Reflector builds OpenAPI Schema with reflected structures.
type Reflector struct {
jsonschema.Reflector

Spec *Spec
}

Expand Down
1 change: 1 addition & 0 deletions openapi31/reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type EmbeddedHeader struct {

type Resp struct {
EmbeddedHeader

Field1 int `json:"field1"`
Field2 string `json:"field2"`
Info struct {
Expand Down
Loading