From fe86b5d7f995c01d070afe4807c7fabd65293235 Mon Sep 17 00:00:00 2001 From: Alex Barter Date: Sun, 16 Jun 2024 17:51:04 +0000 Subject: [PATCH] Replace more occurances of interface{} --- .github/docs/openapi3filter.txt | 4 ++-- .github/docs/routers_legacy_pathpattern.txt | 6 +++--- README.md | 2 +- openapi3/issue735_test.go | 8 ++++---- openapi3filter/req_resp_decoder.go | 2 +- routers/legacy/pathpattern/node.go | 6 +++--- routers/legacy/validate_request_test.go | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/docs/openapi3filter.txt b/.github/docs/openapi3filter.txt index 19b32e095..626cd24a7 100644 --- a/.github/docs/openapi3filter.txt +++ b/.github/docs/openapi3filter.txt @@ -141,8 +141,8 @@ func (input *AuthenticationInput) NewError(err error) error type BodyDecoder func(io.Reader, http.Header, *openapi3.SchemaRef, EncodingFn) (any, error) BodyDecoder is an interface to decode a body of a request or response. - An implementation must return a value that is a primitive, []interface{}, - or map[string]interface{}. + An implementation must return a value that is a primitive, []any, + or map[string]any. func RegisteredBodyDecoder(contentType string) BodyDecoder RegisteredBodyDecoder returns the registered body decoder for the given diff --git a/.github/docs/routers_legacy_pathpattern.txt b/.github/docs/routers_legacy_pathpattern.txt index 27967330b..db79f7ac7 100644 --- a/.github/docs/routers_legacy_pathpattern.txt +++ b/.github/docs/routers_legacy_pathpattern.txt @@ -50,17 +50,17 @@ TYPES type Node struct { VariableNames []string - Value interface{} + Value any Suffixes SuffixList } -func (currentNode *Node) Add(path string, value interface{}, options *Options) error +func (currentNode *Node) Add(path string, value any, options *Options) error func (currentNode *Node) CreateNode(path string, options *Options) (*Node, error) func (currentNode *Node) Match(path string) (*Node, []string) -func (currentNode *Node) MustAdd(path string, value interface{}, options *Options) +func (currentNode *Node) MustAdd(path string, value any, options *Options) func (currentNode *Node) String() string diff --git a/README.md b/README.md index 874db2858..1e6aaab56 100644 --- a/README.md +++ b/README.md @@ -327,7 +327,7 @@ This will change the schema validation errors to return only the `Reason` field, * The string format `email` has been removed by default. To use it please call `openapi3.DefineStringFormat("email", openapi3.FormatOfStringForEmail)`. * Field `openapi3.T.Components` is now a pointer. * Fields `openapi3.Schema.AdditionalProperties` and `openapi3.Schema.AdditionalPropertiesAllowed` are replaced by `openapi3.Schema.AdditionalProperties.Schema` and `openapi3.Schema.AdditionalProperties.Has` respectively. -* Type `openapi3.ExtensionProps` is now just `map[string]interface{}` and extensions are accessible through the `Extensions` field. +* Type `openapi3.ExtensionProps` is now just `map[string]any` and extensions are accessible through the `Extensions` field. ### v0.112.0 * `(openapi3.ValidationOptions).ExamplesValidationDisabled` has been unexported. diff --git a/openapi3/issue735_test.go b/openapi3/issue735_test.go index 114332dd8..ac316af3d 100644 --- a/openapi3/issue735_test.go +++ b/openapi3/issue735_test.go @@ -161,8 +161,8 @@ func TestIssue735(t *testing.T) { // schema: NewSchema().WithProperties(map[string]*Schema{ // "foo": {ReadOnly: true}, // }).WithoutAdditionalProperties(), - // value: map[string]interface{}{"foo": 42}, - // extraNotContains: []interface{}{42}, + // value: map[string]any{"foo": 42}, + // extraNotContains: []any{42}, // options: []SchemaValidationOption{VisitAsRequest()}, //}, //{ @@ -170,8 +170,8 @@ func TestIssue735(t *testing.T) { // schema: NewSchema().WithProperties(map[string]*Schema{ // "foo": {WriteOnly: true}, // }).WithoutAdditionalProperties(), - // value: map[string]interface{}{"foo": 42}, - // extraNotContains: []interface{}{42}, + // value: map[string]any{"foo": 42}, + // extraNotContains: []any{42}, // options: []SchemaValidationOption{VisitAsResponse()}, //}, { diff --git a/openapi3filter/req_resp_decoder.go b/openapi3filter/req_resp_decoder.go index 4d82c9f10..c509def3e 100644 --- a/openapi3filter/req_resp_decoder.go +++ b/openapi3filter/req_resp_decoder.go @@ -1184,7 +1184,7 @@ func parsePrimitiveCase(raw string, schema *openapi3.SchemaRef, typ string) (any type EncodingFn func(partName string) *openapi3.Encoding // BodyDecoder is an interface to decode a body of a request or response. -// An implementation must return a value that is a primitive, []interface{}, or map[string]interface{}. +// An implementation must return a value that is a primitive, []any, or map[string]any. type BodyDecoder func(io.Reader, http.Header, *openapi3.SchemaRef, EncodingFn) (any, error) // bodyDecoders contains decoders for supported content types of a body. diff --git a/routers/legacy/pathpattern/node.go b/routers/legacy/pathpattern/node.go index 3f197df95..75932a26d 100644 --- a/routers/legacy/pathpattern/node.go +++ b/routers/legacy/pathpattern/node.go @@ -55,7 +55,7 @@ func PathFromHost(host string, specialDashes bool) string { type Node struct { VariableNames []string - Value interface{} + Value any Suffixes SuffixList } @@ -153,7 +153,7 @@ func (list SuffixList) Swap(i, j int) { list[i], list[j] = b, a } -func (currentNode *Node) MustAdd(path string, value interface{}, options *Options) { +func (currentNode *Node) MustAdd(path string, value any, options *Options) { node, err := currentNode.CreateNode(path, options) if err != nil { panic(err) @@ -161,7 +161,7 @@ func (currentNode *Node) MustAdd(path string, value interface{}, options *Option node.Value = value } -func (currentNode *Node) Add(path string, value interface{}, options *Options) error { +func (currentNode *Node) Add(path string, value any, options *Options) error { node, err := currentNode.CreateNode(path, options) if err != nil { return err diff --git a/routers/legacy/validate_request_test.go b/routers/legacy/validate_request_test.go index 9c15ed44a..77d8bc1de 100644 --- a/routers/legacy/validate_request_test.go +++ b/routers/legacy/validate_request_test.go @@ -78,7 +78,7 @@ func Example() { panic(err) } - p, err := json.Marshal(map[string]interface{}{ + p, err := json.Marshal(map[string]any{ "pet_type": "Cat", "breed": "Dingo", "bark": true,