@@ -337,3 +337,93 @@ enum MyEnumA {
337337 assert .Equal (thirdSchemaID , fourthSchemaID , "with normalize=true, schemas with different enum value order should produce the same schema ID" )
338338 })
339339}
340+
341+ func (s * APIIntegrationTestSuite ) TestSchemaMetadata () {
342+ t := s .T ()
343+ t .Skip () //todo remove skip once redpanda v26.1 is GA
344+ require := require .New (t )
345+ assert := assert .New (t )
346+
347+ t .Run ("create schema with metadata properties" , func (t * testing.T ) {
348+ ctx , cancel := context .WithTimeout (t .Context (), 30 * time .Second )
349+ defer cancel ()
350+
351+ schemaStr := `{"type":"record","name":"User","fields":[{"name":"id","type":"string"}]}`
352+ req := struct {
353+ Schema string `json:"schema"`
354+ Type string `json:"schemaType"`
355+ Metadata struct {
356+ Properties map [string ]string `json:"properties"`
357+ } `json:"metadata"`
358+ }{
359+ Schema : schemaStr ,
360+ Type : sr .TypeAvro .String (),
361+ }
362+ req .Metadata .Properties = map [string ]string {
363+ "owner" : "team-platform" ,
364+ "version" : "1.0.0" ,
365+ }
366+
367+ res , body := s .apiRequest (ctx , http .MethodPost , "/api/schema-registry/subjects/test-metadata/versions" , req )
368+ require .Equal (200 , res .StatusCode )
369+
370+ createResponse := struct {
371+ ID int `json:"id"`
372+ }{}
373+ err := json .Unmarshal (body , & createResponse )
374+ require .NoError (err )
375+ assert .Greater (createResponse .ID , 0 , "schema ID should be returned" )
376+ })
377+
378+ t .Run ("retrieve schema with metadata" , func (t * testing.T ) {
379+ ctx , cancel := context .WithTimeout (t .Context (), 30 * time .Second )
380+ defer cancel ()
381+
382+ res , body := s .apiRequest (ctx , http .MethodGet , "/api/schema-registry/subjects/test-metadata/versions/latest" , nil )
383+ require .Equal (200 , res .StatusCode )
384+
385+ var details console.SchemaRegistrySubjectDetails
386+ err := json .Unmarshal (body , & details )
387+ require .NoError (err )
388+
389+ // Verify metadata is present in response
390+ require .Len (details .Schemas , 1 , "should have one schema" )
391+ require .NotNil (details .Schemas [0 ].Metadata , "metadata should not be nil" )
392+ assert .Equal ("team-platform" , details .Schemas [0 ].Metadata .Properties ["owner" ], "owner property should match" )
393+ assert .Equal ("1.0.0" , details .Schemas [0 ].Metadata .Properties ["version" ], "version property should match" )
394+ })
395+
396+ t .Run ("create schema without metadata (backward compatibility)" , func (t * testing.T ) {
397+ ctx , cancel := context .WithTimeout (t .Context (), 30 * time .Second )
398+ defer cancel ()
399+
400+ schemaStr := `{"type":"record","name":"Event","fields":[{"name":"id","type":"string"}]}`
401+ req := struct {
402+ Schema string `json:"schema"`
403+ Type string `json:"schemaType"`
404+ }{
405+ Schema : schemaStr ,
406+ Type : sr .TypeAvro .String (),
407+ }
408+
409+ res , body := s .apiRequest (ctx , http .MethodPost , "/api/schema-registry/subjects/test-no-metadata/versions" , req )
410+ require .Equal (200 , res .StatusCode )
411+
412+ createResponse := struct {
413+ ID int `json:"id"`
414+ }{}
415+ err := json .Unmarshal (body , & createResponse )
416+ require .NoError (err )
417+ assert .Greater (createResponse .ID , 0 , "schema ID should be returned" )
418+
419+ // Verify schema without metadata retrieves correctly
420+ res , body = s .apiRequest (ctx , http .MethodGet , "/api/schema-registry/subjects/test-no-metadata/versions/latest" , nil )
421+ require .Equal (200 , res .StatusCode )
422+
423+ var details console.SchemaRegistrySubjectDetails
424+ err = json .Unmarshal (body , & details )
425+ require .NoError (err )
426+ require .Len (details .Schemas , 1 , "should have one schema" )
427+ assert .Nil (details .Schemas [0 ].Metadata , "metadata should be nil for schema without metadata" )
428+ })
429+ }
0 commit comments