@@ -1116,3 +1116,52 @@ func Test_ArrayValidation_ErrorContainsRenderedSchema(t *testing.T) {
11161116 // Verify error message is properly formatted
11171117 assert .Contains (t , validationErrors [0 ].Message , "ids" , "Error should reference parameter name" )
11181118}
1119+
1120+ // Test_ParameterValidation_CompleteCacheEntry verifies that parameter validation
1121+ // writes complete cache entries.
1122+ func Test_ParameterValidation_CompleteCacheEntry (t * testing.T ) {
1123+ spec := []byte (`{
1124+ "openapi": "3.1.0",
1125+ "info": {"title": "Test", "version": "1.0.0"},
1126+ "paths": {
1127+ "/test": {
1128+ "get": {
1129+ "parameters": [{
1130+ "name": "id",
1131+ "in": "query",
1132+ "schema": {"type": "string", "minLength": 1}
1133+ }],
1134+ "responses": {"200": {"description": "OK"}}
1135+ }
1136+ }
1137+ }
1138+ }` )
1139+
1140+ doc , err := libopenapi .NewDocument (spec )
1141+ require .NoError (t , err )
1142+
1143+ v3Model , errs := doc .BuildV3Model ()
1144+ require .Nil (t , errs )
1145+
1146+ opts := config .NewValidationOptions ()
1147+ validator := NewParameterValidator (& v3Model .Model , config .WithExistingOpts (opts ))
1148+
1149+ req , _ := http .NewRequest ("GET" , "/test?id=abc" , nil )
1150+ valid , _ := validator .ValidateQueryParams (req )
1151+ assert .True (t , valid )
1152+
1153+ pathItem := v3Model .Model .Paths .PathItems .GetOrZero ("/test" )
1154+ schema := pathItem .Get .Parameters [0 ].Schema .Schema ()
1155+ hash := schema .GoLow ().Hash ()
1156+
1157+ cached , ok := opts .SchemaCache .Load (hash )
1158+ require .True (t , ok , "Cache entry should exist" )
1159+
1160+ // Check that all fields of the cache entry are populated
1161+ assert .NotNil (t , cached .Schema , "Schema should be populated" )
1162+ assert .NotEmpty (t , cached .RenderedInline , "RenderedInline should be populated" )
1163+ assert .NotEmpty (t , cached .ReferenceSchema , "ReferenceSchema should be populated" )
1164+ assert .NotEmpty (t , cached .RenderedJSON , "RenderedJSON should be populated" )
1165+ assert .NotNil (t , cached .CompiledSchema , "CompiledSchema should be populated" )
1166+ assert .NotNil (t , cached .RenderedNode , "RenderedNode should be populated" )
1167+ }
0 commit comments