1+ <?php
2+ /**
3+ * Created by PhpStorm.
4+ * User: cebe
5+ * Date: 07.11.18
6+ * Time: 23:46
7+ */
8+
9+ namespace cebe \openapi \spec ;
10+ use cebe \openapi \SpecBaseObject ;
11+
12+ /**
13+ * Describes a single API operation on a path.
14+ *
15+ * @link https://github.com/OAI/OpenAPI-Specification/blob/3.0.2/versions/3.0.2.md#operationObject
16+ *
17+ * @property-read string[] $tags
18+ * @property-read string $summary
19+ * @property-read string $description
20+ * @property-read ExternalDocumentation|null $externalDocs
21+ * @property-read string $operationId
22+ * @property-read Parameter[]|Reference[] $parameters
23+ * @property-read RequestBody|Reference $requestBody
24+ * @property-read Responses $responses
25+ * @property-read Callback[]|Reference[] $callbacks
26+ * @property-read bool $deprecated
27+ * @property-read SecurityRequirement[] $security
28+ * @property-read Server[] $servers
29+ */
30+ class Operation extends SpecBaseObject
31+ {
32+
33+ /**
34+ * @return array array of attributes available in this object.
35+ */
36+ protected function attributes (): array
37+ {
38+ return [
39+ 'tags ' => [Tag::class],
40+ 'summary ' => Type::STRING ,
41+ 'description ' => Type::STRING ,
42+ 'externalDocs ' => ExternalDocumentation::class,
43+ 'operationId ' => Type::STRING ,
44+ 'parameters ' => [Parameter::class],// TODO reference
45+ 'requestBody ' => RequestBody::class,
46+ 'responses ' => Responses::class,
47+ 'callbacks ' => [Callback::class],// TODO reference
48+ 'deprecated ' => Type::BOOLEAN ,
49+ 'security ' => [SecurityRequirement::class],
50+ 'servers ' => [Server::class],
51+ ];
52+ }
53+
54+ /**
55+ * Perform validation on this object, check data against OpenAPI Specification rules.
56+ *
57+ * Call `addError()` in case of validation errors.
58+ */
59+ protected function performValidation ()
60+ {
61+ $ this ->requireProperties (['responses ' ]);
62+ }
63+ }
0 commit comments