|
12 | 12 | use Symfony\Component\Serializer\Encoder\XmlEncoder; |
13 | 13 | use Symfony\Component\Serializer\SerializerInterface; |
14 | 14 |
|
| 15 | +#[Get( |
| 16 | + uriTemplate: '/greet', |
| 17 | + extraProperties: [OpenApiFactory::OVERRIDE_OPENAPI_RESPONSES => false], |
| 18 | + openapi: new Model\Operation( |
| 19 | + summary: 'Greet', |
| 20 | + description: 'Greets a recipient with a salutation', |
| 21 | + tags: [ |
| 22 | + 'App', |
| 23 | + ], |
| 24 | + parameters: [ |
| 25 | + new Model\Parameter( |
| 26 | + name: 'Accept', |
| 27 | + in: 'header', |
| 28 | + required: false, |
| 29 | + description: 'If set, the greeting is returned in XML or JSON format.', |
| 30 | + schema: [ |
| 31 | + 'type' => 'string', |
| 32 | + ], |
| 33 | + example: 'application/vnd.ibexa.api.Greeting+json', |
| 34 | + ), |
| 35 | + ], |
| 36 | + responses: [ |
| 37 | + Response::HTTP_OK => [ |
| 38 | + 'description' => 'OK - Return a greeting', |
| 39 | + 'content' => [ |
| 40 | + 'application/vnd.ibexa.api.Greeting+xml' => [ |
| 41 | + 'schema' => [ |
| 42 | + 'xml' => [ |
| 43 | + 'name' => 'Greeting', |
| 44 | + 'wrapped' => false, |
| 45 | + ], |
| 46 | + 'properties' => [ |
| 47 | + 'salutation' => [ |
| 48 | + 'type' => 'string', |
| 49 | + ], |
| 50 | + 'recipient' => [ |
| 51 | + 'type' => 'string', |
| 52 | + ], |
| 53 | + 'sentence' => [ |
| 54 | + 'type' => 'string', |
| 55 | + 'description' => 'Composed sentence using salutation and recipient.' |
| 56 | + ] |
| 57 | + ], |
| 58 | + ], |
| 59 | + 'example' => [ |
| 60 | + 'salutation' => 'Hello', |
| 61 | + 'recipient' => 'World', |
| 62 | + 'sentence' => 'Hello World', |
| 63 | + ], |
| 64 | + ], |
| 65 | + 'application/vnd.ibexa.api.Greeting+json' => [ |
| 66 | + 'schema' => [ |
| 67 | + 'type' => 'object', |
| 68 | + 'properties' => [ |
| 69 | + 'Greeting' => [ |
| 70 | + 'type' => 'object', |
| 71 | + 'properties' => [ |
| 72 | + 'salutation' => [ |
| 73 | + 'type' => 'string', |
| 74 | + ], |
| 75 | + 'recipient' => [ |
| 76 | + 'type' => 'string', |
| 77 | + ], |
| 78 | + 'sentence' => [ |
| 79 | + 'type' => 'string', |
| 80 | + 'description' => 'Composed sentence using salutation and recipient.' |
| 81 | + ], |
| 82 | + ], |
| 83 | + ], |
| 84 | + ], |
| 85 | + ], |
| 86 | + 'example' => [ |
| 87 | + 'Greeting' => [ |
| 88 | + 'salutation' => 'Hello', |
| 89 | + 'recipient' => 'World', |
| 90 | + 'sentence' => 'Hello World', |
| 91 | + ], |
| 92 | + ], |
| 93 | + ], |
| 94 | + ], |
| 95 | + ], |
| 96 | + ], |
| 97 | + ), |
| 98 | +)] |
15 | 99 | #[Post( |
16 | 100 | uriTemplate: '/greet', |
17 | 101 | extraProperties: [OpenApiFactory::OVERRIDE_OPENAPI_RESPONSES => false], |
|
30 | 114 | schema: [ |
31 | 115 | 'type' => 'string', |
32 | 116 | ], |
| 117 | + example: 'application/vnd.ibexa.api.GreetingInput+json', |
33 | 118 | ), |
34 | 119 | new Model\Parameter( |
35 | 120 | name: 'Accept', |
36 | 121 | in: 'header', |
37 | | - required: true, |
| 122 | + required: false, |
38 | 123 | description: 'If set, the greeting is returned in XML or JSON format.', |
39 | 124 | schema: [ |
40 | 125 | 'type' => 'string', |
41 | 126 | ], |
| 127 | + example: 'application/vnd.ibexa.api.Greeting+json', |
42 | 128 | ), |
43 | 129 | ], |
44 | 130 | requestBody: new Model\RequestBody( |
|
138 | 224 | ], |
139 | 225 | 'sentence' => [ |
140 | 226 | 'type' => 'string', |
| 227 | + 'description' => 'Composed sentence using salutation and recipient.' |
141 | 228 | ], |
142 | 229 | ], |
143 | 230 | ], |
|
0 commit comments