Skip to content

Commit

Permalink
openapi3,openapi3filter: fix typos in comments, tests (#810)
Browse files Browse the repository at this point in the history
alexandear authored Jun 20, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f333d82 commit ba08e37
Showing 9 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions openapi3/loader_relative_refs_test.go
Original file line number Diff line number Diff line change
@@ -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": {
2 changes: 1 addition & 1 deletion openapi3/loader_test.go
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 4 additions & 4 deletions openapi3/schema_oneOf_test.go
Original file line number Diff line number Diff line change
@@ -117,15 +117,15 @@ 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",
})
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,15 +143,15 @@ 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",
})
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",
2 changes: 1 addition & 1 deletion openapi3/schema_test.go
Original file line number Diff line number Diff line change
@@ -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{}{
2 changes: 1 addition & 1 deletion openapi3/validation_options.go
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion openapi3filter/issue625_test.go
Original file line number Diff line number Diff line change
@@ -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`,
2 changes: 1 addition & 1 deletion openapi3filter/middleware_test.go
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion openapi3filter/req_resp_decoder.go
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion routers/legacy/pathpattern/node.go
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ba08e37

Please sign in to comment.