File tree Expand file tree Collapse file tree 6 files changed +11
-3
lines changed Expand file tree Collapse file tree 6 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 14
14
trait BuildsOpenApiPaths
15
15
{
16
16
private function buildOpenApiContent (
17
+ string $ name ,
17
18
array $ resources ,
18
19
bool $ multiple = false ,
19
20
bool $ included = true ,
@@ -27,7 +28,7 @@ private function buildOpenApiContent(
27
28
'type ' => 'object ' ,
28
29
'required ' => ['data ' ],
29
30
'properties ' => array_filter ([
30
- 'links ' => $ links ? $ this ->buildLinksObject ($ item ) : [],
31
+ 'links ' => $ links ? $ this ->buildLinksObject ($ name ) : [],
31
32
'data ' => $ multiple ? ['type ' => 'array ' , 'items ' => $ item ] : $ item ,
32
33
'included ' => $ included ? ['type ' => 'array ' ] : [],
33
34
]),
@@ -36,10 +37,10 @@ private function buildOpenApiContent(
36
37
];
37
38
}
38
39
39
- private function buildLinksObject (array $ item ): array
40
+ private function buildLinksObject (string $ name ): array
40
41
{
41
42
// @todo: maybe pull in the API or Context to return a server name?
42
- $ baseUri = sprintf ('https://{server}/%s ' , $ this -> findResourceFromItem ( $ item ) );
43
+ $ baseUri = sprintf ('https://{server}/%s ' , $ name );
43
44
$ defaultQuery = ['page[limit] ' => 10 ];
44
45
45
46
$ links = [
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ public function getOpenApiPaths(Collection $collection): array
118
118
'requestBody ' => [
119
119
'required ' => true ,
120
120
'content ' => $ this ->buildOpenApiContent (
121
+ $ collection ->name (),
121
122
array_map (
122
123
fn ($ resource ) => [
123
124
'$ref ' => "#/components/schemas/ {$ resource }Create " ,
@@ -130,6 +131,7 @@ public function getOpenApiPaths(Collection $collection): array
130
131
'200 ' => [
131
132
'description ' => 'Resource created successfully. ' ,
132
133
'content ' => $ this ->buildOpenApiContent (
134
+ $ collection ->name (),
133
135
array_map (
134
136
fn ($ resource ) => ['$ref ' => "#/components/schemas/ $ resource " ],
135
137
$ collection ->resources (),
Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ public function getOpenApiPaths(Collection $collection): array
192
192
'200 ' => [
193
193
'description ' => 'Successful list all response. ' ,
194
194
'content ' => $ this ->buildOpenApiContent (
195
+ $ collection ->name (),
195
196
array_map (
196
197
fn ($ resource ) => ['$ref ' => "#/components/schemas/ $ resource " ],
197
198
$ collection ->resources (),
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ public function getOpenApiPaths(Collection $collection): array
92
92
'200 ' => [
93
93
'description ' => 'Successful custom action response. ' ,
94
94
'content ' => $ this ->buildOpenApiContent (
95
+ $ collection ->name (),
95
96
array_map (
96
97
fn ($ resource ) => ['$ref ' => "#/components/schemas/ $ resource " ],
97
98
$ collection ->resources (),
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ public function getOpenApiPaths(Collection $collection): array
77
77
'200 ' => [
78
78
'description ' => 'Successful show response. ' ,
79
79
'content ' => $ this ->buildOpenApiContent (
80
+ $ collection ->name (),
80
81
array_map (
81
82
fn ($ resource ) => ['$ref ' => "#/components/schemas/ $ resource " ],
82
83
$ collection ->resources (),
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ public function getOpenApiPaths(Collection $collection): array
98
98
'requestBody ' => [
99
99
'required ' => true ,
100
100
'content ' => $ this ->buildOpenApiContent (
101
+ $ collection ->name (),
101
102
array_map (
102
103
fn ($ resource ) => [
103
104
'$ref ' => "#/components/schemas/ {$ resource }Update " ,
@@ -110,6 +111,7 @@ public function getOpenApiPaths(Collection $collection): array
110
111
'200 ' => [
111
112
'description ' => 'Successful update response. ' ,
112
113
'content ' => $ this ->buildOpenApiContent (
114
+ $ collection ->name (),
113
115
array_map (
114
116
fn ($ resource ) => ['$ref ' => "#/components/schemas/ $ resource " ],
115
117
$ collection ->resources (),
You can’t perform that action at this time.
0 commit comments