44
55use Psr \Http \Message \ResponseInterface ;
66use Tobyz \JsonApiServer \Context ;
7+ use Tobyz \JsonApiServer \Endpoint \Concerns \HasParameters ;
78use Tobyz \JsonApiServer \Endpoint \Concerns \HasResponse ;
89use Tobyz \JsonApiServer \Endpoint \Concerns \ResolvesList ;
910use Tobyz \JsonApiServer \Endpoint \Concerns \ResolvesModel ;
2122
2223class ShowRelated implements Endpoint, ProvidesRootSchema, ProvidesRelationshipLinks
2324{
25+ use HasParameters;
2426 use HasResponse;
2527 use ResolvesModel;
2628 use ResolvesRelationship;
@@ -54,7 +56,7 @@ public function handle(Context $context): ?ResponseInterface
5456 return null ;
5557 }
5658
57- $ context = $ context ->withParameters ($ this ->parameters ($ field , $ context ));
59+ $ context = $ context ->withParameters ($ this ->getParameters ($ field , $ context ));
5860
5961 $ relatedData = $ this ->resolveRelationshipData ($ context , $ field );
6062
@@ -117,7 +119,7 @@ public function rootSchema(SchemaContext $context): array
117119 ],
118120 ...array_map (
119121 fn (Parameter $ parameter ) => $ parameter ->getSchema ($ context ),
120- $ this ->parameters ($ field , $ context ),
122+ $ this ->getParameters ($ field , $ context ),
121123 ),
122124 ],
123125 'responses ' => [
@@ -141,7 +143,7 @@ public function rootSchema(SchemaContext $context): array
141143 return ['paths ' => $ paths ];
142144 }
143145
144- protected function parameters (Relationship $ field , SchemaContext $ context ): array
146+ protected function getParameters (Relationship $ field , SchemaContext $ context ): array
145147 {
146148 $ parameters = $ this ->resourceDocumentParameters ();
147149
@@ -152,7 +154,7 @@ protected function parameters(Relationship $field, SchemaContext $context): arra
152154 );
153155 }
154156
155- return $ parameters ;
157+ return [... $ parameters, ... $ this -> parameters ] ;
156158 }
157159
158160 public function relationshipLinks (Relationship $ field , SchemaContext $ context ): array
0 commit comments