|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace cebe\openapi\spec; |
| 4 | + |
| 5 | +/** |
| 6 | + * The object provides metadata about the API. |
| 7 | + * |
| 8 | + * The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. |
| 9 | + * |
| 10 | + * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#infoObject |
| 11 | + * |
| 12 | + * @property-read string $title |
| 13 | + * @property-read string $description |
| 14 | + * @property-read string $termsOfService |
| 15 | + * @property-read Contact|null $contact |
| 16 | + * @property-read License|null $license |
| 17 | + * @property-read string $version |
| 18 | + * |
| 19 | + * @author Carsten Brandt <mail@cebe.cc> |
| 20 | + */ |
| 21 | +class Info extends SpecBaseObject |
| 22 | +{ |
| 23 | + /** |
| 24 | + * @return array array of attributes available in this object. |
| 25 | + */ |
| 26 | + protected function attributes(): array |
| 27 | + { |
| 28 | + return [ |
| 29 | + 'title' => 'string', |
| 30 | + 'description' => 'string', |
| 31 | + 'termsOfService' => 'string', |
| 32 | + 'contact' => Contact::class, |
| 33 | + 'license' => License::class, |
| 34 | + 'version' => 'string', |
| 35 | + ]; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Perform validation on this object, check data against OpenAPI Specification rules. |
| 40 | + * |
| 41 | + * Call `addError()` in case of validation errors. |
| 42 | + */ |
| 43 | + protected function performValidation() |
| 44 | + { |
| 45 | + $this->requireProperties(['title', 'version']); |
| 46 | + } |
| 47 | +} |
0 commit comments