Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b87cec9
Refactor SchemaValidationFailure struct fields
Oct 9, 2025
56c1f23
document expectation if SchemaValidationFailure did not originate fro…
Oct 10, 2025
5e58242
add ReferenceExample back
Oct 15, 2025
3696bc8
Merge remote-tracking branch 'origin/main' into clarify-error-types
Nov 4, 2025
6c03ca5
Remove SchemaValidationFailure from schema pre-validation errors
Nov 6, 2025
dbc56eb
Remove SchemaValidationFailure from document compilation errors
Nov 6, 2025
f0fc5b5
Parameters: add KeywordLocation when formatting JSON schema errors, r…
Nov 6, 2025
3e80f75
Remove AbsoluteKeywordLocation field - never populated due to schema …
Nov 7, 2025
a21d5ab
Request body validation: remove SchemaValidationFailure from pre-vali…
Nov 7, 2025
969efb8
Response body validation: remove SchemaValidationFailure from pre-val…
Nov 7, 2025
1f6225c
feat: add centralized JSON Pointer construction helpers
Nov 15, 2025
80d4fa7
Response headers: add SchemaValidationFailure with full OpenAPI path
Nov 8, 2025
d936a48
Parameters: render path param schema once, pass to error functions fo…
Nov 8, 2025
e6e7b45
Makes all query params return a SchemaValidationError
Nov 15, 2025
b93b291
feat: add SchemaValidationFailure context to header parameter errors
Nov 15, 2025
0b989f3
feat: add SchemaValidationFailure context to cookie parameter errors
Nov 15, 2025
aa3b06b
refactor: remove deprecated Location field from SchemaValidationFailure
Nov 15, 2025
5ff8999
refactor: use centralized JSON Pointer helpers across codebase
Nov 15, 2025
5775925
fix lint and test
Nov 15, 2025
a825714
WIP: Add upstream files and fix Location field references
Nov 15, 2025
d693ff6
Merge origin/main into unify-context-and-centralize
Nov 15, 2025
fabe24d
Fix upstream merge conflicts and update dependencies
Nov 15, 2025
fcb8f64
Fix linting errors
Nov 15, 2025
bf68afe
Fix additional gofumpt formatting issues
Nov 15, 2025
2141779
Remove duplicate OriginalError field
Nov 15, 2025
6013125
Use ValidateSingleParameterSchemaWithPath consistently
Nov 15, 2025
d750797
Use helper for JSON Pointer construction in formatJsonSchemaValidatio…
Nov 15, 2025
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
431 changes: 395 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