Skip to content

Commit 8766f51

Browse files
committed
Fix OpenAPI generation
1 parent 3819b4c commit 8766f51

File tree

3 files changed

+309
-302
lines changed

3 files changed

+309
-302
lines changed

src/Endpoint/Create.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,19 @@ private function fillDefaultValues(Context $context, array &$data): void
109109

110110
public function getOpenApiPaths(Collection $collection, JsonApi $api): array
111111
{
112+
$type = $collection->name();
113+
112114
return [
113-
"/{$collection->name()}" => [
115+
"/$type" => [
114116
'post' => [
115-
'description' => $this->getDescription(),
116-
'tags' => [$collection->name()],
117+
'description' => $this->getDescription() ?: "Create $type resource",
118+
'tags' => [$type],
117119
'requestBody' => [
118120
'required' => true,
119121
'content' => $this->buildOpenApiContent(
120122
array_map(
121123
fn($resource) => [
122-
'$ref' => "#/components/schemas/{$resource}Create",
124+
'$ref' => "#/components/schemas/{$resource}_create",
123125
],
124126
$collection->resources(),
125127
),

src/OpenApi/OpenApiGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function generate(JsonApi $api): array
5656

5757
foreach ([$id, ...$resource->fields()] as $field) {
5858
$location = $field::location();
59-
$valueSchema = $field->getSchema($api);
59+
$valueSchema = (object) $field->getSchema($api);
6060

6161
if ($field instanceof Relationship) {
6262
$relationshipSchema = "{$type}_{$field->name}";

0 commit comments

Comments
 (0)