Skip to content

Commit

Permalink
Replace more occurances of interface{}
Browse files Browse the repository at this point in the history
  • Loading branch information
percivalalb committed Jun 16, 2024
1 parent 88ab2ba commit fe86b5d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/docs/openapi3filter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/docs/routers_legacy_pathpattern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions openapi3/issue735_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,17 @@ 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()},
//},
//{
// name: "write only properties",
// 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()},
//},
{
Expand Down
2 changes: 1 addition & 1 deletion openapi3filter/req_resp_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions routers/legacy/pathpattern/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func PathFromHost(host string, specialDashes bool) string {

type Node struct {
VariableNames []string
Value interface{}
Value any
Suffixes SuffixList
}

Expand Down Expand Up @@ -153,15 +153,15 @@ 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)
}
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
Expand Down
2 changes: 1 addition & 1 deletion routers/legacy/validate_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fe86b5d

Please sign in to comment.