55use Assert \Assert ;
66use FlixTech \SchemaRegistryApi \Schema \AvroReference ;
77use GuzzleHttp \Psr7 \Request ;
8- use GuzzleHttp \UriTemplate ;
98use Psr \Http \Message \RequestInterface ;
109use const FlixTech \SchemaRegistryApi \Constants \ACCEPT_HEADER ;
1110use const FlixTech \SchemaRegistryApi \Constants \COMPATIBILITY_BACKWARD ;
@@ -32,7 +31,7 @@ function allSubjectVersionsRequest(string $subjectName): RequestInterface
3231{
3332 return new Request (
3433 'GET ' ,
35- ( new UriTemplate ())-> expand ( 'subjects/{name} /versions ' , [ ' name ' => $ subjectName] ),
34+ sprintf ( 'subjects/%s /versions ' , $ subjectName ),
3635 ACCEPT_HEADER
3736 );
3837}
@@ -41,9 +40,10 @@ function singleSubjectVersionRequest(string $subjectName, string $versionId): Re
4140{
4241 return new Request (
4342 'GET ' ,
44- (new UriTemplate ())->expand (
45- 'subjects/{name}/versions/{id} ' ,
46- ['name ' => $ subjectName , 'id ' => $ versionId ]
43+ sprintf (
44+ 'subjects/%s/versions/%s ' ,
45+ $ subjectName ,
46+ $ versionId ,
4747 ),
4848 ACCEPT_HEADER
4949 );
@@ -53,7 +53,7 @@ function registerNewSchemaVersionWithSubjectRequest(string $schema, string $subj
5353{
5454 return new Request (
5555 'POST ' ,
56- ( new UriTemplate ())-> expand ( 'subjects/{name} /versions ' , [ ' name ' => $ subjectName] ),
56+ sprintf ( 'subjects/%s /versions ' , $ subjectName ),
5757 CONTENT_TYPE_HEADER + ACCEPT_HEADER ,
5858 prepareJsonSchemaForTransfer (validateSchemaStringAsJson ($ schema ), ...$ references )
5959 );
@@ -63,9 +63,10 @@ function checkSchemaCompatibilityAgainstVersionRequest(string $schema, string $s
6363{
6464 return new Request (
6565 'POST ' ,
66- (new UriTemplate ())->expand (
67- 'compatibility/subjects/{name}/versions/{version} ' ,
68- ['name ' => $ subjectName , 'version ' => $ versionId ]
66+ sprintf (
67+ 'compatibility/subjects/%s/versions/%s ' ,
68+ $ subjectName ,
69+ $ versionId ,
6970 ),
7071 CONTENT_TYPE_HEADER + ACCEPT_HEADER ,
7172 prepareJsonSchemaForTransfer (validateSchemaStringAsJson ($ schema ))
@@ -76,7 +77,7 @@ function checkIfSubjectHasSchemaRegisteredRequest(string $subjectName, string $s
7677{
7778 return new Request (
7879 'POST ' ,
79- ( new UriTemplate ())-> expand ( 'subjects/{name} ' , [ ' name ' => $ subjectName] ),
80+ sprintf ( 'subjects/%s ' , $ subjectName ),
8081 CONTENT_TYPE_HEADER + ACCEPT_HEADER ,
8182 prepareJsonSchemaForTransfer (validateSchemaStringAsJson ($ schema ))
8283 );
@@ -86,7 +87,7 @@ function schemaRequest(string $id): RequestInterface
8687{
8788 return new Request (
8889 'GET ' ,
89- ( new UriTemplate ())-> expand ( 'schemas/ids/{id} ' , [ ' id ' => $ id] ),
90+ sprintf ( 'schemas/ids/%s ' , $ id ),
9091 ACCEPT_HEADER
9192 );
9293}
@@ -114,7 +115,7 @@ function subjectCompatibilityLevelRequest(string $subjectName): RequestInterface
114115{
115116 return new Request (
116117 'GET ' ,
117- ( new UriTemplate ())-> expand ( 'config/{subject} ' , [ ' subject ' => $ subjectName] ),
118+ sprintf ( 'config/%s ' , $ subjectName ),
118119 ACCEPT_HEADER
119120 );
120121}
@@ -123,7 +124,7 @@ function changeSubjectCompatibilityLevelRequest(string $subjectName, string $lev
123124{
124125 return new Request (
125126 'PUT ' ,
126- ( new UriTemplate ())-> expand ( 'config/{subject} ' , [ ' subject ' => $ subjectName] ),
127+ sprintf ( 'config/%s ' , $ subjectName ),
127128 ACCEPT_HEADER ,
128129 prepareCompatibilityLevelForTransport (validateCompatibilityLevel ($ level ))
129130 );
@@ -208,7 +209,7 @@ function deleteSubjectRequest(string $subjectName): RequestInterface
208209{
209210 return new Request (
210211 'DELETE ' ,
211- ( new UriTemplate ())-> expand ( 'subjects/{name} ' , [ ' name ' => $ subjectName] ),
212+ sprintf ( 'subjects/%s ' , $ subjectName ),
212213 ACCEPT_HEADER
213214 );
214215}
@@ -222,7 +223,7 @@ function deleteSubjectVersionRequest(string $subjectName, string $versionId): Re
222223{
223224 return new Request (
224225 'DELETE ' ,
225- ( new UriTemplate ())-> expand ( 'subjects/{name} /versions/{version} ' , [ ' name ' => $ subjectName , ' version ' => $ versionId] ),
226+ sprintf ( 'subjects/%s /versions/%s ' , $ subjectName , $ versionId ),
226227 ACCEPT_HEADER
227228 );
228229}
0 commit comments