2222use Tobyz \JsonApiServer \Schema \Concerns \HasVisibility ;
2323
2424use function Tobyz \JsonApiServer \has_value ;
25- use function Tobyz \JsonApiServer \json_api_response ;
2625use function Tobyz \JsonApiServer \set_value ;
2726
2827class Create implements Endpoint, OpenApiPathsProvider
@@ -83,14 +82,14 @@ public function handle(Context $context): ?ResponseInterface
8382
8483 if ($ asyncResult !== null ) {
8584 if (is_string ($ asyncResult )) {
86- $ response = json_api_response ($ this ->buildDocument ($ context ))->withHeader (
85+ $ response = $ context -> createResponse ($ this ->buildDocument ($ context ))->withHeader (
8786 'Location ' ,
8887 $ context ->api ->basePath . '/ ' . ltrim ($ asyncResult , '/ ' ),
8988 );
9089 } else {
9190 $ context = $ context ->forModel ([$ this ->asyncCollection ], $ asyncResult );
9291
93- $ response = json_api_response (
92+ $ response = $ context -> createResponse (
9493 $ this ->buildResourceDocument ($ asyncResult , $ context ),
9594 )->withHeader (
9695 'Content-Location ' ,
@@ -110,9 +109,9 @@ public function handle(Context $context): ?ResponseInterface
110109
111110 $ this ->saveFields ($ context , $ data , true );
112111
113- $ response = json_api_response (
114- $ document = $ this ->buildResourceDocument ($ model , $ context ),
115- ) ->withStatus (201 );
112+ $ response = $ context
113+ -> createResponse ( $ document = $ this ->buildResourceDocument ($ model , $ context ))
114+ ->withStatus (201 );
116115
117116 if ($ location = $ document ['data ' ]['links ' ]['self ' ] ?? null ) {
118117 $ response = $ response ->withHeader ('Location ' , $ location );
0 commit comments