@@ -7590,7 +7590,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
7590
7590
use Psr \Http \Message \ResponseInterface ;
7591
7591
use Psr \Http \Message \ServerRequestInterface ;
7592
7592
use Psr \Http \Server \RequestHandlerInterface ;
7593
- use Tqdev \PhpCrudApi \Controller \Responder ;
7594
7593
use Tqdev \PhpCrudApi \Middleware \Base \Middleware ;
7595
7594
use Tqdev \PhpCrudApi \Record \ErrorCode ;
7596
7595
use Tqdev \PhpCrudApi \RequestUtils ;
@@ -7616,7 +7615,7 @@ private function getVerifiedClaims(string $token, int $time, int $leeway, int $t
7616
7615
if (isset ($ header ['kid ' ])) {
7617
7616
$ kid = $ header ['kid ' ];
7618
7617
}
7619
- if (!$ secrets [$ kid ]) {
7618
+ if (!isset ( $ secrets [$ kid ]) ) {
7620
7619
return array ();
7621
7620
}
7622
7621
$ secret = $ secrets [$ kid ];
@@ -7684,14 +7683,14 @@ private function getClaims(string $token): array
7684
7683
$ leeway = (int ) $ this ->getProperty ('leeway ' , '5 ' );
7685
7684
$ ttl = (int ) $ this ->getProperty ('ttl ' , '30 ' );
7686
7685
$ secrets = $ this ->getMapProperty ('secrets ' , '' );
7686
+ if (!$ secrets ) {
7687
+ $ secrets = [$ this ->getProperty ('secret ' , '' )];
7688
+ }
7687
7689
$ requirements = array (
7688
7690
'alg ' => $ this ->getArrayProperty ('algorithms ' , '' ),
7689
7691
'aud ' => $ this ->getArrayProperty ('audiences ' , '' ),
7690
7692
'iss ' => $ this ->getArrayProperty ('issuers ' , '' ),
7691
7693
);
7692
- if (!$ secrets ) {
7693
- return array ();
7694
- }
7695
7694
return $ this ->getVerifiedClaims ($ token , $ time , $ leeway , $ ttl , $ secrets , $ requirements );
7696
7695
}
7697
7696
@@ -8178,12 +8177,17 @@ class OpenApiBuilder
8178
8177
private $ openapi ;
8179
8178
private $ records ;
8180
8179
private $ columns ;
8180
+ private $ builders ;
8181
8181
8182
- public function __construct (ReflectionService $ reflection , array $ base , array $ controllers )
8182
+ public function __construct (ReflectionService $ reflection , array $ base , array $ controllers, array $ builders )
8183
8183
{
8184
8184
$ this ->openapi = new OpenApiDefinition ($ base );
8185
8185
$ this ->records = in_array ('records ' , $ controllers ) ? new OpenApiRecordsBuilder ($ this ->openapi , $ reflection ) : null ;
8186
8186
$ this ->columns = in_array ('columns ' , $ controllers ) ? new OpenApiColumnsBuilder ($ this ->openapi ) : null ;
8187
+ $ this ->builders = array ();
8188
+ foreach ($ builders as $ className ) {
8189
+ $ this ->builders [] = new $ className ($ this ->openapi , $ reflection );
8190
+ }
8187
8191
}
8188
8192
8189
8193
private function getServerUrl (): string
@@ -8208,6 +8212,9 @@ public function build(): OpenApiDefinition
8208
8212
if ($ this ->columns ) {
8209
8213
$ this ->columns ->build ();
8210
8214
}
8215
+ foreach ($ this ->builders as $ builder ) {
8216
+ $ builder ->build ();
8217
+ }
8211
8218
return $ this ->openapi ;
8212
8219
}
8213
8220
}
@@ -8216,8 +8223,6 @@ public function build(): OpenApiDefinition
8216
8223
// file: src/Tqdev/PhpCrudApi/OpenApi/OpenApiColumnsBuilder.php
8217
8224
namespace Tqdev \PhpCrudApi \OpenApi {
8218
8225
8219
- use Tqdev \PhpCrudApi \Column \ReflectionService ;
8220
- use Tqdev \PhpCrudApi \Middleware \Communication \VariableStore ;
8221
8226
use Tqdev \PhpCrudApi \OpenApi \OpenApiDefinition ;
8222
8227
8223
8228
class OpenApiColumnsBuilder
@@ -8786,9 +8791,9 @@ class OpenApiService
8786
8791
{
8787
8792
private $ builder ;
8788
8793
8789
- public function __construct (ReflectionService $ reflection , array $ base , array $ controllers )
8794
+ public function __construct (ReflectionService $ reflection , array $ base , array $ controllers, array $ customBuilders )
8790
8795
{
8791
- $ this ->builder = new OpenApiBuilder ($ reflection , $ base , $ controllers );
8796
+ $ this ->builder = new OpenApiBuilder ($ reflection , $ base , $ controllers, $ customBuilders );
8792
8797
}
8793
8798
8794
8799
public function get (): OpenApiDefinition
@@ -10078,7 +10083,7 @@ public function __construct(Config $config)
10078
10083
new CacheController ($ router , $ responder , $ cache );
10079
10084
break ;
10080
10085
case 'openapi ' :
10081
- $ openApi = new OpenApiService ($ reflection , $ config ->getOpenApiBase (), $ config ->getControllers ());
10086
+ $ openApi = new OpenApiService ($ reflection , $ config ->getOpenApiBase (), $ config ->getControllers (), $ config -> getCustomOpenApiBuilders () );
10082
10087
new OpenApiController ($ router , $ responder , $ openApi );
10083
10088
break ;
10084
10089
case 'geojson ' :
@@ -10182,6 +10187,7 @@ class Config
10182
10187
'middlewares ' => 'cors ' ,
10183
10188
'controllers ' => 'records,geojson,openapi ' ,
10184
10189
'customControllers ' => '' ,
10190
+ 'customOpenApiBuilders ' => '' ,
10185
10191
'cacheType ' => 'TempFile ' ,
10186
10192
'cachePath ' => '' ,
10187
10193
'cacheTime ' => 10 ,
@@ -10314,6 +10320,11 @@ public function getCustomControllers(): array
10314
10320
return array_filter (array_map ('trim ' , explode (', ' , $ this ->values ['customControllers ' ])));
10315
10321
}
10316
10322
10323
+ public function getCustomOpenApiBuilders (): array
10324
+ {
10325
+ return array_filter (array_map ('trim ' , explode (', ' , $ this ->values ['customOpenApiBuilders ' ])));
10326
+ }
10327
+
10317
10328
public function getCacheType (): string
10318
10329
{
10319
10330
return $ this ->values ['cacheType ' ];
0 commit comments