Add complete SchemaValidationFailure context to all parameter errors#6
Draft
mjbonifacio wants to merge 4 commits intojson-pointer-helpersfrom
Draft
Add complete SchemaValidationFailure context to all parameter errors#6mjbonifacio wants to merge 4 commits intojson-pointer-helpersfrom
mjbonifacio wants to merge 4 commits intojson-pointer-helpersfrom
Conversation
added 4 commits
November 15, 2025 11:43
…r ReferenceSchema
- Render parameter schema once in path_parameters.go instead of in each error function
- Pass renderedSchema to all 8 path parameter error functions (bool, enum, integer, number, array variants)
- Update Context field to use raw base.Schema (programmatic access)
- Update ReferenceSchema field to use rendered JSON string (API consumers)
- Use full OpenAPI JSON Pointer paths for KeywordLocation (e.g., /paths/~1users~1{id}/parameters/id/schema/type)
- Serialize full schema objects for ReferenceSchema instead of just type strings
- Update resolveNumber and resolveInteger helpers to accept and pass renderedSchema
Note: This approach (Context=raw schema, ReferenceSchema=rendered string) will be reviewed later for consistency across the codebase
Changes: - Remove 'Build full OpenAPI path for KeywordLocation' comments - Remove inline comments from previous commits - Add renderedSchema parameter to QueryParameterMissing - Set ReferenceSchema field in QueryParameterMissing SchemaValidationFailure - Render schema for missing required parameters before creating error - Update tests to pass renderedSchema parameter
Adds full OpenAPI context to all 7 header parameter error functions:
- HeaderParameterMissing
- HeaderParameterCannotBeDecoded (now includes SchemaValidationFailure)
- IncorrectHeaderParamEnum
- InvalidHeaderParamInteger
- InvalidHeaderParamNumber
- IncorrectHeaderParamBool
- IncorrectHeaderParamArrayBoolean
- IncorrectHeaderParamArrayNumber
All errors now include:
- KeywordLocation: Full JSON Pointer from OpenAPI root (e.g., /paths/{path}/{method}/parameters/{name}/schema/type)
- ReferenceSchema: Rendered schema as JSON string
- Context: Raw base.Schema object
- Proper FieldName and InstancePath
Updated ValidateHeaderArray to accept and pass path/operation/schema context.
Updated all test cases to pass new required parameters.
Adds full OpenAPI context to all 6 cookie parameter error functions:
- InvalidCookieParamInteger
- InvalidCookieParamNumber
- IncorrectCookieParamBool
- IncorrectCookieParamEnum
- IncorrectCookieParamArrayBoolean
- IncorrectCookieParamArrayNumber
All errors now include:
- KeywordLocation: Full JSON Pointer from OpenAPI root (e.g., /paths/{path}/{method}/parameters/{name}/schema/type)
- ReferenceSchema: Rendered schema as JSON string
- Context: Raw base.Schema object
- Proper FieldName and InstancePath
Updated ValidateCookieArray to accept and pass path/operation/schema context.
Updated all test cases to pass new required parameters.
This completes consistent SchemaValidationFailure population across all parameter types (path, query, header, cookie).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
Adds full OpenAPI
KeywordLocationpaths andReferenceSchemacontext to all parameter validation errors (path, query, header, cookie parameters). Uses the centralized JSON Pointer helpers from PR #2.Why
Before this change, parameter validation errors had incomplete context:
ReferenceSchemafield (couldn't see the schema that was violated)KeywordLocation(hard to locate the exact schema rule)Now all parameter errors include:
KeywordLocation: e.g.,/paths/~1users~1{id}/get/parameters/id/schema/minimumReferenceSchema: The actual schema definition as JSON stringThis makes debugging much easier - you can see exactly which schema rule was violated and where it's defined in your OpenAPI spec.
Pattern Applied
Each parameter validation function now:
renderedSchemato error functions (avoid re-rendering on each error)KeywordLocationconstructionExample (Path parameter validation):
SchemaValidationFailure Changes
Path Parameter Validation
Query Parameter Validation
Header Parameter Validation
Cookie Parameter Validation
Dependency Note
Commits (4)