4
4
5
5
use Psr \Http \Message \ResponseInterface ;
6
6
use Tobyz \JsonApiServer \Context ;
7
+ use Tobyz \JsonApiServer \Endpoint \Concerns \HasParameters ;
7
8
use Tobyz \JsonApiServer \Endpoint \Concerns \HasResponse ;
8
9
use Tobyz \JsonApiServer \Endpoint \Concerns \ResolvesList ;
9
10
use Tobyz \JsonApiServer \Endpoint \Concerns \ResolvesModel ;
21
22
22
23
class ShowRelated implements Endpoint, ProvidesRootSchema, ProvidesRelationshipLinks
23
24
{
25
+ use HasParameters;
24
26
use HasResponse;
25
27
use ResolvesModel;
26
28
use ResolvesRelationship;
@@ -54,7 +56,7 @@ public function handle(Context $context): ?ResponseInterface
54
56
return null ;
55
57
}
56
58
57
- $ context = $ context ->withParameters ($ this ->parameters ($ field , $ context ));
59
+ $ context = $ context ->withParameters ($ this ->getParameters ($ field , $ context ));
58
60
59
61
$ relatedData = $ this ->resolveRelationshipData ($ context , $ field );
60
62
@@ -117,7 +119,7 @@ public function rootSchema(SchemaContext $context): array
117
119
],
118
120
...array_map (
119
121
fn (Parameter $ parameter ) => $ parameter ->getSchema ($ context ),
120
- $ this ->parameters ($ field , $ context ),
122
+ $ this ->getParameters ($ field , $ context ),
121
123
),
122
124
],
123
125
'responses ' => [
@@ -141,7 +143,7 @@ public function rootSchema(SchemaContext $context): array
141
143
return ['paths ' => $ paths ];
142
144
}
143
145
144
- protected function parameters (Relationship $ field , SchemaContext $ context ): array
146
+ protected function getParameters (Relationship $ field , SchemaContext $ context ): array
145
147
{
146
148
$ parameters = $ this ->resourceDocumentParameters ();
147
149
@@ -152,7 +154,7 @@ protected function parameters(Relationship $field, SchemaContext $context): arra
152
154
);
153
155
}
154
156
155
- return $ parameters ;
157
+ return [... $ parameters, ... $ this -> parameters ] ;
156
158
}
157
159
158
160
public function relationshipLinks (Relationship $ field , SchemaContext $ context ): array
0 commit comments