From 06d6e564f5be175120213b42b48ab5dd58f94d23 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Sat, 27 Sep 2025 08:09:17 +0200 Subject: [PATCH 1/4] updated README for release Signed-off-by: Frederic BIDON --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 16a1512..25c8c52 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The runtime component for use in code generation or as untyped usage. ## Release notes -### v0.29.0 [draft, unpublished] +### v0.29.0 **New with this release**: From 3802129218a43ea3a8d8cae8afde56f872644e0e Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Sun, 9 Nov 2025 15:44:16 +0100 Subject: [PATCH 2/4] chore: updated license marks in source files Signed-off-by: Frederic BIDON --- .golangci.yml | 1 - README.md | 4 ++ authinfo_test.go | 15 +--- bytestream.go | 19 ++--- bytestream_test.go | 11 +-- client-middleware/opentracing/opentracing.go | 3 + .../opentracing/opentracing_test.go | 3 + client-middleware/opentracing/runtime.go | 3 + client/auth_info.go | 15 +--- client/auth_info_test.go | 15 +--- client/keepalive.go | 3 + client/keepalive_test.go | 3 + client/mock_test.go | 3 + client/opentelemetry.go | 7 +- client/opentelemetry_test.go | 3 + client/request.go | 15 +--- client/request_test.go | 17 +---- client/response.go | 15 +--- client/response_test.go | 15 +--- client/runtime.go | 17 +---- client/runtime_test.go | 67 ++++++++---------- client/runtime_tls_test.go | 5 +- client_auth_info.go | 15 +--- client_operation.go | 17 +---- client_request.go | 25 ++----- client_request_test.go | 15 +--- client_response.go | 25 ++----- client_response_test.go | 21 ++---- constants.go | 15 +--- csv.go | 19 ++--- csv_options.go | 3 + csv_test.go | 15 +--- discard.go | 7 +- file.go | 15 +--- file_test.go | 3 + flagext/byte_size.go | 3 + flagext/byte_size_test.go | 3 + headers.go | 15 +--- headers_test.go | 15 +--- interfaces.go | 45 +++++------- internal/testing/data.go | 15 +--- internal/testing/data_test.go | 3 + internal/testing/petstore/api.go | 47 +++++-------- internal/testing/petstore/api_test.go | 3 + internal/testing/simplepetstore/api.go | 31 +++------ internal/testing/simplepetstore/api_test.go | 15 +--- json.go | 19 ++--- json_test.go | 15 +--- logger/logger.go | 7 +- logger/logger_test.go | 3 + logger/standard.go | 7 +- middleware/body_test.go | 7 +- middleware/context.go | 25 ++----- middleware/context_test.go | 27 +++----- middleware/debug_test.go | 5 +- middleware/denco/router.go | 15 ++-- middleware/denco/router_bench_test.go | 7 +- middleware/denco/router_test.go | 5 +- middleware/denco/server.go | 3 + middleware/denco/server_test.go | 3 + middleware/denco/util.go | 3 + middleware/denco/util_test.go | 5 +- middleware/doc.go | 15 +--- middleware/header/header.go | 8 ++- middleware/header/header_test.go | 3 + middleware/negotiate.go | 3 + middleware/negotiate_test.go | 3 + middleware/not_implemented.go | 19 ++--- middleware/not_implemented_test.go | 3 + middleware/operation.go | 15 +--- middleware/operation_test.go | 23 ++----- middleware/parameter.go | 49 +++++-------- middleware/parameter_test.go | 27 +++----- middleware/rapidoc.go | 3 + middleware/rapidoc_test.go | 3 + middleware/redoc.go | 3 + middleware/redoc_test.go | 3 + middleware/request.go | 21 ++---- middleware/request_test.go | 29 +++----- middleware/route_authenticator_test.go | 19 ++--- middleware/route_param_test.go | 15 +--- middleware/router.go | 21 ++---- middleware/router_test.go | 15 +--- middleware/security.go | 15 +--- middleware/security_test.go | 15 +--- middleware/spec.go | 15 +--- middleware/spec_test.go | 15 +--- middleware/string_conversion_test.go | 69 ++++++++----------- middleware/swaggerui.go | 3 + middleware/swaggerui_oauth2.go | 3 + middleware/swaggerui_oauth2_test.go | 3 + middleware/swaggerui_test.go | 3 + middleware/ui_options.go | 5 +- middleware/ui_options_test.go | 3 + middleware/untyped/api.go | 15 +--- middleware/untyped/api_test.go | 33 +++------ middleware/untyped_request_test.go | 39 ++++------- middleware/validation.go | 15 +--- middleware/validation_test.go | 15 +--- request.go | 15 +--- request_test.go | 15 +--- security/apikey_auth_test.go | 19 ++--- security/authenticator.go | 55 ++++++--------- security/authorizer.go | 17 +---- security/authorizer_test.go | 19 ++--- security/basic_auth_test.go | 19 ++--- security/bearer_auth_test.go | 7 +- statuses.go | 15 +--- text.go | 19 ++--- text_test.go | 15 +--- values.go | 3 + values_test.go | 3 + xml.go | 19 ++--- xml_test.go | 15 +--- yamlpc/yaml.go | 15 +--- yamlpc/yaml_test.go | 15 +--- 116 files changed, 538 insertions(+), 1118 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 5a0faa2..0087ed3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,6 @@ linters: - gomoddirectives # moved to mono-repo, multi-modules, so replace directives are needed - gosmopolitan - inamedparam - #- intrange # disabled while < go1.22 - ireturn - lll - musttag diff --git a/README.md b/README.md index 25c8c52..9e15b1a 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,7 @@ Moving forward, we want to : independently from the main package (to avoid breaking changes, the existing API will remain maintained, but evolve at a slower pace than opentelemetry). * [ ] fix a few known issues with some file upload requests (e.g. #286) + +## Licensing + +This library ships under the [SPDX-License-Identifier: Apache-2.0](./LICENSE). diff --git a/authinfo_test.go b/authinfo_test.go index 5f111a9..d3d8b22 100644 --- a/authinfo_test.go +++ b/authinfo_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/bytestream.go b/bytestream.go index 98e9618..eb64974 100644 --- a/bytestream.go +++ b/bytestream.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -54,7 +43,7 @@ func ByteStreamConsumer(opts ...byteStreamOpt) Consumer { opt(&vals) } - return ConsumerFunc(func(reader io.Reader, data interface{}) error { + return ConsumerFunc(func(reader io.Reader, data any) error { if reader == nil { return errors.New("ByteStreamConsumer requires a reader") // early exit } @@ -148,7 +137,7 @@ func ByteStreamProducer(opts ...byteStreamOpt) Producer { opt(&vals) } - return ProducerFunc(func(writer io.Writer, data interface{}) error { + return ProducerFunc(func(writer io.Writer, data any) error { if writer == nil { return errors.New("ByteStreamProducer requires a writer") // early exit } diff --git a/bytestream_test.go b/bytestream_test.go index 4e5e113..38b45e6 100644 --- a/bytestream_test.go +++ b/bytestream_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package runtime import ( @@ -62,7 +65,7 @@ func TestByteStreamConsumer(t *testing.T) { }) t.Run("can consume as an interface with underlying type []byte", func(t *testing.T) { - var dest interface{} = []byte{} + var dest any = []byte{} require.NoError(t, consumer.Consume(bytes.NewBufferString(expected), &dest)) asBytes, ok := dest.([]byte) require.True(t, ok) @@ -70,7 +73,7 @@ func TestByteStreamConsumer(t *testing.T) { }) t.Run("can consume as an interface with underlying type string", func(t *testing.T) { - var dest interface{} = "x" + var dest any = "x" require.NoError(t, consumer.Consume(bytes.NewBufferString(expected), &dest)) asString, ok := dest.(string) require.True(t, ok) @@ -274,7 +277,7 @@ func TestByteStreamProducer(t *testing.T) { t.Run("can produce from an interface with underlying type string", func(t *testing.T) { var w bytes.Buffer - var data interface{} = expected + var data any = expected require.NoError(t, producer.Produce(&w, data)) assert.Equal(t, expected, w.String()) }) @@ -289,7 +292,7 @@ func TestByteStreamProducer(t *testing.T) { t.Run("can produce from an interface with underling type []byte", func(t *testing.T) { var w bytes.Buffer - var data interface{} = []byte(expected) + var data any = []byte(expected) require.NoError(t, producer.Produce(&w, data)) assert.Equal(t, expected, w.String()) }) diff --git a/client-middleware/opentracing/opentracing.go b/client-middleware/opentracing/opentracing.go index 8c151b9..df50f79 100644 --- a/client-middleware/opentracing/opentracing.go +++ b/client-middleware/opentracing/opentracing.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package opentracing import ( diff --git a/client-middleware/opentracing/opentracing_test.go b/client-middleware/opentracing/opentracing_test.go index 30a8c11..aa2e911 100644 --- a/client-middleware/opentracing/opentracing_test.go +++ b/client-middleware/opentracing/opentracing_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package opentracing import ( diff --git a/client-middleware/opentracing/runtime.go b/client-middleware/opentracing/runtime.go index ee334db..727b671 100644 --- a/client-middleware/opentracing/runtime.go +++ b/client-middleware/opentracing/runtime.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package opentracing import ( diff --git a/client/auth_info.go b/client/auth_info.go index 4f26e92..a98690c 100644 --- a/client/auth_info.go +++ b/client/auth_info.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package client diff --git a/client/auth_info_test.go b/client/auth_info_test.go index 0816c71..1efd5a7 100644 --- a/client/auth_info_test.go +++ b/client/auth_info_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package client diff --git a/client/keepalive.go b/client/keepalive.go index 7dd6b51..831d23b 100644 --- a/client/keepalive.go +++ b/client/keepalive.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package client import ( diff --git a/client/keepalive_test.go b/client/keepalive_test.go index b558e04..d97f4eb 100644 --- a/client/keepalive_test.go +++ b/client/keepalive_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package client import ( diff --git a/client/mock_test.go b/client/mock_test.go index 5b0b930..068c15d 100644 --- a/client/mock_test.go +++ b/client/mock_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package client import ( diff --git a/client/opentelemetry.go b/client/opentelemetry.go index db246fc..e779412 100644 --- a/client/opentelemetry.go +++ b/client/opentelemetry.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package client import ( @@ -108,7 +111,7 @@ func newOpenTelemetryTransport(transport runtime.ClientTransport, host string, o return tr } -func (t *openTelemetryTransport) Submit(op *runtime.ClientOperation) (interface{}, error) { +func (t *openTelemetryTransport) Submit(op *runtime.ClientOperation) (any, error) { if op.Context == nil { return t.transport.Submit(op) } @@ -128,7 +131,7 @@ func (t *openTelemetryTransport) Submit(op *runtime.ClientOperation) (interface{ return params.WriteToRequest(req, reg) }) - op.Reader = runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + op.Reader = runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if span != nil { statusCode := response.Code() // NOTE: this is replaced by semconv.HTTPResponseStatusCode in semconv v1.21 diff --git a/client/opentelemetry_test.go b/client/opentelemetry_test.go index 0042c3b..3c9a08a 100644 --- a/client/opentelemetry_test.go +++ b/client/opentelemetry_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package client import ( diff --git a/client/request.go b/client/request.go index 8f8bab0..6d9b259 100644 --- a/client/request.go +++ b/client/request.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package client diff --git a/client/request_test.go b/client/request_test.go index 742cc1e..240fb48 100644 --- a/client/request_test.go +++ b/client/request_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package client @@ -736,7 +725,7 @@ func TestGetBodyCallsBeforeRoundTrip(t *testing.T) { PathPattern: "/", Params: rwrtr, Client: client, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusCreated { var res string if e := consumer.Consume(response.Body(), &res); e != nil { diff --git a/client/response.go b/client/response.go index 0bbd388..59abc3b 100644 --- a/client/response.go +++ b/client/response.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package client diff --git a/client/response_test.go b/client/response_test.go index 9368b4c..c4b9a8b 100644 --- a/client/response_test.go +++ b/client/response_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package client diff --git a/client/runtime.go b/client/runtime.go index 8dc50c1..203c74e 100644 --- a/client/runtime.go +++ b/client/runtime.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package client @@ -363,7 +352,7 @@ func (r *Runtime) CreateHttpRequest(operation *runtime.ClientOperation) (req *ht // Submit a request and when there is a body on success it will turn that into the result // all other things are turned into an api error for swagger which retains the status code -func (r *Runtime) Submit(operation *runtime.ClientOperation) (interface{}, error) { +func (r *Runtime) Submit(operation *runtime.ClientOperation) (any, error) { _, readResponse, _ := operation.Params, operation.Reader, operation.AuthInfo request, req, err := r.createHttpRequest(operation) diff --git a/client/runtime_test.go b/client/runtime_test.go index 4835c7a..6dab300 100644 --- a/client/runtime_test.go +++ b/client/runtime_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package client @@ -81,17 +70,17 @@ func TestRuntime_Concurrent(t *testing.T) { require.NoError(t, err) rt := New(hu.Host, "/", []string{schemeHTTP}) - resCC := make(chan interface{}) + resCC := make(chan any) errCC := make(chan error) - var res interface{} + var res any for range 6 { go func() { - resC := make(chan interface{}) + resC := make(chan any) errC := make(chan error) go func() { - var resp interface{} + var resp any var errp error for range 3 { resp, errp = rt.Submit(&runtime.ClientOperation{ @@ -99,7 +88,7 @@ func TestRuntime_Concurrent(t *testing.T) { Method: http.MethodGet, PathPattern: "/", Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []task if e := consumer.Consume(response.Body(), &res); e != nil { @@ -161,7 +150,7 @@ func TestRuntime_Canary(t *testing.T) { Method: http.MethodGet, PathPattern: "/", Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []task if e := consumer.Consume(response.Body(), &res); e != nil { @@ -213,7 +202,7 @@ func TestRuntime_XMLCanary(t *testing.T) { Method: http.MethodGet, PathPattern: "/", Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res tasks if e := consumer.Consume(response.Body(), &res); e != nil { @@ -255,7 +244,7 @@ func TestRuntime_TextCanary(t *testing.T) { Method: http.MethodGet, PathPattern: "/", Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res string if e := consumer.Consume(response.Body(), &res); e != nil { @@ -300,7 +289,7 @@ func TestRuntime_CSVCanary(t *testing.T) { Method: http.MethodGet, PathPattern: "/", Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res bytes.Buffer if e := consumer.Consume(response.Body(), &res); e != nil { @@ -358,7 +347,7 @@ func TestRuntime_CustomTransport(t *testing.T) { PathPattern: "/", Schemes: []string{"ws", "wss", schemeHTTPS}, Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []task if e := consumer.Consume(response.Body(), &res); e != nil { @@ -420,9 +409,9 @@ func TestRuntime_CustomCookieJar(t *testing.T) { PathPattern: "/", Params: rwrtr, AuthInfo: authInfo, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, _ runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, _ runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { - return map[string]interface{}{}, nil + return map[string]any{}, nil } return nil, errors.New("generic error") }), @@ -468,7 +457,7 @@ func TestRuntime_AuthCanary(t *testing.T) { res, err := rt.Submit(&runtime.ClientOperation{ ID: "getTasks", Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []task if e := consumer.Consume(response.Body(), &res); e != nil { @@ -520,7 +509,7 @@ func TestRuntime_PickConsumer(t *testing.T) { Schemes: []string{schemeHTTP}, ConsumesMediaTypes: []string{"application/octet-stream"}, Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []task if e := consumer.Consume(response.Body(), &res); e != nil { @@ -573,7 +562,7 @@ func TestRuntime_ContentTypeCanary(t *testing.T) { PathPattern: "/", Schemes: []string{schemeHTTP}, Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []task if e := consumer.Consume(response.Body(), &res); e != nil { @@ -628,7 +617,7 @@ func TestRuntime_ChunkedResponse(t *testing.T) { PathPattern: "/", Schemes: []string{schemeHTTP}, Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []task if e := consumer.Consume(response.Body(), &res); e != nil { @@ -731,8 +720,8 @@ func TestRuntime_OverrideClientOperation(t *testing.T) { Params: runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error { return nil }), - Reader: runtime.ClientResponseReaderFunc(func(_ runtime.ClientResponse, _ runtime.Consumer) (interface{}, error) { - return map[string]interface{}{}, nil + Reader: runtime.ClientResponseReaderFunc(func(_ runtime.ClientResponse, _ runtime.Consumer) (any, error) { + return map[string]any{}, nil }), }) require.NoError(t, err) @@ -768,12 +757,12 @@ func TestRuntime_PreserveTrailingSlash(t *testing.T) { Method: http.MethodGet, PathPattern: "/api/tasks/", Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, _ runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, _ runtime.Consumer) (any, error) { if redirected { return nil, errors.New("expected Submit to preserve trailing slashes - this caused a redirect") } if response.Code() == http.StatusOK { - return map[string]interface{}{}, nil + return map[string]any{}, nil } return nil, errors.New("generic error") }), @@ -806,7 +795,7 @@ func TestRuntime_FallbackConsumer(t *testing.T) { Schemes: []string{schemeHTTP}, ConsumesMediaTypes: []string{"application/octet-stream"}, Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []byte if e := consumer.Consume(response.Body(), &res); e != nil { @@ -829,7 +818,7 @@ func TestRuntime_FallbackConsumer(t *testing.T) { Schemes: []string{schemeHTTP}, ConsumesMediaTypes: []string{"application/octet-stream"}, Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []byte if e := consumer.Consume(response.Body(), &res); e != nil { @@ -879,7 +868,7 @@ func TestRuntime_AuthHeaderParamDetected(t *testing.T) { res, err := rt.Submit(&runtime.ClientOperation{ ID: "getTasks", Params: rwrtr, - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { var res []task if e := consumer.Consume(response.Body(), &res); e != nil { @@ -923,7 +912,7 @@ func TestRuntime_Timeout(t *testing.T) { //nolint:maintidx // linter evaluates t }) } - requestReader := runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + requestReader := runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() != http.StatusOK { return nil, errors.New("generic error") } @@ -1269,8 +1258,8 @@ func testDefaultsInTransport(t *testing.T, value string) http.RoundTripper { }) } -func assertResult(result []task) func(testing.TB, interface{}) { - return func(t testing.TB, res interface{}) { +func assertResult(result []task) func(testing.TB, any) { + return func(t testing.TB, res any) { assert.IsType(t, []task{}, res) actual, ok := res.([]task) require.True(t, ok) diff --git a/client/runtime_tls_test.go b/client/runtime_tls_test.go index 98f33b9..3dd0cf1 100644 --- a/client/runtime_tls_test.go +++ b/client/runtime_tls_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package client import ( @@ -159,7 +162,7 @@ func TestRuntimeManualCertificateValidation(t *testing.T) { Params: runtime.ClientRequestWriterFunc(func(_ runtime.ClientRequest, _ strfmt.Registry) error { return nil }), - Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + Reader: runtime.ClientResponseReaderFunc(func(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) { if response.Code() == http.StatusOK { if e := consumer.Consume(response.Body(), &received); e != nil { return nil, e diff --git a/client_auth_info.go b/client_auth_info.go index c6c97d9..581e644 100644 --- a/client_auth_info.go +++ b/client_auth_info.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/client_operation.go b/client_operation.go index 5a5d635..b0bb097 100644 --- a/client_operation.go +++ b/client_operation.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -37,5 +26,5 @@ type ClientOperation struct { // A ClientTransport implementor knows how to submit Request objects to some destination type ClientTransport interface { // Submit(string, RequestWriter, ResponseReader, AuthInfoWriter) (interface{}, error) - Submit(*ClientOperation) (interface{}, error) + Submit(*ClientOperation) (any, error) } diff --git a/client_request.go b/client_request.go index 4ebb2de..6e335b3 100644 --- a/client_request.go +++ b/client_request.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -53,7 +42,7 @@ type ClientRequest interface { //nolint:interfacebloat // a swagger-capable requ SetFileParam(string, ...NamedReadCloser) error - SetBodyParam(interface{}) error + SetBodyParam(any) error SetTimeout(time.Duration) error @@ -63,7 +52,7 @@ type ClientRequest interface { //nolint:interfacebloat // a swagger-capable requ GetBody() []byte - GetBodyParam() interface{} + GetBodyParam() any GetFileParam() map[string][]NamedReadCloser } @@ -103,7 +92,7 @@ func (n *namedReadCloser) Name() string { type TestClientRequest struct { Headers http.Header - Body interface{} + Body any } func (t *TestClientRequest) SetHeaderParam(name string, values ...string) error { @@ -122,7 +111,7 @@ func (t *TestClientRequest) SetPathParam(_ string, _ string) error { return nil func (t *TestClientRequest) SetFileParam(_ string, _ ...NamedReadCloser) error { return nil } -func (t *TestClientRequest) SetBodyParam(body interface{}) error { +func (t *TestClientRequest) SetBodyParam(body any) error { t.Body = body return nil } @@ -139,7 +128,7 @@ func (t *TestClientRequest) GetPath() string { return "" } func (t *TestClientRequest) GetBody() []byte { return nil } -func (t *TestClientRequest) GetBodyParam() interface{} { +func (t *TestClientRequest) GetBodyParam() any { return t.Body } diff --git a/client_request_test.go b/client_request_test.go index c6df3e4..8d1e420 100644 --- a/client_request_test.go +++ b/client_request_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/client_response.go b/client_response.go index b992994..2be38d2 100644 --- a/client_response.go +++ b/client_response.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -32,28 +21,28 @@ type ClientResponse interface { } // A ClientResponseReaderFunc turns a function into a ClientResponseReader interface implementation -type ClientResponseReaderFunc func(ClientResponse, Consumer) (interface{}, error) +type ClientResponseReaderFunc func(ClientResponse, Consumer) (any, error) // ReadResponse reads the response -func (read ClientResponseReaderFunc) ReadResponse(resp ClientResponse, consumer Consumer) (interface{}, error) { +func (read ClientResponseReaderFunc) ReadResponse(resp ClientResponse, consumer Consumer) (any, error) { return read(resp, consumer) } // A ClientResponseReader is an interface for things want to read a response. // An application of this is to create structs from response values type ClientResponseReader interface { - ReadResponse(ClientResponse, Consumer) (interface{}, error) + ReadResponse(ClientResponse, Consumer) (any, error) } // APIError wraps an error model and captures the status code type APIError struct { OperationName string - Response interface{} + Response any Code int } // NewAPIError creates a new API error -func NewAPIError(opName string, payload interface{}, code int) *APIError { +func NewAPIError(opName string, payload any, code int) *APIError { return &APIError{ OperationName: opName, Response: payload, diff --git a/client_response_test.go b/client_response_test.go index c5b20a3..33a3929 100644 --- a/client_response_test.go +++ b/client_response_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -49,7 +38,7 @@ func TestResponseReaderFunc(t *testing.T) { Header, Message, Body string Code int } - reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (interface{}, error) { + reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (any, error) { b, _ := io.ReadAll(r.Body()) actual.Body = string(b) actual.Code = r.Code() @@ -65,7 +54,7 @@ func TestResponseReaderFunc(t *testing.T) { } func TestResponseReaderFuncError(t *testing.T) { - reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (interface{}, error) { + reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (any, error) { _, _ = io.ReadAll(r.Body()) return nil, NewAPIError("fake", errors.New("writer closed"), 490) }) @@ -73,7 +62,7 @@ func TestResponseReaderFuncError(t *testing.T) { require.Error(t, err) require.ErrorContains(t, err, "writer closed") - reader = func(r ClientResponse, _ Consumer) (interface{}, error) { + reader = func(r ClientResponse, _ Consumer) (any, error) { _, _ = io.ReadAll(r.Body()) err := &fs.PathError{ Op: "write", diff --git a/constants.go b/constants.go index 5159692..62ae9ee 100644 --- a/constants.go +++ b/constants.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/csv.go b/csv.go index c9597bc..567e3d9 100644 --- a/csv.go +++ b/csv.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -48,7 +37,7 @@ import ( func CSVConsumer(opts ...CSVOpt) Consumer { o := csvOptsWithDefaults(opts) - return ConsumerFunc(func(reader io.Reader, data interface{}) error { + return ConsumerFunc(func(reader io.Reader, data any) error { if reader == nil { return errors.New("CSVConsumer requires a reader") } @@ -181,7 +170,7 @@ func CSVConsumer(opts ...CSVOpt) Consumer { func CSVProducer(opts ...CSVOpt) Producer { o := csvOptsWithDefaults(opts) - return ProducerFunc(func(writer io.Writer, data interface{}) error { + return ProducerFunc(func(writer io.Writer, data any) error { if writer == nil { return errors.New("CSVProducer requires a writer") } diff --git a/csv_options.go b/csv_options.go index 8966578..4cc0439 100644 --- a/csv_options.go +++ b/csv_options.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package runtime import ( diff --git a/csv_test.go b/csv_test.go index ba08d1b..fc32641 100644 --- a/csv_test.go +++ b/csv_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/discard.go b/discard.go index 0d390cf..b05678b 100644 --- a/discard.go +++ b/discard.go @@ -1,9 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package runtime import "io" // DiscardConsumer does absolutely nothing, it's a black hole. -var DiscardConsumer = ConsumerFunc(func(_ io.Reader, _ interface{}) error { return nil }) +var DiscardConsumer = ConsumerFunc(func(_ io.Reader, _ any) error { return nil }) // DiscardProducer does absolutely nothing, it's a black hole. -var DiscardProducer = ProducerFunc(func(_ io.Writer, _ interface{}) error { return nil }) +var DiscardProducer = ProducerFunc(func(_ io.Writer, _ any) error { return nil }) diff --git a/file.go b/file.go index 1bc6aab..2a85379 100644 --- a/file.go +++ b/file.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/file_test.go b/file_test.go index d17c607..6213723 100644 --- a/file_test.go +++ b/file_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package runtime import ( diff --git a/flagext/byte_size.go b/flagext/byte_size.go index 0f3eeba..4e514ea 100644 --- a/flagext/byte_size.go +++ b/flagext/byte_size.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package flagext import ( diff --git a/flagext/byte_size_test.go b/flagext/byte_size_test.go index f5853c1..79a4e9a 100644 --- a/flagext/byte_size_test.go +++ b/flagext/byte_size_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package flagext import ( diff --git a/headers.go b/headers.go index 4d111db..510e396 100644 --- a/headers.go +++ b/headers.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/headers_test.go b/headers_test.go index 2b9c46f..3793b8f 100644 --- a/headers_test.go +++ b/headers_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/interfaces.go b/interfaces.go index e334128..90046bf 100644 --- a/interfaces.go +++ b/interfaces.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -23,23 +12,23 @@ import ( ) // OperationHandlerFunc an adapter for a function to the OperationHandler interface -type OperationHandlerFunc func(interface{}) (interface{}, error) +type OperationHandlerFunc func(any) (any, error) // Handle implements the operation handler interface -func (s OperationHandlerFunc) Handle(data interface{}) (interface{}, error) { +func (s OperationHandlerFunc) Handle(data any) (any, error) { return s(data) } // OperationHandler a handler for a swagger operation type OperationHandler interface { - Handle(interface{}) (interface{}, error) + Handle(any) (any, error) } // ConsumerFunc represents a function that can be used as a consumer -type ConsumerFunc func(io.Reader, interface{}) error +type ConsumerFunc func(io.Reader, any) error // Consume consumes the reader into the data parameter -func (fn ConsumerFunc) Consume(reader io.Reader, data interface{}) error { +func (fn ConsumerFunc) Consume(reader io.Reader, data any) error { return fn(reader, data) } @@ -47,14 +36,14 @@ func (fn ConsumerFunc) Consume(reader io.Reader, data interface{}) error { // data provided by the request body type Consumer interface { // Consume performs the binding of request values - Consume(io.Reader, interface{}) error + Consume(io.Reader, any) error } // ProducerFunc represents a function that can be used as a producer -type ProducerFunc func(io.Writer, interface{}) error +type ProducerFunc func(io.Writer, any) error // Produce produces the response for the provided data -func (f ProducerFunc) Produce(writer io.Writer, data interface{}) error { +func (f ProducerFunc) Produce(writer io.Writer, data any) error { return f(writer, data) } @@ -62,14 +51,14 @@ func (f ProducerFunc) Produce(writer io.Writer, data interface{}) error { // HTTP response type Producer interface { // Produce writes to the http response - Produce(io.Writer, interface{}) error + Produce(io.Writer, any) error } // AuthenticatorFunc turns a function into an authenticator -type AuthenticatorFunc func(interface{}) (bool, interface{}, error) +type AuthenticatorFunc func(any) (bool, any, error) // Authenticate authenticates the request with the provided data -func (f AuthenticatorFunc) Authenticate(params interface{}) (bool, interface{}, error) { +func (f AuthenticatorFunc) Authenticate(params any) (bool, any, error) { return f(params) } @@ -77,14 +66,14 @@ func (f AuthenticatorFunc) Authenticate(params interface{}) (bool, interface{}, // implementations of Authenticator know how to authenticate the // request data and translate that into a valid principal object or an error type Authenticator interface { - Authenticate(interface{}) (bool, interface{}, error) + Authenticate(any) (bool, any, error) } // AuthorizerFunc turns a function into an authorizer -type AuthorizerFunc func(*http.Request, interface{}) error +type AuthorizerFunc func(*http.Request, any) error // Authorize authorizes the processing of the request for the principal -func (f AuthorizerFunc) Authorize(r *http.Request, principal interface{}) error { +func (f AuthorizerFunc) Authorize(r *http.Request, principal any) error { return f(r, principal) } @@ -92,7 +81,7 @@ func (f AuthorizerFunc) Authorize(r *http.Request, principal interface{}) error // implementations of Authorizer know how to authorize the principal object // using the request data and returns error if unauthorized type Authorizer interface { - Authorize(*http.Request, interface{}) error + Authorize(*http.Request, any) error } // Validatable types implementing this interface allow customizing their validation diff --git a/internal/testing/data.go b/internal/testing/data.go index ff7a7a4..47099af 100644 --- a/internal/testing/data.go +++ b/internal/testing/data.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package testing diff --git a/internal/testing/data_test.go b/internal/testing/data_test.go index a2f887c..b83fa98 100644 --- a/internal/testing/data_test.go +++ b/internal/testing/data_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package testing import ( diff --git a/internal/testing/petstore/api.go b/internal/testing/petstore/api.go index b9276b9..449eb6a 100644 --- a/internal/testing/petstore/api.go +++ b/internal/testing/petstore/api.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package petstore @@ -52,7 +41,7 @@ func NewAPI(t gotest.TB) (*loads.Document, *untyped.API) { api.RegisterConsumer("application/x-yaml", yamlpc.YAMLConsumer()) api.RegisterProducer("application/x-yaml", yamlpc.YAMLProducer()) - api.RegisterAuth("basic", security.BasicAuth(func(username, password string) (interface{}, error) { + api.RegisterAuth("basic", security.BasicAuth(func(username, password string) (any, error) { switch { case username == apiPrincipal && password == apiPrincipal: return apiPrincipal, nil @@ -64,13 +53,13 @@ func NewAPI(t gotest.TB) (*loads.Document, *untyped.API) { return nil, errors.Unauthenticated("basic") } })) - api.RegisterAuth("apiKey", security.APIKeyAuth("X-API-KEY", "header", func(token string) (interface{}, error) { + api.RegisterAuth("apiKey", security.APIKeyAuth("X-API-KEY", "header", func(token string) (any, error) { if token == "token123" { return apiPrincipal, nil } return nil, errors.Unauthenticated("token") })) - api.RegisterAuthorizer(runtime.AuthorizerFunc(func(r *http.Request, user interface{}) error { + api.RegisterAuthorizer(runtime.AuthorizerFunc(func(r *http.Request, user any) error { if r.Method == http.MethodPost && strings.HasPrefix(r.URL.Path, "/api/pets") && user.(string) != apiPrincipal { if user.(string) == apiUser { return errors.CompositeValidationError(errors.New(errors.InvalidTypeCode, "unauthorized")) @@ -85,9 +74,9 @@ func NewAPI(t gotest.TB) (*loads.Document, *untyped.API) { api.RegisterOperation("delete", "/pets/{id}", new(stubOperationHandler)) api.RegisterOperation("get", "/pets/{id}", new(stubOperationHandler)) - api.Models["pet"] = func() interface{} { return new(Pet) } - api.Models["newPet"] = func() interface{} { return new(Pet) } - api.Models["tag"] = func() interface{} { return new(Tag) } + api.Models["pet"] = func() any { return new(Pet) } + api.Models["newPet"] = func() any { return new(Pet) } + api.Models["tag"] = func() any { return new(Tag) } return spec, api } @@ -107,13 +96,13 @@ func NewRootAPI(t gotest.TB) (*loads.Document, *untyped.API) { api.RegisterConsumer("application/x-yaml", yamlpc.YAMLConsumer()) api.RegisterProducer("application/x-yaml", yamlpc.YAMLProducer()) - api.RegisterAuth("basic", security.BasicAuth(func(username, password string) (interface{}, error) { + api.RegisterAuth("basic", security.BasicAuth(func(username, password string) (any, error) { if username == apiPrincipal && password == apiPrincipal { return apiPrincipal, nil } return nil, errors.Unauthenticated("basic") })) - api.RegisterAuth("apiKey", security.APIKeyAuth("X-API-KEY", "header", func(token string) (interface{}, error) { + api.RegisterAuth("apiKey", security.APIKeyAuth("X-API-KEY", "header", func(token string) (any, error) { if token == "token123" { return apiPrincipal, nil } @@ -125,9 +114,9 @@ func NewRootAPI(t gotest.TB) (*loads.Document, *untyped.API) { api.RegisterOperation("delete", "/pets/{id}", new(stubOperationHandler)) api.RegisterOperation("get", "/pets/{id}", new(stubOperationHandler)) - api.Models["pet"] = func() interface{} { return new(Pet) } - api.Models["newPet"] = func() interface{} { return new(Pet) } - api.Models["tag"] = func() interface{} { return new(Tag) } + api.Models["pet"] = func() any { return new(Pet) } + api.Models["newPet"] = func() any { return new(Pet) } + api.Models["tag"] = func() any { return new(Tag) } return spec, api } @@ -150,24 +139,24 @@ type Pet struct { type stubConsumer struct { } -func (s *stubConsumer) Consume(_ io.Reader, _ interface{}) error { +func (s *stubConsumer) Consume(_ io.Reader, _ any) error { return nil } type stubProducer struct { } -func (s *stubProducer) Produce(_ io.Writer, _ interface{}) error { +func (s *stubProducer) Produce(_ io.Writer, _ any) error { return nil } type stubOperationHandler struct { } -func (s *stubOperationHandler) ParameterModel() interface{} { +func (s *stubOperationHandler) ParameterModel() any { return nil } -func (s *stubOperationHandler) Handle(_ interface{}) (interface{}, error) { - return map[string]interface{}{}, nil +func (s *stubOperationHandler) Handle(_ any) (any, error) { + return map[string]any{}, nil } diff --git a/internal/testing/petstore/api_test.go b/internal/testing/petstore/api_test.go index 450b561..6bfd15b 100644 --- a/internal/testing/petstore/api_test.go +++ b/internal/testing/petstore/api_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package petstore import ( diff --git a/internal/testing/simplepetstore/api.go b/internal/testing/simplepetstore/api.go index b919469..2cacfb3 100644 --- a/internal/testing/simplepetstore/api.go +++ b/internal/testing/simplepetstore/api.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package simplepetstore @@ -44,26 +33,26 @@ func NewPetstore() (http.Handler, error) { return middleware.Serve(spec, api), nil } -var getAllPets = runtime.OperationHandlerFunc(func(_ interface{}) (interface{}, error) { +var getAllPets = runtime.OperationHandlerFunc(func(_ any) (any, error) { return pets, nil }) -var createPet = runtime.OperationHandlerFunc(func(data interface{}) (interface{}, error) { - body := data.(map[string]interface{})["pet"].(map[string]interface{}) +var createPet = runtime.OperationHandlerFunc(func(data any) (any, error) { + body := data.(map[string]any)["pet"].(map[string]any) return addPet(Pet{ Name: body["name"].(string), Status: body["status"].(string), }), nil }) -var deletePet = runtime.OperationHandlerFunc(func(data interface{}) (interface{}, error) { - id := data.(map[string]interface{})["id"].(int64) +var deletePet = runtime.OperationHandlerFunc(func(data any) (any, error) { + id := data.(map[string]any)["id"].(int64) removePet(id) - return map[string]interface{}{}, nil + return map[string]any{}, nil }) -var getPetByID = runtime.OperationHandlerFunc(func(data interface{}) (interface{}, error) { - id := data.(map[string]interface{})["id"].(int64) +var getPetByID = runtime.OperationHandlerFunc(func(data any) (any, error) { + id := data.(map[string]any)["id"].(int64) return petByID(id) }) diff --git a/internal/testing/simplepetstore/api_test.go b/internal/testing/simplepetstore/api_test.go index dce37d8..fbaf595 100644 --- a/internal/testing/simplepetstore/api_test.go +++ b/internal/testing/simplepetstore/api_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package simplepetstore diff --git a/json.go b/json.go index 5a69055..8f93eeb 100644 --- a/json.go +++ b/json.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -21,7 +10,7 @@ import ( // JSONConsumer creates a new JSON consumer func JSONConsumer() Consumer { - return ConsumerFunc(func(reader io.Reader, data interface{}) error { + return ConsumerFunc(func(reader io.Reader, data any) error { dec := json.NewDecoder(reader) dec.UseNumber() // preserve number formats return dec.Decode(data) @@ -30,7 +19,7 @@ func JSONConsumer() Consumer { // JSONProducer creates a new JSON producer func JSONProducer() Producer { - return ProducerFunc(func(writer io.Writer, data interface{}) error { + return ProducerFunc(func(writer io.Writer, data any) error { enc := json.NewEncoder(writer) enc.SetEscapeHTML(false) return enc.Encode(data) diff --git a/json_test.go b/json_test.go index 82af4c8..6fc35e2 100644 --- a/json_test.go +++ b/json_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/logger/logger.go b/logger/logger.go index 6f4debc..45484de 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -1,10 +1,13 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package logger import "os" type Logger interface { - Printf(format string, args ...interface{}) - Debugf(format string, args ...interface{}) + Printf(format string, args ...any) + Debugf(format string, args ...any) } func DebugEnabled() bool { diff --git a/logger/logger_test.go b/logger/logger_test.go index 78e560d..d0ba024 100644 --- a/logger/logger_test.go +++ b/logger/logger_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package logger import ( diff --git a/logger/standard.go b/logger/standard.go index 30035a7..48ba27f 100644 --- a/logger/standard.go +++ b/logger/standard.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package logger import ( @@ -9,14 +12,14 @@ var _ Logger = StandardLogger{} type StandardLogger struct{} -func (StandardLogger) Printf(format string, args ...interface{}) { +func (StandardLogger) Printf(format string, args ...any) { if len(format) == 0 || format[len(format)-1] != '\n' { format += "\n" } fmt.Fprintf(os.Stderr, format, args...) } -func (StandardLogger) Debugf(format string, args ...interface{}) { +func (StandardLogger) Debugf(format string, args ...any) { if len(format) == 0 || format[len(format)-1] != '\n' { format += "\n" } diff --git a/middleware/body_test.go b/middleware/body_test.go index 5582ab7..6d88bc0 100644 --- a/middleware/body_test.go +++ b/middleware/body_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( @@ -46,7 +49,7 @@ func TestBindRequest_BodyValidation(t *testing.T) { err = ctx.BindValidRequest(req, ri, rbn(func(r *http.Request, _ *MatchedRoute) error { defer r.Body.Close() - var data interface{} + var data any e := runtime.JSONConsumer().Consume(r.Body, &data) _ = data return e @@ -87,7 +90,7 @@ func TestBindRequest_DeleteNoBody(t *testing.T) { err = ctx.BindValidRequest(req, ri, rbn(func(r *http.Request, _ *MatchedRoute) error { defer r.Body.Close() - var data interface{} + var data any e := runtime.JSONConsumer().Consume(r.Body, &data) _ = data return e diff --git a/middleware/context.go b/middleware/context.go index f2cade3..bb00b93 100644 --- a/middleware/context.go +++ b/middleware/context.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -126,7 +115,7 @@ func newRoutableUntypedAPI(spec *loads.Document, api *untyped.API, context *Cont } // bind and validate the request using reflection - var bound interface{} + var bound any var validation error bound, r, validation = context.BindAndValidate(r, route) if validation != nil { @@ -287,7 +276,7 @@ func MatchedRouteFrom(req *http.Request) *MatchedRoute { } // SecurityPrincipalFrom request context value. -func SecurityPrincipalFrom(req *http.Request) interface{} { +func SecurityPrincipalFrom(req *http.Request) any { return req.Context().Value(ctxSecurityPrincipal) } @@ -466,7 +455,7 @@ func (c *Context) ResetAuth(request *http.Request) *http.Request { // Returns the principal object and a shallow copy of the request when its // context doesn't contain the principal, otherwise the same request or an error // (the last) if one of the authenticators returns one or an Unauthenticated error -func (c *Context) Authorize(request *http.Request, route *MatchedRoute) (interface{}, *http.Request, error) { +func (c *Context) Authorize(request *http.Request, route *MatchedRoute) (any, *http.Request, error) { if route == nil || !route.HasAuth() { return nil, nil, nil } @@ -504,7 +493,7 @@ func (c *Context) Authorize(request *http.Request, route *MatchedRoute) (interfa // Returns the validation map and a shallow copy of the request when its context // doesn't contain the validation, otherwise it returns the same request or an // CompositeValidationError error -func (c *Context) BindAndValidate(request *http.Request, matched *MatchedRoute) (interface{}, *http.Request, error) { +func (c *Context) BindAndValidate(request *http.Request, matched *MatchedRoute) (any, *http.Request, error) { var rCtx = request.Context() if v, ok := rCtx.Value(ctxBoundParams).(*validation); ok { @@ -530,7 +519,7 @@ func (c *Context) NotFound(rw http.ResponseWriter, r *http.Request) { } // Respond renders the response after doing some content negotiation -func (c *Context) Respond(rw http.ResponseWriter, r *http.Request, produces []string, route *MatchedRoute, data interface{}) { +func (c *Context) Respond(rw http.ResponseWriter, r *http.Request, produces []string, route *MatchedRoute, data any) { c.debugLogf("responding to %s %s with produces: %v", r.Method, r.URL.Path, produces) offers := []string{} for _, mt := range produces { diff --git a/middleware/context_test.go b/middleware/context_test.go index 33dcd38..230c871 100644 --- a/middleware/context_test.go +++ b/middleware/context_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -43,12 +32,12 @@ func (s *stubBindRequester) BindRequest(*http.Request, *MatchedRoute) error { type stubOperationHandler struct { } -func (s *stubOperationHandler) ParameterModel() interface{} { +func (s *stubOperationHandler) ParameterModel() any { return nil } -func (s *stubOperationHandler) Handle(_ interface{}) (interface{}, error) { - return map[string]interface{}{}, nil +func (s *stubOperationHandler) Handle(_ any) (any, error) { + return map[string]any{}, nil } func init() { @@ -551,7 +540,7 @@ func TestContextRender(t *testing.T) { ri, request, _ := ctx.RouteInfo(request) recorder := httptest.NewRecorder() - ctx.Respond(recorder, request, []string{ct}, ri, map[string]interface{}{"name": "hello"}) + ctx.Respond(recorder, request, []string{ct}, ri, map[string]any{"name": "hello"}) assert.Equal(t, http.StatusOK, recorder.Code) assert.JSONEq(t, "{\"name\":\"hello\"}\n", recorder.Body.String()) @@ -567,7 +556,7 @@ func TestContextRender(t *testing.T) { request, err := http.NewRequestWithContext(stdcontext.Background(), http.MethodGet, "/api/pets", nil) require.NoError(t, err) request.Header.Set(runtime.HeaderAccept, "text/xml") - assert.Panics(t, func() { ctx.Respond(recorder, request, []string{}, nil, map[string]interface{}{"name": "hello"}) }) + assert.Panics(t, func() { ctx.Respond(recorder, request, []string{}, nil, map[string]any{"name": "hello"}) }) request, err = http.NewRequestWithContext(stdcontext.Background(), http.MethodGet, "/api/pets", nil) require.NoError(t, err) @@ -575,7 +564,7 @@ func TestContextRender(t *testing.T) { ri, request, _ = ctx.RouteInfo(request) recorder = httptest.NewRecorder() - ctx.Respond(recorder, request, []string{ct}, ri, map[string]interface{}{"name": "hello"}) + ctx.Respond(recorder, request, []string{ct}, ri, map[string]any{"name": "hello"}) assert.Equal(t, http.StatusOK, recorder.Code) assert.JSONEq(t, "{\"name\":\"hello\"}\n", recorder.Body.String()) diff --git a/middleware/debug_test.go b/middleware/debug_test.go index b89d3a6..e7d1ad4 100644 --- a/middleware/debug_test.go +++ b/middleware/debug_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( @@ -20,7 +23,7 @@ type customLogger struct { lg *log.Logger } -func (l customLogger) Debugf(format string, args ...interface{}) { +func (l customLogger) Debugf(format string, args ...any) { l.lg.Printf(format, args...) } diff --git a/middleware/denco/router.go b/middleware/denco/router.go index 21808ed..b371a2c 100644 --- a/middleware/denco/router.go +++ b/middleware/denco/router.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + // Package denco provides fast URL router. package denco @@ -36,14 +39,14 @@ type Router struct { // By default, SizeHint will be determined from given records to Build. SizeHint int - static map[string]interface{} + static map[string]any } // New returns a new Router. func New() *Router { return &Router{ SizeHint: -1, - static: make(map[string]interface{}), + static: make(map[string]any), param: newDoubleArray(), } } @@ -51,7 +54,7 @@ func New() *Router { // Lookup returns data and path parameters that associated with path. // params is a slice of the Param that arranged in the order in which parameters appeared. // e.g. when built routing path is "/path/to/:id/:name" and given path is "/path/to/1/alice". params order is [{"id": "1"}, {"name": "alice"}], not [{"name": "alice"}, {"id": "1"}]. -func (rt *Router) Lookup(path string) (data interface{}, params Params, found bool) { +func (rt *Router) Lookup(path string) (data any, params Params, found bool) { if data, found = rt.static[path]; found { return data, nil, true } @@ -348,7 +351,7 @@ func (da *doubleArray) arrange(records []*record, idx, depth int, usedBase map[i // node represents a node of Double-Array. type node struct { - data interface{} + data any // Names of path parameters. paramNames []string @@ -422,11 +425,11 @@ type Record struct { Key string // Result value for Key. - Value interface{} + Value any } // NewRecord returns a new Record. -func NewRecord(key string, value interface{}) Record { +func NewRecord(key string, value any) Record { return Record{ Key: key, Value: value, diff --git a/middleware/denco/router_bench_test.go b/middleware/denco/router_bench_test.go index 3252e62..12cfc48 100644 --- a/middleware/denco/router_bench_test.go +++ b/middleware/denco/router_bench_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package denco_test import ( @@ -146,7 +149,7 @@ func makeTestStaticRecords(n int) []denco.Record { func makeTestSingleParamRecords(n int) []denco.Record { records := make([]denco.Record, n) - for i := 0; i < len(records); i++ { + for i := range records { records[i] = denco.NewRecord(fmt.Sprintf("/user%d/:name", i), fmt.Sprintf("testroute%d", i)) } return records @@ -154,7 +157,7 @@ func makeTestSingleParamRecords(n int) []denco.Record { func makeTestSingle2ParamRecords(n int) []denco.Record { records := make([]denco.Record, n) - for i := 0; i < len(records); i++ { + for i := range records { records[i] = denco.NewRecord(fmt.Sprintf("/user%d/:name/comment/:id", i), fmt.Sprintf("testroute%d", i)) } return records diff --git a/middleware/denco/router_test.go b/middleware/denco/router_test.go index 4b103ad..3ac5d56 100644 --- a/middleware/denco/router_test.go +++ b/middleware/denco/router_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package denco_test import ( @@ -178,7 +181,7 @@ var realURIs = []denco.Record{ type testcase struct { path string - value interface{} + value any params []denco.Param found bool } diff --git a/middleware/denco/server.go b/middleware/denco/server.go index 0886713..8f04d93 100644 --- a/middleware/denco/server.go +++ b/middleware/denco/server.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package denco import ( diff --git a/middleware/denco/server_test.go b/middleware/denco/server_test.go index fcc56db..5fd32b1 100644 --- a/middleware/denco/server_test.go +++ b/middleware/denco/server_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package denco_test import ( diff --git a/middleware/denco/util.go b/middleware/denco/util.go index edc1f6a..f002bc4 100644 --- a/middleware/denco/util.go +++ b/middleware/denco/util.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package denco // NextSeparator returns an index of next separator in path. diff --git a/middleware/denco/util_test.go b/middleware/denco/util_test.go index c7241be..4c94cab 100644 --- a/middleware/denco/util_test.go +++ b/middleware/denco/util_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package denco_test import ( @@ -11,7 +14,7 @@ func TestNextSeparator(t *testing.T) { for _, testcase := range []struct { path string start int - expected interface{} + expected any }{ {"/path/to/route", 0, 0}, {"/path/to/route", 1, 5}, diff --git a/middleware/doc.go b/middleware/doc.go index 836a988..04b8322 100644 --- a/middleware/doc.go +++ b/middleware/doc.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 /* Package middleware provides the library with helper functions for serving swagger APIs. diff --git a/middleware/header/header.go b/middleware/header/header.go index 13d7dc3..6ce870d 100644 --- a/middleware/header/header.go +++ b/middleware/header/header.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + // Copyright 2013 The Go Authors. All rights reserved. // // Use of this source code is governed by a BSD-style @@ -10,6 +13,7 @@ package header import ( + "maps" "net/http" "strings" "time" @@ -65,9 +69,7 @@ func init() { // Copy returns a shallow copy of the header. func Copy(header http.Header) http.Header { h := make(http.Header) - for k, vs := range header { - h[k] = vs - } + maps.Copy(h, header) return h } diff --git a/middleware/header/header_test.go b/middleware/header/header_test.go index ba1525d..ed090cc 100644 --- a/middleware/header/header_test.go +++ b/middleware/header/header_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package header import ( diff --git a/middleware/negotiate.go b/middleware/negotiate.go index d25d58c..cb0a852 100644 --- a/middleware/negotiate.go +++ b/middleware/negotiate.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + // Copyright 2013 The Go Authors. All rights reserved. // // Use of this source code is governed by a BSD-style diff --git a/middleware/negotiate_test.go b/middleware/negotiate_test.go index 6d28ddf..7530c85 100644 --- a/middleware/negotiate_test.go +++ b/middleware/negotiate_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + // Copyright 2013 The Go Authors. All rights reserved. // // Use of this source code is governed by a BSD-style diff --git a/middleware/not_implemented.go b/middleware/not_implemented.go index bc6942a..2e63780 100644 --- a/middleware/not_implemented.go +++ b/middleware/not_implemented.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -22,7 +11,7 @@ import ( type errorResp struct { code int - response interface{} + response any headers http.Header } @@ -49,7 +38,7 @@ func NotImplemented(message string) Responder { // Error creates a generic responder for returning errors, the data will be serialized // with the matching producer for the request -func Error(code int, data interface{}, headers ...http.Header) Responder { +func Error(code int, data any, headers ...http.Header) Responder { var hdr http.Header for _, h := range headers { for k, v := range h { diff --git a/middleware/not_implemented_test.go b/middleware/not_implemented_test.go index 4451752..94a8fb6 100644 --- a/middleware/not_implemented_test.go +++ b/middleware/not_implemented_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/operation.go b/middleware/operation.go index 1175a63..2a7ab1f 100644 --- a/middleware/operation.go +++ b/middleware/operation.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware diff --git a/middleware/operation_test.go b/middleware/operation_test.go index ddb4659..698b1df 100644 --- a/middleware/operation_test.go +++ b/middleware/operation_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -29,9 +18,9 @@ import ( func TestOperationExecutor(t *testing.T) { spec, api := petstore.NewAPI(t) - api.RegisterOperation("get", "/pets", runtime.OperationHandlerFunc(func(_ interface{}) (interface{}, error) { - return []interface{}{ - map[string]interface{}{"id": 1, "name": "a dog"}, + api.RegisterOperation("get", "/pets", runtime.OperationHandlerFunc(func(_ any) (any, error) { + return []any{ + map[string]any{"id": 1, "name": "a dog"}, }, nil })) @@ -49,7 +38,7 @@ func TestOperationExecutor(t *testing.T) { assert.JSONEq(t, `[{"id":1,"name":"a dog"}]`+"\n", recorder.Body.String()) spec, api = petstore.NewAPI(t) - api.RegisterOperation("get", "/pets", runtime.OperationHandlerFunc(func(_ interface{}) (interface{}, error) { + api.RegisterOperation("get", "/pets", runtime.OperationHandlerFunc(func(_ any) (any, error) { return nil, errors.New(http.StatusUnprocessableEntity, "expected") })) diff --git a/middleware/parameter.go b/middleware/parameter.go index 5301b4c..7d630d6 100644 --- a/middleware/parameter.go +++ b/middleware/parameter.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -192,34 +181,34 @@ func (p *untypedParamBinder) Bind(request *http.Request, routeParams RouteParams func (p *untypedParamBinder) typeForSchema(tpe, format string, items *spec.Items) reflect.Type { switch tpe { case "boolean": - return reflect.TypeOf(true) + return reflect.TypeFor[bool]() case typeString: if tt, ok := p.formats.GetType(format); ok { return tt } - return reflect.TypeOf("") + return reflect.TypeFor[string]() case "integer": switch format { case "int8": - return reflect.TypeOf(int8(0)) + return reflect.TypeFor[int8]() case "int16": - return reflect.TypeOf(int16(0)) + return reflect.TypeFor[int16]() case "int32": - return reflect.TypeOf(int32(0)) + return reflect.TypeFor[int32]() case "int64": - return reflect.TypeOf(int64(0)) + return reflect.TypeFor[int64]() default: - return reflect.TypeOf(int64(0)) + return reflect.TypeFor[int64]() } case "number": switch format { case "float": - return reflect.TypeOf(float32(0)) + return reflect.TypeFor[float32]() case "double": - return reflect.TypeOf(float64(0)) + return reflect.TypeFor[float64]() } case typeArray: @@ -233,10 +222,10 @@ func (p *untypedParamBinder) typeForSchema(tpe, format string, items *spec.Items return reflect.MakeSlice(reflect.SliceOf(itemsType), 0, 0).Type() case "file": - return reflect.TypeOf(&runtime.File{}).Elem() + return reflect.TypeFor[runtime.File]() case "object": - return reflect.TypeOf(map[string]interface{}{}) + return reflect.TypeFor[map[string]any]() } return nil } @@ -279,7 +268,7 @@ func (p *untypedParamBinder) bindValue(data []string, hasKey bool, target reflec return p.setFieldValue(target, p.parameter.Default, d, hasKey) } -func (p *untypedParamBinder) setFieldValue(target reflect.Value, defaultValue interface{}, data string, hasKey bool) error { //nolint:gocyclo +func (p *untypedParamBinder) setFieldValue(target reflect.Value, defaultValue any, data string, hasKey bool) error { //nolint:gocyclo tpe := p.parameter.Type if p.parameter.Format != "" { tpe = p.parameter.Format @@ -341,7 +330,7 @@ func (p *untypedParamBinder) setFieldValue(target reflect.Value, defaultValue in case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: if data == "" { if target.CanSet() { - rd := defVal.Convert(reflect.TypeOf(int64(0))) + rd := defVal.Convert(reflect.TypeFor[int64]()) target.SetInt(rd.Int()) } return nil @@ -360,7 +349,7 @@ func (p *untypedParamBinder) setFieldValue(target reflect.Value, defaultValue in case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: if data == "" { if target.CanSet() { - rd := defVal.Convert(reflect.TypeOf(uint64(0))) + rd := defVal.Convert(reflect.TypeFor[uint64]()) target.SetUint(rd.Uint()) } return nil @@ -379,7 +368,7 @@ func (p *untypedParamBinder) setFieldValue(target reflect.Value, defaultValue in case reflect.Float32, reflect.Float64: if data == "" { if target.CanSet() { - rd := defVal.Convert(reflect.TypeOf(float64(0))) + rd := defVal.Convert(reflect.TypeFor[float64]()) target.SetFloat(rd.Float()) } return nil @@ -426,7 +415,7 @@ func (p *untypedParamBinder) setFieldValue(target reflect.Value, defaultValue in return nil } -func (p *untypedParamBinder) tryUnmarshaler(target reflect.Value, defaultValue interface{}, data string) (bool, error) { +func (p *untypedParamBinder) tryUnmarshaler(target reflect.Value, defaultValue any, data string) (bool, error) { if !target.CanSet() { return false, nil } @@ -458,7 +447,7 @@ func (p *untypedParamBinder) readFormattedSliceFieldValue(data string, target re return stringutils.SplitByFormat(data, p.parameter.CollectionFormat), false, nil } -func (p *untypedParamBinder) setSliceFieldValue(target reflect.Value, defaultValue interface{}, data []string, hasKey bool) error { +func (p *untypedParamBinder) setSliceFieldValue(target reflect.Value, defaultValue any, data []string, hasKey bool) error { sz := len(data) if (!hasKey || (!p.parameter.AllowEmptyValue && (sz == 0 || (sz == 1 && data[0] == "")))) && p.parameter.Required && defaultValue == nil { return errors.Required(p.Name, p.parameter.In, data) diff --git a/middleware/parameter_test.go b/middleware/parameter_test.go index cbec8ab..eb2eba1 100644 --- a/middleware/parameter_test.go +++ b/middleware/parameter_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -62,7 +51,7 @@ func testCollectionFormat(t *testing.T, param *spec.Parameter, valid bool) { } } -func requiredError(param *spec.Parameter, data interface{}) *errors.Validation { +func requiredError(param *spec.Parameter, data any) *errors.Validation { return errors.Required(param.Name, param.In, data) } @@ -135,8 +124,8 @@ func TestRequiredValidation(t *testing.T) { // validateRequiredAllowEmptyTest(t, dateParam, reflect.ValueOf(strfmt.DateTime{})) sliceParam := spec.QueryParam("tags").CollectionOf(stringItems, "").AsRequired() - validateRequiredTest(t, sliceParam, reflect.MakeSlice(reflect.TypeOf([]string{}), 0, 0)) - validateRequiredAllowEmptyTest(t, sliceParam, reflect.MakeSlice(reflect.TypeOf([]string{}), 0, 0)) + validateRequiredTest(t, sliceParam, reflect.MakeSlice(reflect.TypeFor[[]string](), 0, 0)) + validateRequiredAllowEmptyTest(t, sliceParam, reflect.MakeSlice(reflect.TypeFor[[]string](), 0, 0)) } func TestInvalidCollectionFormat(t *testing.T) { @@ -151,7 +140,7 @@ func TestInvalidCollectionFormat(t *testing.T) { testCollectionFormat(t, invalidCf2, false) } -func invalidTypeError(param *spec.Parameter, data interface{}) *errors.Validation { +func invalidTypeError(param *spec.Parameter, data any) *errors.Validation { tpe := param.Type if param.Format != "" { tpe = param.Format @@ -208,7 +197,7 @@ func TestTypeValidation(t *testing.T) { // fails for overflow str3 := strconv.FormatFloat(math.MaxFloat64, 'f', 5, 64) - v3 := reflect.TypeOf(float32(0)) + v3 := reflect.TypeFor[float32]() value = reflect.New(v3).Elem() binder = np(floatParam) err = binder.bindValue([]string{str3}, true, value) @@ -225,7 +214,7 @@ func TestTypeValidation(t *testing.T) { // fails for overflow str4 := "9" + strconv.FormatFloat(math.MaxFloat64, 'f', 5, 64) - v4 := reflect.TypeOf(float64(0)) + v4 := reflect.TypeFor[float64]() value = reflect.New(v4).Elem() binder = np(doubleParam) err = binder.bindValue([]string{str4}, true, value) diff --git a/middleware/rapidoc.go b/middleware/rapidoc.go index ef75e74..6039a26 100644 --- a/middleware/rapidoc.go +++ b/middleware/rapidoc.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/rapidoc_test.go b/middleware/rapidoc_test.go index 50682ee..63d3923 100644 --- a/middleware/rapidoc_test.go +++ b/middleware/rapidoc_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/redoc.go b/middleware/redoc.go index b96b01e..cbaec73 100644 --- a/middleware/redoc.go +++ b/middleware/redoc.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/redoc_test.go b/middleware/redoc_test.go index f117898..35c760b 100644 --- a/middleware/redoc_test.go +++ b/middleware/redoc_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/request.go b/middleware/request.go index 577e4a0..52facfe 100644 --- a/middleware/request.go +++ b/middleware/request.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -50,7 +39,7 @@ func NewUntypedRequestBinder(parameters map[string]spec.Parameter, spec *spec.Sw } // Bind perform the databinding and validation -func (o *UntypedRequestBinder) Bind(request *http.Request, routeParams RouteParams, consumer runtime.Consumer, data interface{}) error { +func (o *UntypedRequestBinder) Bind(request *http.Request, routeParams RouteParams, consumer runtime.Consumer, data any) error { val := reflect.Indirect(reflect.ValueOf(data)) isMap := val.Kind() == reflect.Map var result []error @@ -68,9 +57,9 @@ func (o *UntypedRequestBinder) Bind(request *http.Request, routeParams RoutePara tpe := binder.Type() if tpe == nil { if param.Schema.Type.Contains(typeArray) { - tpe = reflect.TypeOf([]interface{}{}) + tpe = reflect.TypeFor[[]any]() } else { - tpe = reflect.TypeOf(map[string]interface{}{}) + tpe = reflect.TypeFor[map[string]any]() } } target = reflect.Indirect(reflect.New(tpe)) diff --git a/middleware/request_test.go b/middleware/request_test.go index ebf0f5c..b9390da 100644 --- a/middleware/request_test.go +++ b/middleware/request_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -40,7 +29,7 @@ const ( type stubConsumer struct { } -func (s *stubConsumer) Consume(_ io.Reader, _ interface{}) error { +func (s *stubConsumer) Consume(_ io.Reader, _ any) error { return nil } @@ -87,7 +76,7 @@ func parametersForAllTypes(fmt string) map[string]spec.Parameter { friendParam := spec.BodyParam("friend", friendSchema) requestIDParam := spec.HeaderParam("X-Request-Id").Typed("integer", "int64") - requestIDParam.Extensions = spec.Extensions(map[string]interface{}{}) + requestIDParam.Extensions = spec.Extensions(map[string]any{}) requestIDParam.Extensions.Add("go-name", "RequestID") items := new(spec.Items) @@ -126,7 +115,7 @@ func parametersForJSONRequestParams(fmt string) map[string]spec.Parameter { friendParam := spec.BodyParam("friend", friendSchema) requestIDParam := spec.HeaderParam("X-Request-Id").Typed("integer", "int64") - requestIDParam.Extensions = spec.Extensions(map[string]interface{}{}) + requestIDParam.Extensions = spec.Extensions(map[string]any{}) requestIDParam.Extensions.Add("go-name", "RequestID") items := new(spec.Items) @@ -152,7 +141,7 @@ func parametersForJSONRequestSliceParams(fmt string) map[string]spec.Parameter { friendParam := spec.BodyParam("friend", spec.ArrayProperty(friendSchema)) requestIDParam := spec.HeaderParam("X-Request-Id").Typed("integer", "int64") - requestIDParam.Extensions = spec.Extensions(map[string]interface{}{}) + requestIDParam.Extensions = spec.Extensions(map[string]any{}) requestIDParam.Extensions.Add("go-name", "RequestID") items := new(spec.Items) @@ -171,7 +160,7 @@ func parametersForJSONRequestSliceParams(fmt string) map[string]spec.Parameter { func TestRequestBindingDefaultValue(t *testing.T) { confirmed := true name := "thomas" - friend := map[string]interface{}{"name": "toby", "age": float64(32)} + friend := map[string]any{"name": "toby", "age": float64(32)} id, age, score, factor := int64(7575), int32(348), float32(5.309), float64(37.403) requestID := 19394858 tags := []string{"one", "two", "three"} @@ -181,7 +170,7 @@ func TestRequestBindingDefaultValue(t *testing.T) { delivered := strfmt.DateTime(dt2) uri, err := url.Parse(testURL) require.NoError(t, err) - defaults := map[string]interface{}{ + defaults := map[string]any{ "id": id, "age": age, "score": score, @@ -207,7 +196,7 @@ func TestRequestBindingDefaultValue(t *testing.T) { req.Header.Set("Content-Type", "application/json") binder := NewUntypedRequestBinder(op3, new(spec.Swagger), strfmt.Default) - data := make(map[string]interface{}) + data := make(map[string]any) err = binder.Bind(req, RouteParams(nil), runtime.JSONConsumer(), &data) require.NoError(t, err) assert.Equal(t, defaults["id"], data["id"]) diff --git a/middleware/route_authenticator_test.go b/middleware/route_authenticator_test.go index aa5d9c4..7183a44 100644 --- a/middleware/route_authenticator_test.go +++ b/middleware/route_authenticator_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( @@ -14,27 +17,27 @@ import ( type countAuthenticator struct { count int applies bool - principal interface{} + principal any err error } -func (c *countAuthenticator) Authenticate(_ interface{}) (bool, interface{}, error) { +func (c *countAuthenticator) Authenticate(_ any) (bool, any, error) { c.count++ return c.applies, c.principal, c.err } -func newCountAuthenticator(applies bool, principal interface{}, err error) *countAuthenticator { +func newCountAuthenticator(applies bool, principal any, err error) *countAuthenticator { return &countAuthenticator{applies: applies, principal: principal, err: err} } var ( - successAuth = runtime.AuthenticatorFunc(func(_ interface{}) (bool, interface{}, error) { + successAuth = runtime.AuthenticatorFunc(func(_ any) (bool, any, error) { return true, "the user", nil }) - failAuth = runtime.AuthenticatorFunc(func(_ interface{}) (bool, interface{}, error) { + failAuth = runtime.AuthenticatorFunc(func(_ any) (bool, any, error) { return true, nil, errors.New("unauthenticated") }) - noApplyAuth = runtime.AuthenticatorFunc(func(_ interface{}) (bool, interface{}, error) { + noApplyAuth = runtime.AuthenticatorFunc(func(_ any) (bool, any, error) { return false, nil, nil }) ) @@ -135,11 +138,11 @@ func TestAuthenticateLogicalAnd(t *testing.T) { require.Equal(t, 2, authorizer.count) var count int - successA := runtime.AuthenticatorFunc(func(_ interface{}) (bool, interface{}, error) { + successA := runtime.AuthenticatorFunc(func(_ any) (bool, any, error) { count++ return true, "the user", nil }) - failA := runtime.AuthenticatorFunc(func(_ interface{}) (bool, interface{}, error) { + failA := runtime.AuthenticatorFunc(func(_ any) (bool, any, error) { count++ return true, nil, errors.New("unauthenticated") }) diff --git a/middleware/route_param_test.go b/middleware/route_param_test.go index 714646a..02727c4 100644 --- a/middleware/route_param_test.go +++ b/middleware/route_param_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware diff --git a/middleware/router.go b/middleware/router.go index 0f93179..1681658 100644 --- a/middleware/router.go +++ b/middleware/router.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -208,13 +197,13 @@ func (ra *RouteAuthenticator) CommonScopes() []string { } // Authenticate Authenticator interface implementation -func (ra *RouteAuthenticator) Authenticate(req *http.Request, route *MatchedRoute) (bool, interface{}, error) { +func (ra *RouteAuthenticator) Authenticate(req *http.Request, route *MatchedRoute) (bool, any, error) { if ra.allowAnonymous { route.Authenticator = ra return true, nil, nil } // iterate in proper order - var lastResult interface{} + var lastResult any for _, scheme := range ra.Schemes { if authenticator, ok := ra.Authenticator[scheme]; ok { applies, princ, err := authenticator.Authenticate(&security.ScopedAuthRequest{ @@ -287,7 +276,7 @@ func (ras RouteAuthenticators) AllowsAnonymous() bool { } // Authenticate method implemention so this collection can be used as authenticator -func (ras RouteAuthenticators) Authenticate(req *http.Request, route *MatchedRoute) (bool, interface{}, error) { +func (ras RouteAuthenticators) Authenticate(req *http.Request, route *MatchedRoute) (bool, any, error) { var lastError error var allowsAnon bool var anonAuth RouteAuthenticator diff --git a/middleware/router_test.go b/middleware/router_test.go index 6d6a56a..f98ae43 100644 --- a/middleware/router_test.go +++ b/middleware/router_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware diff --git a/middleware/security.go b/middleware/security.go index 2b061ca..37ecfa6 100644 --- a/middleware/security.go +++ b/middleware/security.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware diff --git a/middleware/security_test.go b/middleware/security_test.go index 90b01bd..6dbf026 100644 --- a/middleware/security_test.go +++ b/middleware/security_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware diff --git a/middleware/spec.go b/middleware/spec.go index 87e17e3..9cc9940 100644 --- a/middleware/spec.go +++ b/middleware/spec.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware diff --git a/middleware/spec_test.go b/middleware/spec_test.go index 3282461..324da54 100644 --- a/middleware/spec_test.go +++ b/middleware/spec_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware diff --git a/middleware/string_conversion_test.go b/middleware/string_conversion_test.go index 93bcae2..eda31bf 100644 --- a/middleware/string_conversion_test.go +++ b/middleware/string_conversion_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -64,7 +53,7 @@ type SomeOperationParams struct { Categories unmarshallerSlice } -func FloatParamTest(t *testing.T, _, pName, _ string, val reflect.Value, defVal, expectedDef interface{}, actual func() interface{}) { +func FloatParamTest(t *testing.T, _, pName, _ string, val reflect.Value, defVal, expectedDef any, actual func() any) { fld := val.FieldByName(pName) binder := &untypedParamBinder{ parameter: spec.QueryParam(pName).Typed("number", "double").WithDefault(defVal), @@ -83,7 +72,7 @@ func FloatParamTest(t *testing.T, _, pName, _ string, val reflect.Value, defVal, require.Error(t, err) } -func IntParamTest(t *testing.T, pName string, val reflect.Value, defVal, expectedDef interface{}, actual func() interface{}) { +func IntParamTest(t *testing.T, pName string, val reflect.Value, defVal, expectedDef any, actual func() any) { fld := val.FieldByName(pName) binder := &untypedParamBinder{ @@ -121,31 +110,31 @@ func TestParamBinding(t *testing.T) { require.NoError(t, err) assert.Equal(t, "some-name", actual.Name) - IntParamTest(t, "ID", val, 1, 1, func() interface{} { return actual.ID }) - IntParamTest(t, "ID", val, nil, 0, func() interface{} { return actual.ID }) - IntParamTest(t, "Age", val, 1, 1, func() interface{} { return actual.Age }) - IntParamTest(t, "Age", val, nil, 0, func() interface{} { return actual.Age }) - IntParamTest(t, "Visits", val, 1, 1, func() interface{} { return actual.Visits }) - IntParamTest(t, "Visits", val, nil, 0, func() interface{} { return actual.Visits }) - IntParamTest(t, "Count", val, 1, 1, func() interface{} { return actual.Count }) - IntParamTest(t, "Count", val, nil, 0, func() interface{} { return actual.Count }) - IntParamTest(t, "Seq", val, 1, 1, func() interface{} { return actual.Seq }) - IntParamTest(t, "Seq", val, nil, 0, func() interface{} { return actual.Seq }) - IntParamTest(t, "UID", val, uint64(1), 1, func() interface{} { return actual.UID }) - IntParamTest(t, "UID", val, uint64(0), 0, func() interface{} { return actual.UID }) - IntParamTest(t, "UAge", val, uint(1), 1, func() interface{} { return actual.UAge }) - IntParamTest(t, "UAge", val, nil, 0, func() interface{} { return actual.UAge }) - IntParamTest(t, "UVisits", val, uint32(1), 1, func() interface{} { return actual.UVisits }) - IntParamTest(t, "UVisits", val, nil, 0, func() interface{} { return actual.UVisits }) - IntParamTest(t, "UCount", val, uint16(1), 1, func() interface{} { return actual.UCount }) - IntParamTest(t, "UCount", val, nil, 0, func() interface{} { return actual.UCount }) - IntParamTest(t, "USeq", val, uint8(1), 1, func() interface{} { return actual.USeq }) - IntParamTest(t, "USeq", val, nil, 0, func() interface{} { return actual.USeq }) - - FloatParamTest(t, "score", "Score", "float", val, 1.0, 1, func() interface{} { return actual.Score }) - FloatParamTest(t, "score", "Score", "float", val, nil, 0, func() interface{} { return actual.Score }) - FloatParamTest(t, "rate", "Rate", "double", val, 1.0, 1, func() interface{} { return actual.Rate }) - FloatParamTest(t, "rate", "Rate", "double", val, nil, 0, func() interface{} { return actual.Rate }) + IntParamTest(t, "ID", val, 1, 1, func() any { return actual.ID }) + IntParamTest(t, "ID", val, nil, 0, func() any { return actual.ID }) + IntParamTest(t, "Age", val, 1, 1, func() any { return actual.Age }) + IntParamTest(t, "Age", val, nil, 0, func() any { return actual.Age }) + IntParamTest(t, "Visits", val, 1, 1, func() any { return actual.Visits }) + IntParamTest(t, "Visits", val, nil, 0, func() any { return actual.Visits }) + IntParamTest(t, "Count", val, 1, 1, func() any { return actual.Count }) + IntParamTest(t, "Count", val, nil, 0, func() any { return actual.Count }) + IntParamTest(t, "Seq", val, 1, 1, func() any { return actual.Seq }) + IntParamTest(t, "Seq", val, nil, 0, func() any { return actual.Seq }) + IntParamTest(t, "UID", val, uint64(1), 1, func() any { return actual.UID }) + IntParamTest(t, "UID", val, uint64(0), 0, func() any { return actual.UID }) + IntParamTest(t, "UAge", val, uint(1), 1, func() any { return actual.UAge }) + IntParamTest(t, "UAge", val, nil, 0, func() any { return actual.UAge }) + IntParamTest(t, "UVisits", val, uint32(1), 1, func() any { return actual.UVisits }) + IntParamTest(t, "UVisits", val, nil, 0, func() any { return actual.UVisits }) + IntParamTest(t, "UCount", val, uint16(1), 1, func() any { return actual.UCount }) + IntParamTest(t, "UCount", val, nil, 0, func() any { return actual.UCount }) + IntParamTest(t, "USeq", val, uint8(1), 1, func() any { return actual.USeq }) + IntParamTest(t, "USeq", val, nil, 0, func() any { return actual.USeq }) + + FloatParamTest(t, "score", "Score", "float", val, 1.0, 1, func() any { return actual.Score }) + FloatParamTest(t, "score", "Score", "float", val, nil, 0, func() any { return actual.Score }) + FloatParamTest(t, "rate", "Rate", "double", val, 1.0, 1, func() any { return actual.Rate }) + FloatParamTest(t, "rate", "Rate", "double", val, nil, 0, func() any { return actual.Rate }) pName = "Confirmed" confirmedField := val.FieldByName(pName) diff --git a/middleware/swaggerui.go b/middleware/swaggerui.go index ec3c10c..b25a3a2 100644 --- a/middleware/swaggerui.go +++ b/middleware/swaggerui.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/swaggerui_oauth2.go b/middleware/swaggerui_oauth2.go index e81212f..879bdba 100644 --- a/middleware/swaggerui_oauth2.go +++ b/middleware/swaggerui_oauth2.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/swaggerui_oauth2_test.go b/middleware/swaggerui_oauth2_test.go index a19c430..c3c31f8 100644 --- a/middleware/swaggerui_oauth2_test.go +++ b/middleware/swaggerui_oauth2_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/swaggerui_test.go b/middleware/swaggerui_test.go index b299c09..6bcdddd 100644 --- a/middleware/swaggerui_test.go +++ b/middleware/swaggerui_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/ui_options.go b/middleware/ui_options.go index 7a5fb16..cf2f673 100644 --- a/middleware/ui_options.go +++ b/middleware/ui_options.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( @@ -39,7 +42,7 @@ type uiOptions struct { // toCommonUIOptions converts any UI option type to retain the common options. // // This uses gob encoding/decoding to convert common fields from one struct to another. -func toCommonUIOptions(opts interface{}) uiOptions { +func toCommonUIOptions(opts any) uiOptions { var buf bytes.Buffer enc := gob.NewEncoder(&buf) dec := gob.NewDecoder(&buf) diff --git a/middleware/ui_options_test.go b/middleware/ui_options_test.go index 7183369..686f94f 100644 --- a/middleware/ui_options_test.go +++ b/middleware/ui_options_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package middleware import ( diff --git a/middleware/untyped/api.go b/middleware/untyped/api.go index a98d669..774da0b 100644 --- a/middleware/untyped/api.go +++ b/middleware/untyped/api.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package untyped diff --git a/middleware/untyped/api_test.go b/middleware/untyped/api_test.go index fa2a1fe..238e746 100644 --- a/middleware/untyped/api_test.go +++ b/middleware/untyped/api_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package untyped @@ -30,36 +19,36 @@ import ( ) func stubAutenticator() runtime.Authenticator { - return runtime.AuthenticatorFunc(func(_ interface{}) (bool, interface{}, error) { return false, nil, nil }) + return runtime.AuthenticatorFunc(func(_ any) (bool, any, error) { return false, nil, nil }) } func stubAuthorizer() runtime.Authorizer { - return runtime.AuthorizerFunc(func(_ *http.Request, _ interface{}) error { return nil }) + return runtime.AuthorizerFunc(func(_ *http.Request, _ any) error { return nil }) } type stubConsumer struct { } -func (s *stubConsumer) Consume(_ io.Reader, _ interface{}) error { +func (s *stubConsumer) Consume(_ io.Reader, _ any) error { return nil } type stubProducer struct { } -func (s *stubProducer) Produce(_ io.Writer, _ interface{}) error { +func (s *stubProducer) Produce(_ io.Writer, _ any) error { return nil } type stubOperationHandler struct { } -func (s *stubOperationHandler) ParameterModel() interface{} { +func (s *stubOperationHandler) ParameterModel() any { return nil } -func (s *stubOperationHandler) Handle(_ interface{}) (interface{}, error) { - return map[string]interface{}{}, nil +func (s *stubOperationHandler) Handle(_ any) (any, error) { + return map[string]any{}, nil } func TestUntypedAPIRegistrations(t *testing.T) { @@ -271,14 +260,14 @@ func TestUntypedAppValidation(t *testing.T) { authenticators := api3.AuthenticatorsFor(definitions) assert.Len(t, authenticators, 1) - opHandler := runtime.OperationHandlerFunc(func(data interface{}) (interface{}, error) { + opHandler := runtime.OperationHandlerFunc(func(data any) (any, error) { return data, nil }) d, err := opHandler.Handle(1) require.NoError(t, err) assert.Equal(t, 1, d) - authenticator := runtime.AuthenticatorFunc(func(params interface{}) (bool, interface{}, error) { + authenticator := runtime.AuthenticatorFunc(func(params any) (bool, any, error) { if str, ok := params.(string); ok { return ok, str, nil } diff --git a/middleware/untyped_request_test.go b/middleware/untyped_request_test.go index 8cdf2c0..e366d66 100644 --- a/middleware/untyped_request_test.go +++ b/middleware/untyped_request_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware @@ -41,7 +30,7 @@ func TestUntypedFormPost(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - data := make(map[string]interface{}) + data := make(map[string]any) require.NoError(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) assert.Equal(t, "the-name", data["name"]) assert.EqualValues(t, 32, data["age"]) @@ -50,7 +39,7 @@ func TestUntypedFormPost(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - data = make(map[string]interface{}) + data = make(map[string]any) require.Error(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) } @@ -71,7 +60,7 @@ func TestUntypedFileUpload(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", writer.FormDataContentType()) - data := make(map[string]interface{}) + data := make(map[string]any) require.NoError(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) assert.Equal(t, "the-name", data["name"]) assert.NotNil(t, data["file"]) @@ -87,13 +76,13 @@ func TestUntypedFileUpload(t *testing.T) { req, err = http.NewRequestWithContext(context.Background(), http.MethodPost, testURL, body) require.NoError(t, err) req.Header.Set("Content-Type", "application/json") - data = make(map[string]interface{}) + data = make(map[string]any) require.Error(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) req, err = http.NewRequestWithContext(context.Background(), http.MethodPost, testURL, body) require.NoError(t, err) req.Header.Set("Content-Type", "application(") - data = make(map[string]interface{}) + data = make(map[string]any) require.Error(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) body = bytes.NewBuffer(nil) @@ -109,7 +98,7 @@ func TestUntypedFileUpload(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", writer.FormDataContentType()) - data = make(map[string]interface{}) + data = make(map[string]any) require.Error(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) req, err = http.NewRequestWithContext(context.Background(), http.MethodPost, testURL, body) @@ -118,7 +107,7 @@ func TestUntypedFileUpload(t *testing.T) { _, err = req.MultipartReader() require.NoError(t, err) - data = make(map[string]interface{}) + data = make(map[string]any) require.Error(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) writer = multipart.NewWriter(body) @@ -129,7 +118,7 @@ func TestUntypedFileUpload(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", writer.FormDataContentType()) - data = make(map[string]interface{}) + data = make(map[string]any) require.Error(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) } @@ -145,7 +134,7 @@ func TestUntypedOptionalFileUpload(t *testing.T) { require.NoError(t, err) req.Header.Set("Content-Type", writer.FormDataContentType()) - data := make(map[string]interface{}) + data := make(map[string]any) require.NoError(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) assert.Equal(t, "the-name", data["name"]) @@ -162,7 +151,7 @@ func TestUntypedOptionalFileUpload(t *testing.T) { req.Header.Set("Content-Type", writer.FormDataContentType()) require.NoError(t, writer.Close()) - data = make(map[string]interface{}) + data = make(map[string]any) require.NoError(t, binder.Bind(req, nil, runtime.JSONConsumer(), &data)) assert.Equal(t, "the-name", data["name"]) assert.NotNil(t, data["file"]) @@ -179,7 +168,7 @@ func TestUntypedBindingTypesForValid(t *testing.T) { confirmed := true name := "thomas" - friend := map[string]interface{}{"name": "toby", "age": json.Number("32")} + friend := map[string]any{"name": "toby", "age": json.Number("32")} id, age, score, factor := int64(7575), int32(348), float32(5.309), float64(37.403) requestID := 19394858 tags := []string{"one", "two", "three"} @@ -206,7 +195,7 @@ func TestUntypedBindingTypesForValid(t *testing.T) { req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Request-Id", "19394858") - data := make(map[string]interface{}) + data := make(map[string]any) err = binder.Bind(req, RouteParams([]RouteParam{{"id", "7575"}}), runtime.JSONConsumer(), &data) require.NoError(t, err) assert.Equal(t, id, data["id"]) diff --git a/middleware/validation.go b/middleware/validation.go index 3879d75..ed026d6 100644 --- a/middleware/validation.go +++ b/middleware/validation.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware diff --git a/middleware/validation_test.go b/middleware/validation_test.go index 3788942..01bda84 100644 --- a/middleware/validation_test.go +++ b/middleware/validation_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package middleware diff --git a/request.go b/request.go index 203dab2..aab7b8c 100644 --- a/request.go +++ b/request.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/request_test.go b/request_test.go index aab9465..1e35831 100644 --- a/request_test.go +++ b/request_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/security/apikey_auth_test.go b/security/apikey_auth_test.go index 3899f73..cf216f1 100644 --- a/security/apikey_auth_test.go +++ b/security/apikey_auth_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package security @@ -31,7 +20,7 @@ const ( ) func TestApiKeyAuth(t *testing.T) { - tokenAuth := TokenAuthentication(func(token string) (interface{}, error) { + tokenAuth := TokenAuthentication(func(token string) (any, error) { if token == validToken { return principal, nil } @@ -117,7 +106,7 @@ func TestApiKeyAuth(t *testing.T) { } func TestApiKeyAuthCtx(t *testing.T) { - tokenAuthCtx := TokenAuthenticationCtx(func(ctx context.Context, token string) (context.Context, interface{}, error) { + tokenAuthCtx := TokenAuthenticationCtx(func(ctx context.Context, token string) (context.Context, any, error) { if token == validToken { return context.WithValue(ctx, extra, extraWisdom), principal, nil } diff --git a/security/authenticator.go b/security/authenticator.go index def3746..b5b7904 100644 --- a/security/authenticator.go +++ b/security/authenticator.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package security @@ -31,8 +20,8 @@ const ( ) // HttpAuthenticator is a function that authenticates a HTTP request -func HttpAuthenticator(handler func(*http.Request) (bool, interface{}, error)) runtime.Authenticator { //nolint:revive - return runtime.AuthenticatorFunc(func(params interface{}) (bool, interface{}, error) { +func HttpAuthenticator(handler func(*http.Request) (bool, any, error)) runtime.Authenticator { //nolint:revive + return runtime.AuthenticatorFunc(func(params any) (bool, any, error) { if request, ok := params.(*http.Request); ok { return handler(request) } @@ -44,8 +33,8 @@ func HttpAuthenticator(handler func(*http.Request) (bool, interface{}, error)) r } // ScopedAuthenticator is a function that authenticates a HTTP request against a list of valid scopes -func ScopedAuthenticator(handler func(*ScopedAuthRequest) (bool, interface{}, error)) runtime.Authenticator { - return runtime.AuthenticatorFunc(func(params interface{}) (bool, interface{}, error) { +func ScopedAuthenticator(handler func(*ScopedAuthRequest) (bool, any, error)) runtime.Authenticator { + return runtime.AuthenticatorFunc(func(params any) (bool, any, error) { if request, ok := params.(*ScopedAuthRequest); ok { return handler(request) } @@ -54,22 +43,22 @@ func ScopedAuthenticator(handler func(*ScopedAuthRequest) (bool, interface{}, er } // UserPassAuthentication authentication function -type UserPassAuthentication func(string, string) (interface{}, error) +type UserPassAuthentication func(string, string) (any, error) // UserPassAuthenticationCtx authentication function with context.Context -type UserPassAuthenticationCtx func(context.Context, string, string) (context.Context, interface{}, error) +type UserPassAuthenticationCtx func(context.Context, string, string) (context.Context, any, error) // TokenAuthentication authentication function -type TokenAuthentication func(string) (interface{}, error) +type TokenAuthentication func(string) (any, error) // TokenAuthenticationCtx authentication function with context.Context -type TokenAuthenticationCtx func(context.Context, string) (context.Context, interface{}, error) +type TokenAuthenticationCtx func(context.Context, string) (context.Context, any, error) // ScopedTokenAuthentication authentication function -type ScopedTokenAuthentication func(string, []string) (interface{}, error) +type ScopedTokenAuthentication func(string, []string) (any, error) // ScopedTokenAuthenticationCtx authentication function with context.Context -type ScopedTokenAuthenticationCtx func(context.Context, string, []string) (context.Context, interface{}, error) +type ScopedTokenAuthenticationCtx func(context.Context, string, []string) (context.Context, any, error) var DefaultRealmName = "API" @@ -115,7 +104,7 @@ func BasicAuthRealm(realm string, authenticate UserPassAuthentication) runtime.A realm = DefaultRealmName } - return HttpAuthenticator(func(r *http.Request) (bool, interface{}, error) { + return HttpAuthenticator(func(r *http.Request) (bool, any, error) { if usr, pass, ok := r.BasicAuth(); ok { p, err := authenticate(usr, pass) if err != nil { @@ -139,7 +128,7 @@ func BasicAuthRealmCtx(realm string, authenticate UserPassAuthenticationCtx) run realm = DefaultRealmName } - return HttpAuthenticator(func(r *http.Request) (bool, interface{}, error) { + return HttpAuthenticator(func(r *http.Request) (bool, any, error) { if usr, pass, ok := r.BasicAuth(); ok { ctx, p, err := authenticate(r.Context(), usr, pass) if err != nil { @@ -170,7 +159,7 @@ func APIKeyAuth(name, in string, authenticate TokenAuthentication) runtime.Authe getToken = func(r *http.Request) string { return r.URL.Query().Get(name) } } - return HttpAuthenticator(func(r *http.Request) (bool, interface{}, error) { + return HttpAuthenticator(func(r *http.Request) (bool, any, error) { token := getToken(r) if token == "" { return false, nil, nil @@ -198,7 +187,7 @@ func APIKeyAuthCtx(name, in string, authenticate TokenAuthenticationCtx) runtime getToken = func(r *http.Request) string { return r.URL.Query().Get(name) } } - return HttpAuthenticator(func(r *http.Request) (bool, interface{}, error) { + return HttpAuthenticator(func(r *http.Request) (bool, any, error) { token := getToken(r) if token == "" { return false, nil, nil @@ -219,11 +208,11 @@ type ScopedAuthRequest struct { // BearerAuth for use with oauth2 flows func BearerAuth(name string, authenticate ScopedTokenAuthentication) runtime.Authenticator { const prefix = "Bearer " - return ScopedAuthenticator(func(r *ScopedAuthRequest) (bool, interface{}, error) { + return ScopedAuthenticator(func(r *ScopedAuthRequest) (bool, any, error) { var token string hdr := r.Request.Header.Get(runtime.HeaderAuthorization) - if strings.HasPrefix(hdr, prefix) { - token = strings.TrimPrefix(hdr, prefix) + if after, ok := strings.CutPrefix(hdr, prefix); ok { + token = after } if token == "" { qs := r.Request.URL.Query() @@ -249,11 +238,11 @@ func BearerAuth(name string, authenticate ScopedTokenAuthentication) runtime.Aut // BearerAuthCtx for use with oauth2 flows with support for context.Context. func BearerAuthCtx(name string, authenticate ScopedTokenAuthenticationCtx) runtime.Authenticator { const prefix = "Bearer " - return ScopedAuthenticator(func(r *ScopedAuthRequest) (bool, interface{}, error) { + return ScopedAuthenticator(func(r *ScopedAuthRequest) (bool, any, error) { var token string hdr := r.Request.Header.Get(runtime.HeaderAuthorization) - if strings.HasPrefix(hdr, prefix) { - token = strings.TrimPrefix(hdr, prefix) + if after, ok := strings.CutPrefix(hdr, prefix); ok { + token = after } if token == "" { qs := r.Request.URL.Query() diff --git a/security/authorizer.go b/security/authorizer.go index 00c1a4d..69bd497 100644 --- a/security/authorizer.go +++ b/security/authorizer.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package security @@ -23,5 +12,5 @@ import ( // Authorized provides a default implementation of the Authorizer interface where all // requests are authorized (successful) func Authorized() runtime.Authorizer { - return runtime.AuthorizerFunc(func(_ *http.Request, _ interface{}) error { return nil }) + return runtime.AuthorizerFunc(func(_ *http.Request, _ any) error { return nil }) } diff --git a/security/authorizer_test.go b/security/authorizer_test.go index 5463748..0b68b5c 100644 --- a/security/authorizer_test.go +++ b/security/authorizer_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package security @@ -35,7 +24,7 @@ func TestAuthenticator(t *testing.T) { require.NoError(t, err) t.Run("with HttpAuthenticator", func(t *testing.T) { - auth := HttpAuthenticator(func(_ *http.Request) (bool, interface{}, error) { return true, "test", nil }) + auth := HttpAuthenticator(func(_ *http.Request) (bool, any, error) { return true, "test", nil }) t.Run("authenticator should work on *http.Request", func(t *testing.T) { isAuth, user, err := auth.Authenticate(r) @@ -62,7 +51,7 @@ func TestAuthenticator(t *testing.T) { }) t.Run("with ScopedAuthenticator", func(t *testing.T) { - auth := ScopedAuthenticator(func(_ *ScopedAuthRequest) (bool, interface{}, error) { return true, "test", nil }) + auth := ScopedAuthenticator(func(_ *ScopedAuthRequest) (bool, any, error) { return true, "test", nil }) t.Run("authenticator should work on *ScopedAuthRequest", func(t *testing.T) { scoped := &ScopedAuthRequest{Request: r} diff --git a/security/basic_auth_test.go b/security/basic_auth_test.go index 65aad8a..b2ad1b4 100644 --- a/security/basic_auth_test.go +++ b/security/basic_auth_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package security @@ -40,7 +29,7 @@ const ( ) func TestBasicAuth(t *testing.T) { - basicAuthHandler := UserPassAuthentication(func(user, pass string) (interface{}, error) { + basicAuthHandler := UserPassAuthentication(func(user, pass string) (any, error) { if user == principal && pass == testPassword { return principal, nil } @@ -123,7 +112,7 @@ func TestBasicAuth(t *testing.T) { } func TestBasicAuthCtx(t *testing.T) { - basicAuthHandlerCtx := UserPassAuthenticationCtx(func(ctx context.Context, user, pass string) (context.Context, interface{}, error) { + basicAuthHandlerCtx := UserPassAuthenticationCtx(func(ctx context.Context, user, pass string) (context.Context, any, error) { if user == principal && pass == testPassword { return context.WithValue(ctx, extra, extraWisdom), principal, nil } diff --git a/security/bearer_auth_test.go b/security/bearer_auth_test.go index eea0c59..4fe4c20 100644 --- a/security/bearer_auth_test.go +++ b/security/bearer_auth_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package security import ( @@ -34,7 +37,7 @@ const ( ) func TestBearerAuth(t *testing.T) { - bearerAuth := ScopedTokenAuthentication(func(token string, _ []string) (interface{}, error) { + bearerAuth := ScopedTokenAuthentication(func(token string, _ []string) (any, error) { if token == validToken { return principal, nil } @@ -90,7 +93,7 @@ func TestBearerAuth(t *testing.T) { } func TestBearerAuthCtx(t *testing.T) { - bearerAuthCtx := ScopedTokenAuthenticationCtx(func(ctx context.Context, token string, _ []string) (context.Context, interface{}, error) { + bearerAuthCtx := ScopedTokenAuthenticationCtx(func(ctx context.Context, token string, _ []string) (context.Context, any, error) { if token == validToken { return context.WithValue(ctx, extra, extraWisdom), principal, nil } diff --git a/statuses.go b/statuses.go index 3b011a0..7e10a5a 100644 --- a/statuses.go +++ b/statuses.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/text.go b/text.go index d8dee94..2b8e4ac 100644 --- a/text.go +++ b/text.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -27,7 +16,7 @@ import ( // TextConsumer creates a new text consumer func TextConsumer() Consumer { - return ConsumerFunc(func(reader io.Reader, data interface{}) error { + return ConsumerFunc(func(reader io.Reader, data any) error { if reader == nil { return errors.New("TextConsumer requires a reader") // early exit } @@ -69,7 +58,7 @@ func TextConsumer() Consumer { // TextProducer creates a new text producer func TextProducer() Producer { - return ProducerFunc(func(writer io.Writer, data interface{}) error { + return ProducerFunc(func(writer io.Writer, data any) error { if writer == nil { return errors.New("TextProducer requires a writer") // early exit } diff --git a/text_test.go b/text_test.go index 5f2f727..fef2041 100644 --- a/text_test.go +++ b/text_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/values.go b/values.go index 11f5732..19894e7 100644 --- a/values.go +++ b/values.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package runtime // Values typically represent parameters on a http request. diff --git a/values_test.go b/values_test.go index 7f341cb..2a4269c 100644 --- a/values_test.go +++ b/values_test.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 + package runtime import ( diff --git a/xml.go b/xml.go index 821c739..5060b5c 100644 --- a/xml.go +++ b/xml.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime @@ -21,7 +10,7 @@ import ( // XMLConsumer creates a new XML consumer func XMLConsumer() Consumer { - return ConsumerFunc(func(reader io.Reader, data interface{}) error { + return ConsumerFunc(func(reader io.Reader, data any) error { dec := xml.NewDecoder(reader) return dec.Decode(data) }) @@ -29,7 +18,7 @@ func XMLConsumer() Consumer { // XMLProducer creates a new XML producer func XMLProducer() Producer { - return ProducerFunc(func(writer io.Writer, data interface{}) error { + return ProducerFunc(func(writer io.Writer, data any) error { enc := xml.NewEncoder(writer) return enc.Encode(data) }) diff --git a/xml_test.go b/xml_test.go index 9da96bb..44e4c0e 100644 --- a/xml_test.go +++ b/xml_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package runtime diff --git a/yamlpc/yaml.go b/yamlpc/yaml.go index 467408c..ca63430 100644 --- a/yamlpc/yaml.go +++ b/yamlpc/yaml.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package yamlpc diff --git a/yamlpc/yaml_test.go b/yamlpc/yaml_test.go index befbba7..ac795fb 100644 --- a/yamlpc/yaml_test.go +++ b/yamlpc/yaml_test.go @@ -1,16 +1,5 @@ -// Copyright 2015 go-swagger maintainers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-FileCopyrightText: Copyright 2015-2025 go-swagger maintainers +// SPDX-License-Identifier: Apache-2.0 package yamlpc From 97d4db8dd6700363a52ccf196827e8f5dacb0271 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Sun, 9 Nov 2025 17:04:44 +0100 Subject: [PATCH 3/4] tests: replaced stretchr/testify by go-openapi/testify Signed-off-by: Frederic BIDON --- authinfo_test.go | 4 +- bytestream_test.go | 4 +- client-middleware/opentracing/go.mod | 28 +++++----- client-middleware/opentracing/go.sum | 54 ++++++++++--------- .../opentracing/opentracing_test.go | 8 +-- client-middleware/opentracing/runtime.go | 1 + client/auth_info_test.go | 4 +- client/keepalive_test.go | 4 +- client/opentelemetry_test.go | 4 +- client/request_test.go | 4 +- client/response_test.go | 2 +- client/runtime_test.go | 4 +- client/runtime_tls_test.go | 4 +- client_request_test.go | 2 +- client_response_test.go | 4 +- csv_test.go | 4 +- file_test.go | 4 +- flagext/byte_size_test.go | 4 +- go.mod | 31 +++++------ go.sum | 54 ++++++++++--------- go.work.sum | 5 ++ headers_test.go | 6 +-- internal/testing/data_test.go | 2 +- internal/testing/petstore/api.go | 2 +- internal/testing/petstore/api_test.go | 2 +- internal/testing/simplepetstore/api_test.go | 4 +- json_test.go | 4 +- logger/logger_test.go | 2 +- middleware/body_test.go | 4 +- middleware/context_test.go | 4 +- middleware/debug_test.go | 4 +- middleware/denco/router_test.go | 4 +- middleware/denco/server_test.go | 4 +- middleware/header/header_test.go | 2 +- middleware/not_implemented_test.go | 2 +- middleware/operation_test.go | 4 +- middleware/parameter_test.go | 4 +- middleware/rapidoc_test.go | 4 +- middleware/redoc_test.go | 4 +- middleware/request_test.go | 4 +- middleware/route_authenticator_test.go | 2 +- middleware/route_param_test.go | 2 +- middleware/router_test.go | 4 +- middleware/security_test.go | 4 +- middleware/spec_test.go | 6 +-- middleware/string_conversion_test.go | 4 +- middleware/swaggerui_oauth2_test.go | 4 +- middleware/swaggerui_test.go | 4 +- middleware/ui_options_test.go | 2 +- middleware/untyped/api_test.go | 4 +- middleware/untyped_request_test.go | 4 +- middleware/validation_test.go | 6 +-- request_test.go | 8 +-- security/apikey_auth_test.go | 4 +- security/authorizer_test.go | 4 +- security/basic_auth_test.go | 4 +- security/bearer_auth_test.go | 4 +- text_test.go | 4 +- values_test.go | 2 +- xml_test.go | 4 +- yamlpc/yaml_test.go | 5 +- 61 files changed, 194 insertions(+), 190 deletions(-) diff --git a/authinfo_test.go b/authinfo_test.go index d3d8b22..2ffab29 100644 --- a/authinfo_test.go +++ b/authinfo_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/go-openapi/strfmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestAuthInfoWriter(t *testing.T) { diff --git a/bytestream_test.go b/bytestream_test.go index 38b45e6..6e6d342 100644 --- a/bytestream_test.go +++ b/bytestream_test.go @@ -12,8 +12,8 @@ import ( "sync/atomic" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestByteStreamConsumer(t *testing.T) { diff --git a/client-middleware/opentracing/go.mod b/client-middleware/opentracing/go.mod index 039d409..a766e40 100644 --- a/client-middleware/opentracing/go.mod +++ b/client-middleware/opentracing/go.mod @@ -2,22 +2,20 @@ module github.com/go-openapi/runtime/client-middleware/opentracing require ( github.com/go-openapi/runtime v0.28.0 - github.com/go-openapi/strfmt v0.24.0 + github.com/go-openapi/strfmt v0.25.0 + github.com/go-openapi/testify/v2 v2.0.2 github.com/opentracing/opentracing-go v1.2.0 - github.com/stretchr/testify v1.11.1 ) require ( - github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/analysis v0.24.0 // indirect - github.com/go-openapi/errors v0.22.3 // indirect + github.com/go-openapi/analysis v0.24.1 // indirect + github.com/go-openapi/errors v0.22.4 // indirect github.com/go-openapi/jsonpointer v0.22.1 // indirect - github.com/go-openapi/jsonreference v0.21.2 // indirect - github.com/go-openapi/loads v0.23.1 // indirect - github.com/go-openapi/spec v0.22.0 // indirect + github.com/go-openapi/jsonreference v0.21.3 // indirect + github.com/go-openapi/loads v0.23.2 // indirect + github.com/go-openapi/spec v0.22.1 // indirect github.com/go-openapi/swag/conv v0.25.1 // indirect github.com/go-openapi/swag/fileutils v0.25.1 // indirect github.com/go-openapi/swag/jsonname v0.25.1 // indirect @@ -27,21 +25,19 @@ require ( github.com/go-openapi/swag/stringutils v0.25.1 // indirect github.com/go-openapi/swag/typeutils v0.25.1 // indirect github.com/go-openapi/swag/yamlutils v0.25.1 // indirect - github.com/go-openapi/validate v0.25.0 // indirect + github.com/go-openapi/validate v0.25.1 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/oklog/ulid v1.3.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - go.mongodb.org/mongo-driver v1.17.4 // indirect + go.mongodb.org/mongo-driver v1.17.6 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/otel v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.44.0 // indirect - golang.org/x/sync v0.17.0 // indirect - golang.org/x/text v0.29.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + golang.org/x/net v0.46.0 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/text v0.30.0 // indirect ) replace github.com/go-openapi/runtime => ../.. diff --git a/client-middleware/opentracing/go.sum b/client-middleware/opentracing/go.sum index 9a074a4..25f19f3 100644 --- a/client-middleware/opentracing/go.sum +++ b/client-middleware/opentracing/go.sum @@ -1,5 +1,3 @@ -github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= -github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -8,20 +6,20 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-openapi/analysis v0.24.0 h1:vE/VFFkICKyYuTWYnplQ+aVr45vlG6NcZKC7BdIXhsA= -github.com/go-openapi/analysis v0.24.0/go.mod h1:GLyoJA+bvmGGaHgpfeDh8ldpGo69fAJg7eeMDMRCIrw= -github.com/go-openapi/errors v0.22.3 h1:k6Hxa5Jg1TUyZnOwV2Lh81j8ayNw5VVYLvKrp4zFKFs= -github.com/go-openapi/errors v0.22.3/go.mod h1:+WvbaBBULWCOna//9B9TbLNGSFOfF8lY9dw4hGiEiKQ= +github.com/go-openapi/analysis v0.24.1 h1:Xp+7Yn/KOnVWYG8d+hPksOYnCYImE3TieBa7rBOesYM= +github.com/go-openapi/analysis v0.24.1/go.mod h1:dU+qxX7QGU1rl7IYhBC8bIfmWQdX4Buoea4TGtxXY84= +github.com/go-openapi/errors v0.22.4 h1:oi2K9mHTOb5DPW2Zjdzs/NIvwi2N3fARKaTJLdNabaM= +github.com/go-openapi/errors v0.22.4/go.mod h1:z9S8ASTUqx7+CP1Q8dD8ewGH/1JWFFLX/2PmAYNQLgk= github.com/go-openapi/jsonpointer v0.22.1 h1:sHYI1He3b9NqJ4wXLoJDKmUmHkWy/L7rtEo92JUxBNk= github.com/go-openapi/jsonpointer v0.22.1/go.mod h1:pQT9OsLkfz1yWoMgYFy4x3U5GY5nUlsOn1qSBH5MkCM= -github.com/go-openapi/jsonreference v0.21.2 h1:Wxjda4M/BBQllegefXrY/9aq1fxBA8sI5M/lFU6tSWU= -github.com/go-openapi/jsonreference v0.21.2/go.mod h1:pp3PEjIsJ9CZDGCNOyXIQxsNuroxm8FAJ/+quA0yKzQ= -github.com/go-openapi/loads v0.23.1 h1:H8A0dX2KDHxDzc797h0+uiCZ5kwE2+VojaQVaTlXvS0= -github.com/go-openapi/loads v0.23.1/go.mod h1:hZSXkyACCWzWPQqizAv/Ye0yhi2zzHwMmoXQ6YQml44= -github.com/go-openapi/spec v0.22.0 h1:xT/EsX4frL3U09QviRIZXvkh80yibxQmtoEvyqug0Tw= -github.com/go-openapi/spec v0.22.0/go.mod h1:K0FhKxkez8YNS94XzF8YKEMULbFrRw4m15i2YUht4L0= -github.com/go-openapi/strfmt v0.24.0 h1:dDsopqbI3wrrlIzeXRbqMihRNnjzGC+ez4NQaAAJLuc= -github.com/go-openapi/strfmt v0.24.0/go.mod h1:Lnn1Bk9rZjXxU9VMADbEEOo7D7CDyKGLsSKekhFr7s4= +github.com/go-openapi/jsonreference v0.21.3 h1:96Dn+MRPa0nYAR8DR1E03SblB5FJvh7W6krPI0Z7qMc= +github.com/go-openapi/jsonreference v0.21.3/go.mod h1:RqkUP0MrLf37HqxZxrIAtTWW4ZJIK1VzduhXYBEeGc4= +github.com/go-openapi/loads v0.23.2 h1:rJXAcP7g1+lWyBHC7iTY+WAF0rprtM+pm8Jxv1uQJp4= +github.com/go-openapi/loads v0.23.2/go.mod h1:IEVw1GfRt/P2Pplkelxzj9BYFajiWOtY2nHZNj4UnWY= +github.com/go-openapi/spec v0.22.1 h1:beZMa5AVQzRspNjvhe5aG1/XyBSMeX1eEOs7dMoXh/k= +github.com/go-openapi/spec v0.22.1/go.mod h1:c7aeIQT175dVowfp7FeCvXXnjN/MrpaONStibD2WtDA= +github.com/go-openapi/strfmt v0.25.0 h1:7R0RX7mbKLa9EYCTHRcCuIPcaqlyQiWNPTXwClK0saQ= +github.com/go-openapi/strfmt v0.25.0/go.mod h1:nNXct7OzbwrMY9+5tLX4I21pzcmE6ccMGXl3jFdPfn8= github.com/go-openapi/swag/conv v0.25.1 h1:+9o8YUg6QuqqBM5X6rYL/p1dpWeZRhoIt9x7CCP+he0= github.com/go-openapi/swag/conv v0.25.1/go.mod h1:Z1mFEGPfyIKPu0806khI3zF+/EUXde+fdeksUl2NiDs= github.com/go-openapi/swag/fileutils v0.25.1 h1:rSRXapjQequt7kqalKXdcpIegIShhTPXx7yw0kek2uU= @@ -42,8 +40,12 @@ github.com/go-openapi/swag/typeutils v0.25.1 h1:rD/9HsEQieewNt6/k+JBwkxuAHktFtH3 github.com/go-openapi/swag/typeutils v0.25.1/go.mod h1:9McMC/oCdS4BKwk2shEB7x17P6HmMmA6dQRtAkSnNb8= github.com/go-openapi/swag/yamlutils v0.25.1 h1:mry5ez8joJwzvMbaTGLhw8pXUnhDK91oSJLDPF1bmGk= github.com/go-openapi/swag/yamlutils v0.25.1/go.mod h1:cm9ywbzncy3y6uPm/97ysW8+wZ09qsks+9RS8fLWKqg= -github.com/go-openapi/validate v0.25.0 h1:JD9eGX81hDTjoY3WOzh6WqxVBVl7xjsLnvDo1GL5WPU= -github.com/go-openapi/validate v0.25.0/go.mod h1:SUY7vKrN5FiwK6LyvSwKjDfLNirSfWwHNgxd2l29Mmw= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 h1:0+Y41Pz1NkbTHz8NngxTuAXxEodtNSI1WG1c/m5Akw4= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2/go.mod h1:kme83333GCtJQHXQ8UKX3IBZu6z8T5Dvy5+CW3NLUUg= +github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= +github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= +github.com/go-openapi/validate v0.25.1 h1:sSACUI6Jcnbo5IWqbYHgjibrhhmt3vR6lCzKZnmAgBw= +github.com/go-openapi/validate v0.25.1/go.mod h1:RMVyVFYte0gbSTaZ0N4KmTn6u/kClvAFp+mAVfS/DQc= github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -66,8 +68,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw= -go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= +go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss= +go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -80,14 +82,14 @@ go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJr go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= -golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= -golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= -golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= -golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= -golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= +golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4= +golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= +golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= +golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/client-middleware/opentracing/opentracing_test.go b/client-middleware/opentracing/opentracing_test.go index aa2e911..da185bb 100644 --- a/client-middleware/opentracing/opentracing_test.go +++ b/client-middleware/opentracing/opentracing_test.go @@ -9,15 +9,15 @@ import ( "io" "testing" + "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" + "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "github.com/opentracing/opentracing-go/mocktracer" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/go-openapi/runtime" ) type tres struct { diff --git a/client-middleware/opentracing/runtime.go b/client-middleware/opentracing/runtime.go index 727b671..c9759cc 100644 --- a/client-middleware/opentracing/runtime.go +++ b/client-middleware/opentracing/runtime.go @@ -6,6 +6,7 @@ package opentracing import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/client" + opentracing "github.com/opentracing/opentracing-go" ) diff --git a/client/auth_info_test.go b/client/auth_info_test.go index 1efd5a7..666df91 100644 --- a/client/auth_info_test.go +++ b/client/auth_info_test.go @@ -7,8 +7,8 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" "github.com/go-openapi/runtime" ) diff --git a/client/keepalive_test.go b/client/keepalive_test.go index d97f4eb..26d010a 100644 --- a/client/keepalive_test.go +++ b/client/keepalive_test.go @@ -8,8 +8,8 @@ import ( "io" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func newCountingReader(rdr io.Reader, readOnce bool) *countingReadCloser { diff --git a/client/opentelemetry_test.go b/client/opentelemetry_test.go index 3c9a08a..8bf7c08 100644 --- a/client/opentelemetry_test.go +++ b/client/opentelemetry_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/go-openapi/runtime" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" diff --git a/client/request_test.go b/client/request_test.go index 240fb48..adf2b31 100644 --- a/client/request_test.go +++ b/client/request_test.go @@ -20,8 +20,8 @@ import ( "testing" "github.com/go-openapi/strfmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" "github.com/go-openapi/runtime" ) diff --git a/client/response_test.go b/client/response_test.go index c4b9a8b..50d851f 100644 --- a/client/response_test.go +++ b/client/response_test.go @@ -9,7 +9,7 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" + "github.com/go-openapi/testify/v2/assert" "github.com/go-openapi/runtime" ) diff --git a/client/runtime_test.go b/client/runtime_test.go index 6dab300..0b63aac 100644 --- a/client/runtime_test.go +++ b/client/runtime_test.go @@ -20,8 +20,8 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) const ( diff --git a/client/runtime_tls_test.go b/client/runtime_tls_test.go index 3dd0cf1..cbb1993 100644 --- a/client/runtime_tls_test.go +++ b/client/runtime_tls_test.go @@ -21,8 +21,8 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestRuntimeTLSOptions(t *testing.T) { diff --git a/client_request_test.go b/client_request_test.go index 8d1e420..4827a9d 100644 --- a/client_request_test.go +++ b/client_request_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/go-openapi/strfmt" - "github.com/stretchr/testify/assert" + "github.com/go-openapi/testify/v2/assert" ) func TestRequestWriterFunc(t *testing.T) { diff --git a/client_response_test.go b/client_response_test.go index 33a3929..8a0169b 100644 --- a/client_response_test.go +++ b/client_response_test.go @@ -10,8 +10,8 @@ import ( "io/fs" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) type response struct { diff --git a/csv_test.go b/csv_test.go index fc32641..c4357bc 100644 --- a/csv_test.go +++ b/csv_test.go @@ -12,8 +12,8 @@ import ( "strings" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) const ( diff --git a/file_test.go b/file_test.go index 6213723..637afd9 100644 --- a/file_test.go +++ b/file_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/go-openapi/spec" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" "github.com/go-openapi/validate" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestValidateFile(t *testing.T) { diff --git a/flagext/byte_size_test.go b/flagext/byte_size_test.go index 79a4e9a..7c50888 100644 --- a/flagext/byte_size_test.go +++ b/flagext/byte_size_test.go @@ -6,8 +6,8 @@ package flagext import ( "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestMarshalBytesize(t *testing.T) { diff --git a/go.mod b/go.mod index b22ee02..a4ae56f 100644 --- a/go.mod +++ b/go.mod @@ -2,28 +2,27 @@ module github.com/go-openapi/runtime require ( github.com/docker/go-units v0.5.0 - github.com/go-openapi/analysis v0.24.0 - github.com/go-openapi/errors v0.22.3 - github.com/go-openapi/loads v0.23.1 - github.com/go-openapi/spec v0.22.0 - github.com/go-openapi/strfmt v0.24.0 + github.com/go-openapi/analysis v0.24.1 + github.com/go-openapi/errors v0.22.4 + github.com/go-openapi/loads v0.23.2 + github.com/go-openapi/spec v0.22.1 + github.com/go-openapi/strfmt v0.25.0 github.com/go-openapi/swag/fileutils v0.25.1 - github.com/go-openapi/validate v0.25.0 - github.com/stretchr/testify v1.11.1 + github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 + github.com/go-openapi/testify/v2 v2.0.2 + github.com/go-openapi/validate v0.25.1 go.opentelemetry.io/otel v1.38.0 go.opentelemetry.io/otel/sdk v1.38.0 go.opentelemetry.io/otel/trace v1.38.0 go.yaml.in/yaml/v3 v3.0.4 - golang.org/x/sync v0.17.0 + golang.org/x/sync v0.18.0 ) require ( - github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.22.1 // indirect - github.com/go-openapi/jsonreference v0.21.2 // indirect + github.com/go-openapi/jsonreference v0.21.3 // indirect github.com/go-openapi/swag/conv v0.25.1 github.com/go-openapi/swag/jsonname v0.25.1 // indirect github.com/go-openapi/swag/jsonutils v0.25.1 @@ -35,14 +34,12 @@ require ( github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/oklog/ulid v1.3.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - go.mongodb.org/mongo-driver v1.17.4 // indirect + go.mongodb.org/mongo-driver v1.17.6 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect - golang.org/x/net v0.44.0 // indirect - golang.org/x/sys v0.36.0 // indirect - golang.org/x/text v0.29.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + golang.org/x/net v0.46.0 // indirect + golang.org/x/sys v0.37.0 // indirect + golang.org/x/text v0.30.0 // indirect ) go 1.24.0 diff --git a/go.sum b/go.sum index 2656b72..1532745 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= -github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -9,20 +7,20 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-openapi/analysis v0.24.0 h1:vE/VFFkICKyYuTWYnplQ+aVr45vlG6NcZKC7BdIXhsA= -github.com/go-openapi/analysis v0.24.0/go.mod h1:GLyoJA+bvmGGaHgpfeDh8ldpGo69fAJg7eeMDMRCIrw= -github.com/go-openapi/errors v0.22.3 h1:k6Hxa5Jg1TUyZnOwV2Lh81j8ayNw5VVYLvKrp4zFKFs= -github.com/go-openapi/errors v0.22.3/go.mod h1:+WvbaBBULWCOna//9B9TbLNGSFOfF8lY9dw4hGiEiKQ= +github.com/go-openapi/analysis v0.24.1 h1:Xp+7Yn/KOnVWYG8d+hPksOYnCYImE3TieBa7rBOesYM= +github.com/go-openapi/analysis v0.24.1/go.mod h1:dU+qxX7QGU1rl7IYhBC8bIfmWQdX4Buoea4TGtxXY84= +github.com/go-openapi/errors v0.22.4 h1:oi2K9mHTOb5DPW2Zjdzs/NIvwi2N3fARKaTJLdNabaM= +github.com/go-openapi/errors v0.22.4/go.mod h1:z9S8ASTUqx7+CP1Q8dD8ewGH/1JWFFLX/2PmAYNQLgk= github.com/go-openapi/jsonpointer v0.22.1 h1:sHYI1He3b9NqJ4wXLoJDKmUmHkWy/L7rtEo92JUxBNk= github.com/go-openapi/jsonpointer v0.22.1/go.mod h1:pQT9OsLkfz1yWoMgYFy4x3U5GY5nUlsOn1qSBH5MkCM= -github.com/go-openapi/jsonreference v0.21.2 h1:Wxjda4M/BBQllegefXrY/9aq1fxBA8sI5M/lFU6tSWU= -github.com/go-openapi/jsonreference v0.21.2/go.mod h1:pp3PEjIsJ9CZDGCNOyXIQxsNuroxm8FAJ/+quA0yKzQ= -github.com/go-openapi/loads v0.23.1 h1:H8A0dX2KDHxDzc797h0+uiCZ5kwE2+VojaQVaTlXvS0= -github.com/go-openapi/loads v0.23.1/go.mod h1:hZSXkyACCWzWPQqizAv/Ye0yhi2zzHwMmoXQ6YQml44= -github.com/go-openapi/spec v0.22.0 h1:xT/EsX4frL3U09QviRIZXvkh80yibxQmtoEvyqug0Tw= -github.com/go-openapi/spec v0.22.0/go.mod h1:K0FhKxkez8YNS94XzF8YKEMULbFrRw4m15i2YUht4L0= -github.com/go-openapi/strfmt v0.24.0 h1:dDsopqbI3wrrlIzeXRbqMihRNnjzGC+ez4NQaAAJLuc= -github.com/go-openapi/strfmt v0.24.0/go.mod h1:Lnn1Bk9rZjXxU9VMADbEEOo7D7CDyKGLsSKekhFr7s4= +github.com/go-openapi/jsonreference v0.21.3 h1:96Dn+MRPa0nYAR8DR1E03SblB5FJvh7W6krPI0Z7qMc= +github.com/go-openapi/jsonreference v0.21.3/go.mod h1:RqkUP0MrLf37HqxZxrIAtTWW4ZJIK1VzduhXYBEeGc4= +github.com/go-openapi/loads v0.23.2 h1:rJXAcP7g1+lWyBHC7iTY+WAF0rprtM+pm8Jxv1uQJp4= +github.com/go-openapi/loads v0.23.2/go.mod h1:IEVw1GfRt/P2Pplkelxzj9BYFajiWOtY2nHZNj4UnWY= +github.com/go-openapi/spec v0.22.1 h1:beZMa5AVQzRspNjvhe5aG1/XyBSMeX1eEOs7dMoXh/k= +github.com/go-openapi/spec v0.22.1/go.mod h1:c7aeIQT175dVowfp7FeCvXXnjN/MrpaONStibD2WtDA= +github.com/go-openapi/strfmt v0.25.0 h1:7R0RX7mbKLa9EYCTHRcCuIPcaqlyQiWNPTXwClK0saQ= +github.com/go-openapi/strfmt v0.25.0/go.mod h1:nNXct7OzbwrMY9+5tLX4I21pzcmE6ccMGXl3jFdPfn8= github.com/go-openapi/swag/conv v0.25.1 h1:+9o8YUg6QuqqBM5X6rYL/p1dpWeZRhoIt9x7CCP+he0= github.com/go-openapi/swag/conv v0.25.1/go.mod h1:Z1mFEGPfyIKPu0806khI3zF+/EUXde+fdeksUl2NiDs= github.com/go-openapi/swag/fileutils v0.25.1 h1:rSRXapjQequt7kqalKXdcpIegIShhTPXx7yw0kek2uU= @@ -43,8 +41,12 @@ github.com/go-openapi/swag/typeutils v0.25.1 h1:rD/9HsEQieewNt6/k+JBwkxuAHktFtH3 github.com/go-openapi/swag/typeutils v0.25.1/go.mod h1:9McMC/oCdS4BKwk2shEB7x17P6HmMmA6dQRtAkSnNb8= github.com/go-openapi/swag/yamlutils v0.25.1 h1:mry5ez8joJwzvMbaTGLhw8pXUnhDK91oSJLDPF1bmGk= github.com/go-openapi/swag/yamlutils v0.25.1/go.mod h1:cm9ywbzncy3y6uPm/97ysW8+wZ09qsks+9RS8fLWKqg= -github.com/go-openapi/validate v0.25.0 h1:JD9eGX81hDTjoY3WOzh6WqxVBVl7xjsLnvDo1GL5WPU= -github.com/go-openapi/validate v0.25.0/go.mod h1:SUY7vKrN5FiwK6LyvSwKjDfLNirSfWwHNgxd2l29Mmw= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 h1:0+Y41Pz1NkbTHz8NngxTuAXxEodtNSI1WG1c/m5Akw4= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2/go.mod h1:kme83333GCtJQHXQ8UKX3IBZu6z8T5Dvy5+CW3NLUUg= +github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= +github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= +github.com/go-openapi/validate v0.25.1 h1:sSACUI6Jcnbo5IWqbYHgjibrhhmt3vR6lCzKZnmAgBw= +github.com/go-openapi/validate v0.25.1/go.mod h1:RMVyVFYte0gbSTaZ0N4KmTn6u/kClvAFp+mAVfS/DQc= github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -63,8 +65,8 @@ github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0t github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw= -go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= +go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss= +go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -81,14 +83,14 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= -golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= -golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= -golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= -golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= -golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= +golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4= +golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= +golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= +golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/go.work.sum b/go.work.sum index a60668a..b0c2c9a 100644 --- a/go.work.sum +++ b/go.work.sum @@ -43,15 +43,18 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= +golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= +golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= +golang.org/x/net v0.45.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= @@ -70,6 +73,7 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA= +golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -83,6 +87,7 @@ golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw= golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= +golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/headers_test.go b/headers_test.go index 3793b8f..9d5ccb2 100644 --- a/headers_test.go +++ b/headers_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/go-openapi/errors" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestParseContentType(t *testing.T) { @@ -41,7 +41,7 @@ func TestParseContentType(t *testing.T) { require.NoError(t, err, "input: %q, err: %v", v.hdr, err) } else { require.Error(t, err, "input: %q", v.hdr) - assert.IsTypef(t, &errors.ParseError{}, err, "input: %q", v.hdr) //nolint: testifylint // ErrorAs doesn't work and ErrorIs doesn't fit + assert.IsTypef(t, &errors.ParseError{}, err, "input: %q", v.hdr) assert.Equal(t, v.err.Error(), err.Error(), "input: %q", v.hdr) } assert.Equal(t, v.mt, ct, "input: %q", v.hdr) diff --git a/internal/testing/data_test.go b/internal/testing/data_test.go index b83fa98..4ffbebd 100644 --- a/internal/testing/data_test.go +++ b/internal/testing/data_test.go @@ -6,7 +6,7 @@ package testing import ( "testing" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" ) func TestInvalidJSON(t *testing.T) { diff --git a/internal/testing/petstore/api.go b/internal/testing/petstore/api.go index 449eb6a..1aea388 100644 --- a/internal/testing/petstore/api.go +++ b/internal/testing/petstore/api.go @@ -17,7 +17,7 @@ import ( "github.com/go-openapi/runtime/middleware/untyped" "github.com/go-openapi/runtime/security" "github.com/go-openapi/runtime/yamlpc" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" ) const ( diff --git a/internal/testing/petstore/api_test.go b/internal/testing/petstore/api_test.go index 6bfd15b..f256bdc 100644 --- a/internal/testing/petstore/api_test.go +++ b/internal/testing/petstore/api_test.go @@ -6,7 +6,7 @@ package petstore import ( "testing" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" ) func TestAPI(t *testing.T) { diff --git a/internal/testing/simplepetstore/api_test.go b/internal/testing/simplepetstore/api_test.go index fbaf595..aa3bb89 100644 --- a/internal/testing/simplepetstore/api_test.go +++ b/internal/testing/simplepetstore/api_test.go @@ -11,8 +11,8 @@ import ( "testing" "github.com/go-openapi/runtime" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestSimplePetstoreSpec(t *testing.T) { diff --git a/json_test.go b/json_test.go index 6fc35e2..5e4ee0f 100644 --- a/json_test.go +++ b/json_test.go @@ -9,8 +9,8 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) var consProdJSON = `{"name":"Somebody","id":1}` diff --git a/logger/logger_test.go b/logger/logger_test.go index d0ba024..33983c4 100644 --- a/logger/logger_test.go +++ b/logger/logger_test.go @@ -6,7 +6,7 @@ package logger import ( "testing" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" ) func TestLogger(t *testing.T) { diff --git a/middleware/body_test.go b/middleware/body_test.go index 6d88bc0..88c9778 100644 --- a/middleware/body_test.go +++ b/middleware/body_test.go @@ -12,8 +12,8 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/internal/testing/petstore" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) type eofReader struct { diff --git a/middleware/context_test.go b/middleware/context_test.go index 230c871..71919ed 100644 --- a/middleware/context_test.go +++ b/middleware/context_test.go @@ -18,8 +18,8 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/internal/testing/petstore" "github.com/go-openapi/runtime/middleware/untyped" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) type stubBindRequester struct { diff --git a/middleware/debug_test.go b/middleware/debug_test.go index e7d1ad4..8c4ceec 100644 --- a/middleware/debug_test.go +++ b/middleware/debug_test.go @@ -13,8 +13,8 @@ import ( "github.com/go-openapi/runtime/internal/testing/petstore" "github.com/go-openapi/runtime/logger" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) type customLogger struct { diff --git a/middleware/denco/router_test.go b/middleware/denco/router_test.go index 3ac5d56..0a13c6f 100644 --- a/middleware/denco/router_test.go +++ b/middleware/denco/router_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/go-openapi/runtime/middleware/denco" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func routes() []denco.Record { diff --git a/middleware/denco/server_test.go b/middleware/denco/server_test.go index 5fd32b1..0e00418 100644 --- a/middleware/denco/server_test.go +++ b/middleware/denco/server_test.go @@ -12,8 +12,8 @@ import ( "testing" "github.com/go-openapi/runtime/middleware/denco" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func testHandlerFunc(w http.ResponseWriter, r *http.Request, params denco.Params) { diff --git a/middleware/header/header_test.go b/middleware/header/header_test.go index ed090cc..f39bed9 100644 --- a/middleware/header/header_test.go +++ b/middleware/header/header_test.go @@ -7,7 +7,7 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" ) func TestHeader(t *testing.T) { diff --git a/middleware/not_implemented_test.go b/middleware/not_implemented_test.go index 94a8fb6..462845d 100644 --- a/middleware/not_implemented_test.go +++ b/middleware/not_implemented_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/go-openapi/runtime" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" ) func TestErrorResponder(t *testing.T) { diff --git a/middleware/operation_test.go b/middleware/operation_test.go index 698b1df..42be412 100644 --- a/middleware/operation_test.go +++ b/middleware/operation_test.go @@ -12,8 +12,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/internal/testing/petstore" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestOperationExecutor(t *testing.T) { diff --git a/middleware/parameter_test.go b/middleware/parameter_test.go index eb2eba1..b1817ca 100644 --- a/middleware/parameter_test.go +++ b/middleware/parameter_test.go @@ -13,8 +13,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" "github.com/go-openapi/runtime" ) diff --git a/middleware/rapidoc_test.go b/middleware/rapidoc_test.go index 63d3923..5aae11f 100644 --- a/middleware/rapidoc_test.go +++ b/middleware/rapidoc_test.go @@ -10,8 +10,8 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestRapiDocMiddleware(t *testing.T) { diff --git a/middleware/redoc_test.go b/middleware/redoc_test.go index 35c760b..aea0550 100644 --- a/middleware/redoc_test.go +++ b/middleware/redoc_test.go @@ -10,8 +10,8 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestRedocMiddleware(t *testing.T) { diff --git a/middleware/request_test.go b/middleware/request_test.go index b9390da..fb34fe7 100644 --- a/middleware/request_test.go +++ b/middleware/request_test.go @@ -17,8 +17,8 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) const ( diff --git a/middleware/route_authenticator_test.go b/middleware/route_authenticator_test.go index 7183a44..b7396e8 100644 --- a/middleware/route_authenticator_test.go +++ b/middleware/route_authenticator_test.go @@ -9,7 +9,7 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" "github.com/go-openapi/runtime" ) diff --git a/middleware/route_param_test.go b/middleware/route_param_test.go index 02727c4..390f260 100644 --- a/middleware/route_param_test.go +++ b/middleware/route_param_test.go @@ -6,7 +6,7 @@ package middleware import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/go-openapi/testify/v2/assert" ) func TestRouteParams(t *testing.T) { diff --git a/middleware/router_test.go b/middleware/router_test.go index f98ae43..1be2cdf 100644 --- a/middleware/router_test.go +++ b/middleware/router_test.go @@ -15,8 +15,8 @@ import ( "github.com/go-openapi/loads" "github.com/go-openapi/runtime/internal/testing/petstore" "github.com/go-openapi/runtime/middleware/untyped" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func terminator(rw http.ResponseWriter, _ *http.Request) { diff --git a/middleware/security_test.go b/middleware/security_test.go index 6dbf026..f2b0e06 100644 --- a/middleware/security_test.go +++ b/middleware/security_test.go @@ -9,8 +9,8 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" "github.com/go-openapi/runtime/internal/testing/petstore" ) diff --git a/middleware/spec_test.go b/middleware/spec_test.go index 324da54..d8fce23 100644 --- a/middleware/spec_test.go +++ b/middleware/spec_test.go @@ -9,8 +9,8 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/internal/testing/petstore" @@ -34,7 +34,7 @@ func TestServeSpecMiddleware(t *testing.T) { responseHeaders := recorder.Result().Header responseContentType := responseHeaders.Get("Content-Type") - assert.Equal(t, applicationJSON, responseContentType) //nolint:testifylint + assert.Equal(t, applicationJSON, responseContentType) responseBody := recorder.Body require.NotNil(t, responseBody) diff --git a/middleware/string_conversion_test.go b/middleware/string_conversion_test.go index eda31bf..9d6a584 100644 --- a/middleware/string_conversion_test.go +++ b/middleware/string_conversion_test.go @@ -13,8 +13,8 @@ import ( "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag/stringutils" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) var evaluatesAsTrue = []string{"true", "1", "yes", "ok", "y", "on", "selected", "checked", "t", "enabled"} diff --git a/middleware/swaggerui_oauth2_test.go b/middleware/swaggerui_oauth2_test.go index c3c31f8..c97a619 100644 --- a/middleware/swaggerui_oauth2_test.go +++ b/middleware/swaggerui_oauth2_test.go @@ -10,8 +10,8 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestSwaggerUIOAuth2CallbackMiddleware(t *testing.T) { diff --git a/middleware/swaggerui_test.go b/middleware/swaggerui_test.go index 6bcdddd..3b83f6f 100644 --- a/middleware/swaggerui_test.go +++ b/middleware/swaggerui_test.go @@ -11,8 +11,8 @@ import ( "strings" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestSwaggerUIMiddleware(t *testing.T) { diff --git a/middleware/ui_options_test.go b/middleware/ui_options_test.go index 686f94f..694a226 100644 --- a/middleware/ui_options_test.go +++ b/middleware/ui_options_test.go @@ -6,7 +6,7 @@ package middleware import ( "testing" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" ) func TestConvertOptions(t *testing.T) { diff --git a/middleware/untyped/api_test.go b/middleware/untyped/api_test.go index 238e746..eda92c0 100644 --- a/middleware/untyped/api_test.go +++ b/middleware/untyped/api_test.go @@ -14,8 +14,8 @@ import ( "github.com/go-openapi/loads" "github.com/go-openapi/runtime" swaggerspec "github.com/go-openapi/spec" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func stubAutenticator() runtime.Authenticator { diff --git a/middleware/untyped_request_test.go b/middleware/untyped_request_test.go index e366d66..f4e2842 100644 --- a/middleware/untyped_request_test.go +++ b/middleware/untyped_request_test.go @@ -18,8 +18,8 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestUntypedFormPost(t *testing.T) { diff --git a/middleware/validation_test.go b/middleware/validation_test.go index 01bda84..8066b4b 100644 --- a/middleware/validation_test.go +++ b/middleware/validation_test.go @@ -14,8 +14,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/internal/testing/petstore" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func newTestValidation(ctx *Context, next http.Handler) http.Handler { @@ -160,7 +160,7 @@ func TestValidateContentType(t *testing.T) { require.NoError(t, err, "input: %q", v.hdr) } else { require.Error(t, err, "input: %q", v.hdr) - assert.IsTypef(t, &errors.Validation{}, err, "input: %q", v.hdr) //nolint: testifylint // ErrorAs doesn't work and ErrorIs doesn't fit + assert.IsTypef(t, &errors.Validation{}, err, "input: %q", v.hdr) require.EqualErrorf(t, err, v.err.Error(), "input: %q", v.hdr) assert.EqualValues(t, http.StatusUnsupportedMediaType, err.(*errors.Validation).Code()) } diff --git a/request_test.go b/request_test.go index 1e35831..a2f9c8e 100644 --- a/request_test.go +++ b/request_test.go @@ -13,9 +13,9 @@ import ( "strings" "testing" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" - "github.com/stretchr/testify/assert" + "github.com/go-openapi/testify/v2/assert" ) type eofReader struct{} @@ -165,8 +165,8 @@ func TestJSONRequest(t *testing.T) { req, err := JSONRequest(http.MethodGet, "/swagger.json", nil) require.NoError(t, err) assert.Equal(t, http.MethodGet, req.Method) - assert.Equal(t, JSONMime, req.Header.Get(HeaderContentType)) //nolint:testifylint - assert.Equal(t, JSONMime, req.Header.Get(HeaderAccept)) //nolint:testifylint + assert.Equal(t, JSONMime, req.Header.Get(HeaderContentType)) + assert.Equal(t, JSONMime, req.Header.Get(HeaderAccept)) req, err = JSONRequest(http.MethodGet, "%2", nil) require.Error(t, err) diff --git a/security/apikey_auth_test.go b/security/apikey_auth_test.go index cf216f1..eeb03d7 100644 --- a/security/apikey_auth_test.go +++ b/security/apikey_auth_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/go-openapi/errors" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) const ( diff --git a/security/authorizer_test.go b/security/authorizer_test.go index 0b68b5c..3d7507a 100644 --- a/security/authorizer_test.go +++ b/security/authorizer_test.go @@ -8,8 +8,8 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) func TestAuthorized(t *testing.T) { diff --git a/security/basic_auth_test.go b/security/basic_auth_test.go index b2ad1b4..7510439 100644 --- a/security/basic_auth_test.go +++ b/security/basic_auth_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/go-openapi/errors" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) type secTestKey uint8 diff --git a/security/bearer_auth_test.go b/security/bearer_auth_test.go index 4fe4c20..5e2db6a 100644 --- a/security/bearer_auth_test.go +++ b/security/bearer_auth_test.go @@ -15,8 +15,8 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/runtime" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) const ( diff --git a/text_test.go b/text_test.go index fef2041..90401dd 100644 --- a/text_test.go +++ b/text_test.go @@ -10,8 +10,8 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) var consProdText = `The quick brown fox jumped over the lazy dog.` diff --git a/values_test.go b/values_test.go index 2a4269c..41da662 100644 --- a/values_test.go +++ b/values_test.go @@ -6,7 +6,7 @@ package runtime import ( "testing" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/require" ) func TestGetOK(t *testing.T) { diff --git a/xml_test.go b/xml_test.go index 44e4c0e..97a6f2b 100644 --- a/xml_test.go +++ b/xml_test.go @@ -9,8 +9,8 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) var consProdXML = `Somebody1` diff --git a/yamlpc/yaml_test.go b/yamlpc/yaml_test.go index ac795fb..6c5e325 100644 --- a/yamlpc/yaml_test.go +++ b/yamlpc/yaml_test.go @@ -9,8 +9,9 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + _ "github.com/go-openapi/testify/enable/yaml/v2" + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" ) var consProdYAML = "name: Somebody\nid: 1\n" From 078717abbee7f694e8e77d8e41b8f32a435ae03e Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Sun, 9 Nov 2025 20:37:42 +0100 Subject: [PATCH 4/4] fix(vuln): fixed vulnerability in returned error, not escaping single quotes Signed-off-by: Frederic BIDON --- client_response.go | 7 +++- client_response_test.go | 79 +++++++++++++++++++++++++++++++---------- 2 files changed, 66 insertions(+), 20 deletions(-) diff --git a/client_response.go b/client_response.go index 2be38d2..f2cf942 100644 --- a/client_response.go +++ b/client_response.go @@ -7,6 +7,7 @@ import ( "encoding/json" "fmt" "io" + "strings" ) // A ClientResponse represents a client response. @@ -50,13 +51,17 @@ func NewAPIError(opName string, payload any, code int) *APIError { } } +// sanitizer ensures that single quotes are escaped +var sanitizer = strings.NewReplacer(`\`, `\\`, `'`, `\'`) + func (o *APIError) Error() string { var resp []byte if err, ok := o.Response.(error); ok { - resp = []byte("'" + err.Error() + "'") + resp = []byte("'" + sanitizer.Replace(err.Error()) + "'") } else { resp, _ = json.Marshal(o.Response) } + return fmt.Sprintf("%s (status %d): %s", o.OperationName, o.Code, resp) } diff --git a/client_response_test.go b/client_response_test.go index 8a0169b..13c42a0 100644 --- a/client_response_test.go +++ b/client_response_test.go @@ -53,26 +53,67 @@ func TestResponseReaderFunc(t *testing.T) { assert.Equal(t, 490, actual.Code) } +type errResponse struct { + A int `json:"a"` + B string `json:"b"` +} + func TestResponseReaderFuncError(t *testing.T) { - reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (any, error) { - _, _ = io.ReadAll(r.Body()) - return nil, NewAPIError("fake", errors.New("writer closed"), 490) + t.Parallel() + + t.Run("with API error as string", func(t *testing.T) { + reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (any, error) { + _, _ = io.ReadAll(r.Body()) + + return nil, NewAPIError("fake", errors.New("writer closed"), 490) + }) + + _, err := reader.ReadResponse(response{}, nil) + require.Error(t, err) + require.ErrorContains(t, err, "'writer closed'") }) - _, err := reader.ReadResponse(response{}, nil) - require.Error(t, err) - require.ErrorContains(t, err, "writer closed") - - reader = func(r ClientResponse, _ Consumer) (any, error) { - _, _ = io.ReadAll(r.Body()) - err := &fs.PathError{ - Op: "write", - Path: "path/to/fake", - Err: fs.ErrClosed, - } - return nil, NewAPIError("fake", err, 200) - } - _, err = reader.ReadResponse(response{}, nil) - require.Error(t, err) - assert.Contains(t, err.Error(), "file already closed") + t.Run("with API error as complex error", func(t *testing.T) { + reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (any, error) { + _, _ = io.ReadAll(r.Body()) + err := &fs.PathError{ + Op: "write", + Path: "path/to/fake", + Err: fs.ErrClosed, + } + + return nil, NewAPIError("fake", err, 200) + }) + + _, err := reader.ReadResponse(response{}, nil) + require.Error(t, err) + assert.Contains(t, err.Error(), "file already closed") + }) + + t.Run("with API error requiring escaping", func(t *testing.T) { + reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (any, error) { + _, _ = io.ReadAll(r.Body()) + return nil, NewAPIError("fake", errors.New(`writer is \"terminated\" and 'closed'`), 490) + }) + + _, err := reader.ReadResponse(response{}, nil) + require.Error(t, err) + require.ErrorContains(t, err, `'writer is \\"terminated\\" and \'closed\''`) + }) + + t.Run("with API error as JSON", func(t *testing.T) { + reader := ClientResponseReaderFunc(func(r ClientResponse, _ Consumer) (any, error) { + _, _ = io.ReadAll(r.Body()) + obj := &errResponse{ // does not implement error + A: 555, + B: "closed", + } + + return nil, NewAPIError("fake", obj, 200) + }) + + _, err := reader.ReadResponse(response{}, nil) + require.Error(t, err) + assert.Contains(t, err.Error(), `{"a":555,"b":"closed"}`) + }) }