Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
506 changes: 470 additions & 36 deletions errors/parameter_errors.go

Large diffs are not rendered by default.

72 changes: 36 additions & 36 deletions errors/parameter_errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestQueryParameterMissing(t *testing.T) {
param := createMockParameterWithSchema()

// Call the function
err := QueryParameterMissing(param)
err := QueryParameterMissing(param, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -134,7 +134,7 @@ func TestHeaderParameterMissing(t *testing.T) {
param := createMockParameterWithSchema()

// Call the function
err := HeaderParameterMissing(param)
err := HeaderParameterMissing(param, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -150,7 +150,7 @@ func TestHeaderParameterCannotBeDecoded(t *testing.T) {
val := "malformed_header_value"

// Call the function
err := HeaderParameterCannotBeDecoded(param, val)
err := HeaderParameterCannotBeDecoded(param, val, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestIncorrectHeaderParamEnum(t *testing.T) {
schema := base.NewSchema(s)

// Call the function with an invalid enum value
err := IncorrectHeaderParamEnum(param, "invalidEnum", schema)
err := IncorrectHeaderParamEnum(param, "invalidEnum", schema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestIncorrectQueryParamArrayBoolean(t *testing.T) {
schema := base.NewSchema(s)

// Call the function with an invalid boolean value in the array
err := IncorrectQueryParamArrayBoolean(param, "notBoolean", schema, schema.Items.A.Schema())
err := IncorrectQueryParamArrayBoolean(param, "notBoolean", schema, schema.Items.A.Schema(), "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -314,7 +314,7 @@ func TestIncorrectCookieParamArrayBoolean(t *testing.T) {
itemsSchema := base.NewSchema(baseSchema.Items.Value.A.Schema())

// Call the function with an invalid boolean value in the array
err := IncorrectCookieParamArrayBoolean(param, "notBoolean", s, itemsSchema)
err := IncorrectCookieParamArrayBoolean(param, "notBoolean", s, itemsSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -375,7 +375,7 @@ func TestIncorrectQueryParamArrayInteger(t *testing.T) {
itemsSchema := base.NewSchema(baseSchema.Items.Value.A.Schema())

// Call the function with an invalid number value in the array
err := IncorrectQueryParamArrayInteger(param, "notNumber", s, itemsSchema)
err := IncorrectQueryParamArrayInteger(param, "notNumber", s, itemsSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -394,7 +394,7 @@ func TestIncorrectQueryParamArrayNumber(t *testing.T) {
itemsSchema := base.NewSchema(baseSchema.Items.Value.A.Schema())

// Call the function with an invalid number value in the array
err := IncorrectQueryParamArrayNumber(param, "notNumber", s, itemsSchema)
err := IncorrectQueryParamArrayNumber(param, "notNumber", s, itemsSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -455,7 +455,7 @@ func TestIncorrectCookieParamArrayNumber(t *testing.T) {
itemsSchema := base.NewSchema(baseSchema.Items.Value.A.Schema())

// Call the function with an invalid number value in the cookie array
err := IncorrectCookieParamArrayNumber(param, "notNumber", s, itemsSchema)
err := IncorrectCookieParamArrayNumber(param, "notNumber", s, itemsSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -531,7 +531,7 @@ func TestIncorrectParamEncodingJSON(t *testing.T) {
baseSchema := createMockLowBaseSchema()

// Call the function with an invalid JSON value
err := IncorrectParamEncodingJSON(param, "invalidJSON", base.NewSchema(baseSchema))
err := IncorrectParamEncodingJSON(param, "invalidJSON", base.NewSchema(baseSchema), "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -560,7 +560,7 @@ func TestIncorrectQueryParamBool(t *testing.T) {
})

// Call the function with an invalid boolean value
err := IncorrectQueryParamBool(param, "notBoolean", base.NewSchema(baseSchema))
err := IncorrectQueryParamBool(param, "notBoolean", base.NewSchema(baseSchema), "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -576,7 +576,7 @@ func TestInvalidQueryParamNumber(t *testing.T) {
baseSchema := createMockLowBaseSchema()

// Call the function with an invalid number value
err := InvalidQueryParamNumber(param, "notNumber", base.NewSchema(baseSchema))
err := InvalidQueryParamNumber(param, "notNumber", base.NewSchema(baseSchema), "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -592,7 +592,7 @@ func TestInvalidQueryParamInteger(t *testing.T) {
baseSchema := createMockLowBaseSchema()

// Call the function with an invalid number value
err := InvalidQueryParamInteger(param, "notNumber", base.NewSchema(baseSchema))
err := InvalidQueryParamInteger(param, "notNumber", base.NewSchema(baseSchema), "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -617,7 +617,7 @@ func TestIncorrectQueryParamEnum(t *testing.T) {
param.GoLow().Schema.Value.Schema().Enum.KeyNode = &yaml.Node{}

// Call the function with an invalid enum value
err := IncorrectQueryParamEnum(param, "invalidEnum", highSchema)
err := IncorrectQueryParamEnum(param, "invalidEnum", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -646,7 +646,7 @@ func TestIncorrectQueryParamEnumArray(t *testing.T) {
}

// Call the function with an invalid enum value
err := IncorrectQueryParamEnumArray(param, "invalidEnum", highSchema)
err := IncorrectQueryParamEnumArray(param, "invalidEnum", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -669,7 +669,7 @@ func TestIncorrectReservedValues(t *testing.T) {
param := createMockParameter()
param.Name = "borked::?^&*"

err := IncorrectReservedValues(param, "borked::?^&*", highSchema)
err := IncorrectReservedValues(param, "borked::?^&*", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -692,7 +692,7 @@ func TestInvalidHeaderParamInteger(t *testing.T) {
param := createMockParameter()
param.Name = "bunny"

err := InvalidHeaderParamInteger(param, "bunmy", highSchema)
err := InvalidHeaderParamInteger(param, "bunmy", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -715,7 +715,7 @@ func TestInvalidHeaderParamNumber(t *testing.T) {
param := createMockParameter()
param.Name = "bunny"

err := InvalidHeaderParamNumber(param, "bunmy", highSchema)
err := InvalidHeaderParamNumber(param, "bunmy", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -738,7 +738,7 @@ func TestInvalidCookieParamNumber(t *testing.T) {
param := createMockParameter()
param.Name = "cookies"

err := InvalidCookieParamNumber(param, "milky", highSchema)
err := InvalidCookieParamNumber(param, "milky", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -761,7 +761,7 @@ func TestInvalidCookieParamInteger(t *testing.T) {
param := createMockParameter()
param.Name = "cookies"

err := InvalidCookieParamInteger(param, "milky", highSchema)
err := InvalidCookieParamInteger(param, "milky", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -784,7 +784,7 @@ func TestIncorrectHeaderParamBool(t *testing.T) {
param := createMockParameter()
param.Name = "cookies"

err := IncorrectHeaderParamBool(param, "milky", highSchema)
err := IncorrectHeaderParamBool(param, "milky", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -807,7 +807,7 @@ func TestIncorrectCookieParamBool(t *testing.T) {
param := createMockParameter()
param.Name = "cookies"

err := IncorrectCookieParamBool(param, "milky", highSchema)
err := IncorrectCookieParamBool(param, "milky", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -837,7 +837,7 @@ items:
}
param.GoLow().Schema.Value.Schema().Enum.KeyNode = &yaml.Node{}

err := IncorrectCookieParamEnum(param, "milky", highSchema)
err := IncorrectCookieParamEnum(param, "milky", highSchema, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -863,7 +863,7 @@ func TestIncorrectHeaderParamArrayBoolean(t *testing.T) {
param := createMockParameter()
param.Name = "bubbles"

err := IncorrectHeaderParamArrayBoolean(param, "milky", highSchema, nil)
err := IncorrectHeaderParamArrayBoolean(param, "milky", highSchema, nil, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -889,7 +889,7 @@ func TestIncorrectHeaderParamArrayNumber(t *testing.T) {
param := createMockParameter()
param.Name = "bubbles"

err := IncorrectHeaderParamArrayNumber(param, "milky", highSchema, nil)
err := IncorrectHeaderParamArrayNumber(param, "milky", highSchema, nil, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -914,7 +914,7 @@ func TestIncorrectPathParamBool(t *testing.T) {
param.Schema = base.CreateSchemaProxy(highSchema)
param.GoLow().Schema.KeyNode = &yaml.Node{}

err := IncorrectPathParamBool(param, "milky", highSchema)
err := IncorrectPathParamBool(param, "milky", highSchema, "/test-path", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down Expand Up @@ -945,7 +945,7 @@ items:
}
param.GoLow().Schema.Value.Schema().Enum.KeyNode = &yaml.Node{}

err := IncorrectPathParamEnum(param, "milky", highSchema)
err := IncorrectPathParamEnum(param, "milky", highSchema, "/test-path", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -970,7 +970,7 @@ func TestIncorrectPathParamNumber(t *testing.T) {
param.Schema = base.CreateSchemaProxy(highSchema)
param.GoLow().Schema.KeyNode = &yaml.Node{}

err := IncorrectPathParamNumber(param, "milky", highSchema)
err := IncorrectPathParamNumber(param, "milky", highSchema, "/test-path", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -995,7 +995,7 @@ func TestIncorrectPathParamInteger(t *testing.T) {
param.Schema = base.CreateSchemaProxy(highSchema)
param.GoLow().Schema.KeyNode = &yaml.Node{}

err := IncorrectPathParamInteger(param, "milky", highSchema)
err := IncorrectPathParamInteger(param, "milky", highSchema, "/test-path", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -1021,7 +1021,7 @@ func TestIncorrectPathParamArrayNumber(t *testing.T) {
param := createMockParameter()
param.Name = "bubbles"

err := IncorrectPathParamArrayNumber(param, "milky", highSchema, nil)
err := IncorrectPathParamArrayNumber(param, "milky", highSchema, nil, "/test-path", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -1047,7 +1047,7 @@ func TestIncorrectPathParamArrayInteger(t *testing.T) {
param := createMockParameter()
param.Name = "bubbles"

err := IncorrectPathParamArrayInteger(param, "milky", highSchema, nil)
err := IncorrectPathParamArrayInteger(param, "milky", highSchema, nil, "/test-path", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -1073,7 +1073,7 @@ func TestIncorrectPathParamArrayBoolean(t *testing.T) {
param := createMockParameter()
param.Name = "bubbles"

err := IncorrectPathParamArrayBoolean(param, "milky", highSchema, nil)
err := IncorrectPathParamArrayBoolean(param, "milky", highSchema, nil, "/test-path", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -1098,7 +1098,7 @@ func TestPathParameterMissing(t *testing.T) {
param.Schema = base.CreateSchemaProxy(highSchema)
param.GoLow().Schema.KeyNode = &yaml.Node{}

err := PathParameterMissing(param)
err := PathParameterMissing(param, "/test/{testQueryParam}", "/test/")

// Validate the error
require.NotNil(t, err)
Expand All @@ -1124,7 +1124,7 @@ items:
param.Schema = base.CreateSchemaProxy(highSchema)
param.GoLow().Schema.KeyNode = &yaml.Node{}

err := IncorrectParamArrayMaxNumItems(param, param.Schema.Schema(), 10, 25)
err := IncorrectParamArrayMaxNumItems(param, param.Schema.Schema(), 10, 25, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -1150,7 +1150,7 @@ items:
param.Schema = base.CreateSchemaProxy(highSchema)
param.GoLow().Schema.KeyNode = &yaml.Node{}

err := IncorrectParamArrayMinNumItems(param, param.Schema.Schema(), 10, 5)
err := IncorrectParamArrayMinNumItems(param, param.Schema.Schema(), 10, 5, "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand All @@ -1176,7 +1176,7 @@ items:
param.Schema = base.CreateSchemaProxy(highSchema)
param.GoLow().Schema.KeyNode = &yaml.Node{}

err := IncorrectParamArrayUniqueItems(param, param.Schema.Schema(), "fish, cake")
err := IncorrectParamArrayUniqueItems(param, param.Schema.Schema(), "fish, cake", "/test-path", "get", "{}")

// Validate the error
require.NotNil(t, err)
Expand Down
Loading