Skip to content

Commit 7418c72

Browse files
docs: document openapi object argument (#1679)
1 parent 7a6c98c commit 7418c72

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

core/file-upload.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ use ApiPlatform\Metadata\ApiResource;
6060
use ApiPlatform\Metadata\Get;
6161
use ApiPlatform\Metadata\GetCollection;
6262
use ApiPlatform\Metadata\Post;
63+
use ApiPlatform\OpenApi\Model;
6364
use App\Controller\CreateMediaObjectAction;
6465
use Doctrine\ORM\Mapping as ORM;
6566
use Symfony\Component\HttpFoundation\File\File;
@@ -79,9 +80,9 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich;
7980
controller: CreateMediaObjectAction::class,
8081
deserialize: false,
8182
validationContext: ['groups' => ['Default', 'media_object_create']],
82-
openapiContext: [
83-
'requestBody' => [
84-
'content' => [
83+
openapi: new Model\Operation(
84+
requestBody: new Model\RequestBody(
85+
content: new \ArrayObject([
8586
'multipart/form-data' => [
8687
'schema' => [
8788
'type' => 'object',
@@ -93,9 +94,9 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich;
9394
]
9495
]
9596
]
96-
]
97-
]
98-
]
97+
])
98+
)
99+
)
99100
)
100101
]
101102
)]

core/openapi.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,18 +304,19 @@ namespace App\Entity;
304304

305305
use ApiPlatform\Metadata\ApiResource;
306306
use ApiPlatform\Metadata\Post;
307+
use ApiPlatform\OpenApi\Model;
307308
use App\Controller\RandomRabbit;
308309

309310
#[ApiResource]
310311
#[Post(
311312
name: 'create_rabbit',
312313
uriTemplate: '/rabbit/create',
313314
controller: RandomRabbit::class,
314-
openapiContext: [
315-
'summary' => 'Create a rabbit picture',
316-
'description' => '# Pop a great rabbit picture by color!\n\n![A great rabbit](https://rabbit.org/graphics/fun/netbunnies/jellybean1-brennan1.jpg)',
317-
'requestBody' => [
318-
'content' => [
315+
openapi: new Model\Operation(
316+
summary: 'Create a rabbit picture',
317+
description: '# Pop a great rabbit picture by color!\n\n![A great rabbit](https://rabbit.org/graphics/fun/netbunnies/jellybean1-brennan1.jpg)',
318+
requestBody: new Model\RequestBody(
319+
content: new \ArrayObject([
319320
'application/json' => [
320321
'schema' => [
321322
'type' => 'object',
@@ -329,9 +330,9 @@ use App\Controller\RandomRabbit;
329330
'description' => 'Pink Rabbit'
330331
]
331332
]
332-
]
333-
]
334-
]
333+
])
334+
)
335+
)
335336
)]
336337
class Rabbit
337338
{
@@ -347,7 +348,7 @@ resources:
347348
class: ApiPlatform\Metadata\Post
348349
path: '/rabbit/create'
349350
controller: App\Controller\RandomRabbit
350-
openapiContext:
351+
openapi:
351352
summary: Random rabbit picture
352353
description: >
353354
# Pop a great rabbit picture by color!
@@ -378,7 +379,7 @@ resources:
378379
<operations>
379380
<operation class="ApiPlatform\Metadata\Post" name="create_rabbit" uriTemplate="/rabbit/create"
380381
controller="App\Controller\RandomRabbit">
381-
<openapiContext>
382+
<openapi>
382383
<values>
383384
<value name="summary">Create a rabbit picture </value>
384385
<value name="description"># Pop a great rabbit picture by color!!
@@ -412,7 +413,7 @@ resources:
412413
</values>
413414
</value>
414415
</values>
415-
</openapiContext>
416+
</openapi>
416417
</operation>
417418
</operations>
418419
</resource>

0 commit comments

Comments
 (0)