From 3f964df077d391545192ba1ec05f2f4bb5b0cc63 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Tue, 20 Jun 2023 15:26:12 +0300 Subject: [PATCH] openapi3,openapi3filter: fix typos in comments, tests --- openapi3/loader_relative_refs_test.go | 6 +++--- openapi3/loader_test.go | 2 +- openapi3/schema_oneOf_test.go | 8 ++++---- openapi3/schema_test.go | 2 +- openapi3/validation_options.go | 2 +- openapi3filter/issue625_test.go | 2 +- openapi3filter/middleware_test.go | 2 +- openapi3filter/req_resp_decoder.go | 2 +- routers/legacy/pathpattern/node.go | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/openapi3/loader_relative_refs_test.go b/openapi3/loader_relative_refs_test.go index 50d2c7d24..7c553672d 100644 --- a/openapi3/loader_relative_refs_test.go +++ b/openapi3/loader_relative_refs_test.go @@ -139,8 +139,8 @@ var refTestDataEntries = []refTestDataEntry{ }, }, { - name: "PathOperationReqestBodyContentSchemaRef", - contentTemplate: externalPathOperationReqestBodyContentSchemaRefTemplate, + name: "PathOperationRequestBodyContentSchemaRef", + contentTemplate: externalPathOperationRequestBodyContentSchemaRefTemplate, testFunc: func(t *testing.T, doc *T) { require.NotNil(t, doc.Paths["/test"].Post.RequestBody.Value.Content["application/json"].Schema.Value) require.Equal(t, "string", doc.Paths["/test"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Type) @@ -567,7 +567,7 @@ const externalPathOperationRequestBodyExampleRefTemplate = ` } }` -const externalPathOperationReqestBodyContentSchemaRefTemplate = ` +const externalPathOperationRequestBodyContentSchemaRefTemplate = ` { "openapi": "3.0.0", "info": { diff --git a/openapi3/loader_test.go b/openapi3/loader_test.go index 4c6f8c841..2c1d4198f 100644 --- a/openapi3/loader_test.go +++ b/openapi3/loader_test.go @@ -314,7 +314,7 @@ func TestLoadWithRecursiveReferenceInLocalReferenceInParentSubdir(t *testing.T) require.Equal(t, "object", doc.Paths["/api/test/ref/in/ref"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["definition_reference"].Value.Type) } -func TestLoadWithRecursiveReferenceInRefrerenceInLocalReference(t *testing.T) { +func TestLoadWithRecursiveReferenceInReferenceInLocalReference(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true doc, err := loader.LoadFromFile("testdata/refInLocalRef/openapi.json") diff --git a/openapi3/schema_oneOf_test.go b/openapi3/schema_oneOf_test.go index 2dc8b95c8..f6bd50861 100644 --- a/openapi3/schema_oneOf_test.go +++ b/openapi3/schema_oneOf_test.go @@ -117,7 +117,7 @@ components: return doc } -func TestVisitJSON_OneOf_MissingDiscriptorProperty(t *testing.T) { +func TestVisitJSON_OneOf_MissingDescriptorProperty(t *testing.T) { doc := oneofSpec(t) err := doc.Components.Schemas["Animal"].Value.VisitJSON(map[string]interface{}{ "name": "snoopy", @@ -125,7 +125,7 @@ func TestVisitJSON_OneOf_MissingDiscriptorProperty(t *testing.T) { require.ErrorContains(t, err, `input does not contain the discriminator property "$type"`) } -func TestVisitJSON_OneOf_MissingDiscriptorValue(t *testing.T) { +func TestVisitJSON_OneOf_MissingDescriptorValue(t *testing.T) { doc := oneofSpec(t) err := doc.Components.Schemas["Animal"].Value.VisitJSON(map[string]interface{}{ "name": "snoopy", @@ -143,7 +143,7 @@ func TestVisitJSON_OneOf_MissingField(t *testing.T) { require.ErrorContains(t, err, `doesn't match schema due to: Error at "/barks": property "barks" is missing`) } -func TestVisitJSON_OneOf_NoDiscriptor_MissingField(t *testing.T) { +func TestVisitJSON_OneOf_NoDescriptor_MissingField(t *testing.T) { doc := oneofNoDiscriminatorSpec(t) err := doc.Components.Schemas["Animal"].Value.VisitJSON(map[string]interface{}{ "name": "snoopy", @@ -151,7 +151,7 @@ func TestVisitJSON_OneOf_NoDiscriptor_MissingField(t *testing.T) { require.ErrorContains(t, err, `doesn't match schema due to: Error at "/scratches": property "scratches" is missing`) } -func TestVisitJSON_OneOf_BadDescriminatorType(t *testing.T) { +func TestVisitJSON_OneOf_BadDiscriminatorType(t *testing.T) { doc := oneofSpec(t) err := doc.Components.Schemas["Animal"].Value.VisitJSON(map[string]interface{}{ "name": "snoopy", diff --git a/openapi3/schema_test.go b/openapi3/schema_test.go index 4dff2069a..1c2ed355f 100644 --- a/openapi3/schema_test.go +++ b/openapi3/schema_test.go @@ -491,7 +491,7 @@ var schemaExamples = []schemaExample{ map[string]interface{}{ "key1": 1, "key2": 1, - // Additioanl properties will make object different + // Additional properties will make object different // By default additionalProperties is true }, map[string]interface{}{ diff --git a/openapi3/validation_options.go b/openapi3/validation_options.go index 0ca12e5ab..24394baa2 100644 --- a/openapi3/validation_options.go +++ b/openapi3/validation_options.go @@ -92,7 +92,7 @@ func DisableExamplesValidation() ValidationOption { } } -// WithValidationOptions allows adding validation options to a context object that can be used when validationg any OpenAPI type. +// WithValidationOptions allows adding validation options to a context object that can be used when validating any OpenAPI type. func WithValidationOptions(ctx context.Context, opts ...ValidationOption) context.Context { if len(opts) == 0 { return ctx diff --git a/openapi3filter/issue625_test.go b/openapi3filter/issue625_test.go index 21aaf997c..d92906457 100644 --- a/openapi3filter/issue625_test.go +++ b/openapi3filter/issue625_test.go @@ -80,7 +80,7 @@ paths: req: `/items?test=true,3`, }, { - name: "faled oneof object array", + name: "failed oneof object array", spec: oneOfArraySpec, req: `/items?test="val1","val2"`, errStr: `parameter "test" in query has an error: item 0: decoding oneOf failed: 0 schemas matched`, diff --git a/openapi3filter/middleware_test.go b/openapi3filter/middleware_test.go index 6c53d0f42..813d1c9e8 100644 --- a/openapi3filter/middleware_test.go +++ b/openapi3filter/middleware_test.go @@ -454,7 +454,7 @@ paths: result := map[string]interface{}{"result": x * x} if x == 42 { // An easter egg. Unfortunately, the spec does not allow additional properties... - result["comment"] = "the answer to the ulitimate question of life, the universe, and everything" + result["comment"] = "the answer to the ultimate question of life, the universe, and everything" } if err = json.NewEncoder(w).Encode(&result); err != nil { panic(err) diff --git a/openapi3filter/req_resp_decoder.go b/openapi3filter/req_resp_decoder.go index fd28c2f3e..c8571790e 100644 --- a/openapi3filter/req_resp_decoder.go +++ b/openapi3filter/req_resp_decoder.go @@ -812,7 +812,7 @@ func propsFromString(src, propDelim, valueDelim string) (map[string]string, erro pairs := strings.Split(src, propDelim) // When propDelim and valueDelim is equal the source string follow the next rule: - // every even item of pairs is a properies's name, and the subsequent odd item is a property's value. + // every even item of pairs is a properties's name, and the subsequent odd item is a property's value. if propDelim == valueDelim { // Taking into account the rule above, a valid source string must be splitted by propDelim // to an array with an even number of items. diff --git a/routers/legacy/pathpattern/node.go b/routers/legacy/pathpattern/node.go index 011dda358..3f197df95 100644 --- a/routers/legacy/pathpattern/node.go +++ b/routers/legacy/pathpattern/node.go @@ -4,7 +4,7 @@ // - "/" // - "/abc"" // - "/abc/{variable}" (matches until next '/' or end-of-string) -// - "/abc/{variable*}" (matches everything, including "/abc" if "/abc" has noot) +// - "/abc/{variable*}" (matches everything, including "/abc" if "/abc" has root) // - "/abc/{ variable | prefix_(.*}_suffix }" (matches regular expressions) package pathpattern