From 13d6c1cbbaa104a56a0da2bdbcb06857adc9da7e Mon Sep 17 00:00:00 2001 From: Michael Calcinai Date: Mon, 14 Jan 2019 16:43:08 +1300 Subject: [PATCH] Adds OAS 3.0 support, fixes #3 --- src/BaseSchema.php | 28 +- src/Definitions/AnysOrExpressions.php | 39 ++ src/Definitions/BodyParameter.php | 139 ------ src/Definitions/Callback.php | 42 ++ src/Definitions/CallbacksOrReferences.php | 39 ++ src/Definitions/Components.php | 213 +++++++++ src/Definitions/Contact.php | 15 +- src/Definitions/Discriminator.php | 80 ++++ src/Definitions/Encoding.php | 137 ++++++ .../{NonBodyParameter.php => Encodings.php} | 4 +- .../{ApiKeySecurity.php => Example.php} | 56 ++- src/Definitions/ExamplesOrReferences.php | 39 ++ .../{Examples.php => Expression.php} | 2 +- src/Definitions/ExternalDocs.php | 8 +- src/Definitions/FileSchema.php | 206 -------- .../FormDataParameterSubSchema.php | 445 ------------------ src/Definitions/Header.php | 274 ++++------- src/Definitions/HeaderParameterSubSchema.php | 425 ----------------- .../{Headers.php => HeadersOrReferences.php} | 4 +- src/Definitions/Info.php | 62 +-- src/Definitions/License.php | 13 +- src/Definitions/Link.php | 158 +++++++ src/Definitions/LinksOrReferences.php | 39 ++ src/Definitions/MediaType.php | 118 +++++ src/Definitions/MediaTypes.php | 39 ++ src/Definitions/Oauth2ApplicationSecurity.php | 129 ----- src/Definitions/Oauth2ImplicitSecurity.php | 129 ----- src/Definitions/Oauth2PasswordSecurity.php | 129 ----- ...h2AccessCodeSecurity.php => OauthFlow.php} | 95 ++-- src/Definitions/OauthFlows.php | 126 +++++ src/Definitions/Operation.php | 117 ++--- src/Definitions/Parameter.php | 289 ++++++++++++ src/Definitions/ParameterDefinitions.php | 42 -- src/Definitions/ParametersOrReferences.php | 39 ++ src/Definitions/PathItem.php | 114 ++++- src/Definitions/PathParameterSubSchema.php | 425 ----------------- src/Definitions/Paths.php | 4 +- src/Definitions/PrimitivesItems.php | 345 -------------- src/Definitions/QueryParameterSubSchema.php | 445 ------------------ .../{JsonReference.php => Reference.php} | 8 +- src/Definitions/RequestBodiesOrReferences.php | 39 ++ src/Definitions/RequestBody.php | 99 ++++ src/Definitions/Response.php | 47 +- src/Definitions/Responses.php | 25 +- ...initions.php => ResponsesOrReferences.php} | 7 +- src/Definitions/Schema.php | 359 +++++++++----- .../Schema/Properties/Properties.php | 2 +- ...efinitions.php => SchemasOrReferences.php} | 7 +- src/Definitions/SecurityDefinitions.php | 39 -- src/Definitions/SecurityRequirement.php | 7 +- src/Definitions/SecurityScheme.php | 196 ++++++++ .../SecuritySchemesOrReferences.php | 39 ++ src/Definitions/Server.php | 99 ++++ ...icationSecurity.php => ServerVariable.php} | 44 +- src/Definitions/ServerVariables.php | 39 ++ .../{Oauth2Scopes.php => Strings.php} | 4 +- src/Definitions/Tag.php | 14 +- src/Definitions/Xml.php | 20 +- src/OpenAPI.php | 208 ++++++++ src/Swagger.php | 341 -------------- 60 files changed, 2875 insertions(+), 3820 deletions(-) create mode 100644 src/Definitions/AnysOrExpressions.php delete mode 100644 src/Definitions/BodyParameter.php create mode 100644 src/Definitions/Callback.php create mode 100644 src/Definitions/CallbacksOrReferences.php create mode 100644 src/Definitions/Components.php create mode 100644 src/Definitions/Discriminator.php create mode 100644 src/Definitions/Encoding.php rename src/Definitions/{NonBodyParameter.php => Encodings.php} (85%) rename src/Definitions/{ApiKeySecurity.php => Example.php} (54%) create mode 100644 src/Definitions/ExamplesOrReferences.php rename src/Definitions/{Examples.php => Expression.php} (95%) delete mode 100644 src/Definitions/FileSchema.php delete mode 100644 src/Definitions/FormDataParameterSubSchema.php delete mode 100644 src/Definitions/HeaderParameterSubSchema.php rename src/Definitions/{Headers.php => HeadersOrReferences.php} (89%) create mode 100644 src/Definitions/Link.php create mode 100644 src/Definitions/LinksOrReferences.php create mode 100644 src/Definitions/MediaType.php create mode 100644 src/Definitions/MediaTypes.php delete mode 100644 src/Definitions/Oauth2ApplicationSecurity.php delete mode 100644 src/Definitions/Oauth2ImplicitSecurity.php delete mode 100644 src/Definitions/Oauth2PasswordSecurity.php rename src/Definitions/{Oauth2AccessCodeSecurity.php => OauthFlow.php} (54%) create mode 100644 src/Definitions/OauthFlows.php create mode 100644 src/Definitions/Parameter.php delete mode 100644 src/Definitions/ParameterDefinitions.php create mode 100644 src/Definitions/ParametersOrReferences.php delete mode 100644 src/Definitions/PathParameterSubSchema.php delete mode 100644 src/Definitions/PrimitivesItems.php delete mode 100644 src/Definitions/QueryParameterSubSchema.php rename src/Definitions/{JsonReference.php => Reference.php} (65%) create mode 100644 src/Definitions/RequestBodiesOrReferences.php create mode 100644 src/Definitions/RequestBody.php rename src/Definitions/{ResponseDefinitions.php => ResponsesOrReferences.php} (86%) rename src/Definitions/{Definitions.php => SchemasOrReferences.php} (82%) delete mode 100644 src/Definitions/SecurityDefinitions.php create mode 100644 src/Definitions/SecurityScheme.php create mode 100644 src/Definitions/SecuritySchemesOrReferences.php create mode 100644 src/Definitions/Server.php rename src/Definitions/{BasicAuthenticationSecurity.php => ServerVariable.php} (50%) create mode 100644 src/Definitions/ServerVariables.php rename src/Definitions/{Oauth2Scopes.php => Strings.php} (87%) create mode 100644 src/OpenAPI.php delete mode 100644 src/Swagger.php diff --git a/src/BaseSchema.php b/src/BaseSchema.php index 2a9c5ab..ba29b3b 100644 --- a/src/BaseSchema.php +++ b/src/BaseSchema.php @@ -24,6 +24,10 @@ abstract class BaseSchema implements \IteratorAggregate, \Countable, \JsonSerial */ protected static $additional_properties = []; + /** + * @param array $data + * @throws \Exception + */ public function __construct($data = []) { $this->parseData($data); @@ -110,8 +114,11 @@ private function validateProperty($property_name, $value) if (empty(static::$properties[$property_name])) { return true; } - foreach (static::$properties[$property_name] as $allowed_class) { - $fq_class = self::getFQCN($allowed_class); + foreach (static::$properties[$property_name] as $allowed_type) { + if (gettype($value) === $allowed_type) { + return true; + } + $fq_class = self::getFQCN($allowed_type); if ($value instanceof $fq_class) { return true; } @@ -124,8 +131,11 @@ private function validateProperty($property_name, $value) if (empty(static::$additional_properties)) { return true; } - foreach (static::$additional_properties as $allowed_class) { - $fq_class = self::getFQCN($allowed_class); + foreach (static::$additional_properties as $allowed_type) { + if (gettype($value) === $allowed_type) { + return true; + } + $fq_class = self::getFQCN($allowed_type); if ($value instanceof $fq_class) { return true; } @@ -145,8 +155,11 @@ private function validateProperty($property_name, $value) if (!isset($types[0])) { return true; } - foreach ($types as $allowed_class) { - $fq_class = self::getFQCN($allowed_class); + foreach ($types as $allowed_type) { + if (gettype($value) === $allowed_type) { + return true; + } + $fq_class = self::getFQCN($allowed_type); if ($value instanceof $fq_class) { return true; } @@ -160,6 +173,7 @@ private function validateProperty($property_name, $value) * Parse a schema object into the correct objects * * @param $data + * @throws \Exception */ private function parseData($data) { @@ -193,6 +207,7 @@ private function parseData($data) * @param $types_to_try * @param $object * @return BaseSchema + * @throws \Exception */ private static function tryToCast($types_to_try, $object) { @@ -225,6 +240,7 @@ protected static function getFQCN($relative_class) /** * @param array $data * @return static + * @throws \Exception */ public static function create($data = []) { diff --git a/src/Definitions/AnysOrExpressions.php b/src/Definitions/AnysOrExpressions.php new file mode 100644 index 0000000..e3da96e --- /dev/null +++ b/src/Definitions/AnysOrExpressions.php @@ -0,0 +1,39 @@ + 'body']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['in' => ['body']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['description' => [], 'name' => [], 'in' => [], 'required' => [], 'schema' => ['Definitions\\Schema']]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @param string $description - * @return $this - */ - public function setDescription($description) - { - $this->set('description', $description); - return $this; - } - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @return string - */ - public function getDescription() - { - return $this->get('description'); - } - - /** - * The name of the parameter. - * @param string $name - * @return $this - */ - public function setName($name) - { - $this->set('name', $name); - return $this; - } - - /** - * The name of the parameter. - * @return string - */ - public function getName() - { - return $this->get('name'); - } - - /** - * Determines the location of the parameter. - * @param string $in - * @return $this - */ - public function setIn($in) - { - $this->set('in', $in); - return $this; - } - - /** - * Determines the location of the parameter. - * @return string - */ - public function getIn() - { - return $this->get('in'); - } - - /** - * Determines whether or not this parameter is required or optional. - * @param bool $required - * @return $this - */ - public function setRequired($required) - { - $this->set('required', $required); - return $this; - } - - /** - * Determines whether or not this parameter is required or optional. - * @return bool - */ - public function getRequired() - { - return $this->get('required'); - } - - /** - * A deterministic version of a JSON Schema object. - * @param Schema $schema - * @return $this - */ - public function setSchema(Schema $schema) - { - $this->set('schema', $schema); - return $this; - } - - /** - * A deterministic version of a JSON Schema object. - * @return Schema - */ - public function getSchema() - { - return $this->get('schema'); - } - -} \ No newline at end of file diff --git a/src/Definitions/Callback.php b/src/Definitions/Callback.php new file mode 100644 index 0000000..bf0831b --- /dev/null +++ b/src/Definitions/Callback.php @@ -0,0 +1,42 @@ + ['Definitions\\PathItem'], '^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + +} \ No newline at end of file diff --git a/src/Definitions/CallbacksOrReferences.php b/src/Definitions/CallbacksOrReferences.php new file mode 100644 index 0000000..ef50e59 --- /dev/null +++ b/src/Definitions/CallbacksOrReferences.php @@ -0,0 +1,39 @@ + ['Definitions\\SchemasOrReferences'], 'responses' => ['Definitions\\ResponsesOrReferences'], 'parameters' => ['Definitions\\ParametersOrReferences'], 'examples' => ['Definitions\\ExamplesOrReferences'], 'requestBodies' => ['Definitions\\RequestBodiesOrReferences'], 'headers' => ['Definitions\\HeadersOrReferences'], 'securitySchemes' => ['Definitions\\SecuritySchemesOrReferences'], 'links' => ['Definitions\\LinksOrReferences'], 'callbacks' => ['Definitions\\CallbacksOrReferences']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param SchemasOrReferences $schemas + * @return $this + * @throws \Exception + */ + public function setSchemas(SchemasOrReferences $schemas) + { + $this->set('schemas', $schemas); + return $this; + } + + /** + * @return SchemasOrReferences + */ + public function getSchemas() + { + return $this->get('schemas'); + } + + /** + * @param ResponsesOrReferences $responses + * @return $this + * @throws \Exception + */ + public function setResponses(ResponsesOrReferences $responses) + { + $this->set('responses', $responses); + return $this; + } + + /** + * @return ResponsesOrReferences + */ + public function getResponses() + { + return $this->get('responses'); + } + + /** + * @param ParametersOrReferences $parameters + * @return $this + * @throws \Exception + */ + public function setParameters(ParametersOrReferences $parameters) + { + $this->set('parameters', $parameters); + return $this; + } + + /** + * @return ParametersOrReferences + */ + public function getParameters() + { + return $this->get('parameters'); + } + + /** + * @param ExamplesOrReferences $examples + * @return $this + * @throws \Exception + */ + public function setExamples(ExamplesOrReferences $examples) + { + $this->set('examples', $examples); + return $this; + } + + /** + * @return ExamplesOrReferences + */ + public function getExamples() + { + return $this->get('examples'); + } + + /** + * @param RequestBodiesOrReferences $requestBodies + * @return $this + * @throws \Exception + */ + public function setRequestBodies(RequestBodiesOrReferences $requestBodies) + { + $this->set('requestBodies', $requestBodies); + return $this; + } + + /** + * @return RequestBodiesOrReferences + */ + public function getRequestBodies() + { + return $this->get('requestBodies'); + } + + /** + * @param HeadersOrReferences $headers + * @return $this + * @throws \Exception + */ + public function setHeaders(HeadersOrReferences $headers) + { + $this->set('headers', $headers); + return $this; + } + + /** + * @return HeadersOrReferences + */ + public function getHeaders() + { + return $this->get('headers'); + } + + /** + * @param SecuritySchemesOrReferences $securitySchemes + * @return $this + * @throws \Exception + */ + public function setSecuritySchemes(SecuritySchemesOrReferences $securitySchemes) + { + $this->set('securitySchemes', $securitySchemes); + return $this; + } + + /** + * @return SecuritySchemesOrReferences + */ + public function getSecuritySchemes() + { + return $this->get('securitySchemes'); + } + + /** + * @param LinksOrReferences $links + * @return $this + * @throws \Exception + */ + public function setLinks(LinksOrReferences $links) + { + $this->set('links', $links); + return $this; + } + + /** + * @return LinksOrReferences + */ + public function getLinks() + { + return $this->get('links'); + } + + /** + * @param CallbacksOrReferences $callbacks + * @return $this + * @throws \Exception + */ + public function setCallbacks(CallbacksOrReferences $callbacks) + { + $this->set('callbacks', $callbacks); + return $this; + } + + /** + * @return CallbacksOrReferences + */ + public function getCallbacks() + { + return $this->get('callbacks'); + } + +} \ No newline at end of file diff --git a/src/Definitions/Contact.php b/src/Definitions/Contact.php index b3bcefc..bb6c1fd 100644 --- a/src/Definitions/Contact.php +++ b/src/Definitions/Contact.php @@ -4,7 +4,7 @@ use Calcinai\Strut\BaseSchema; /** - * Contact information for the owners of the API. + * Contact information for the exposed API. */ class Contact extends BaseSchema @@ -25,7 +25,7 @@ class Contact extends BaseSchema * Properties and types * @var array */ - protected static $properties = ['name' => [], 'url' => [], 'email' => []]; + protected static $properties = ['name' => ['string'], 'url' => ['string'], 'email' => ['string']]; /** * Allowed additional properties @@ -37,12 +37,12 @@ class Contact extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** - * The identifying name of the contact person/organization. * @param string $name * @return $this + * @throws \Exception */ public function setName($name) { @@ -51,7 +51,6 @@ public function setName($name) } /** - * The identifying name of the contact person/organization. * @return string */ public function getName() @@ -60,9 +59,9 @@ public function getName() } /** - * The URL pointing to the contact information. * @param string $url * @return $this + * @throws \Exception */ public function setUrl($url) { @@ -71,7 +70,6 @@ public function setUrl($url) } /** - * The URL pointing to the contact information. * @return string */ public function getUrl() @@ -80,9 +78,9 @@ public function getUrl() } /** - * The email address of the contact person/organization. * @param string $email * @return $this + * @throws \Exception */ public function setEmail($email) { @@ -91,7 +89,6 @@ public function setEmail($email) } /** - * The email address of the contact person/organization. * @return string */ public function getEmail() diff --git a/src/Definitions/Discriminator.php b/src/Definitions/Discriminator.php new file mode 100644 index 0000000..4e20db6 --- /dev/null +++ b/src/Definitions/Discriminator.php @@ -0,0 +1,80 @@ + ['string'], 'mapping' => ['Definitions\\Strings']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = []; + + /** + * @param string $propertyName + * @return $this + * @throws \Exception + */ + public function setPropertyName($propertyName) + { + $this->set('propertyName', $propertyName); + return $this; + } + + /** + * @return string + */ + public function getPropertyName() + { + return $this->get('propertyName'); + } + + /** + * @param Strings $mapping + * @return $this + * @throws \Exception + */ + public function setMapping(Strings $mapping) + { + $this->set('mapping', $mapping); + return $this; + } + + /** + * @return Strings + */ + public function getMapping() + { + return $this->get('mapping'); + } + +} \ No newline at end of file diff --git a/src/Definitions/Encoding.php b/src/Definitions/Encoding.php new file mode 100644 index 0000000..97050f0 --- /dev/null +++ b/src/Definitions/Encoding.php @@ -0,0 +1,137 @@ + ['string'], 'headers' => ['Definitions\\HeadersOrReferences'], 'style' => ['string'], 'explode' => ['boolean'], 'allowReserved' => ['boolean']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param string $contentType + * @return $this + * @throws \Exception + */ + public function setContentType($contentType) + { + $this->set('contentType', $contentType); + return $this; + } + + /** + * @return string + */ + public function getContentType() + { + return $this->get('contentType'); + } + + /** + * @param HeadersOrReferences $headers + * @return $this + * @throws \Exception + */ + public function setHeaders(HeadersOrReferences $headers) + { + $this->set('headers', $headers); + return $this; + } + + /** + * @return HeadersOrReferences + */ + public function getHeaders() + { + return $this->get('headers'); + } + + /** + * @param string $style + * @return $this + * @throws \Exception + */ + public function setStyle($style) + { + $this->set('style', $style); + return $this; + } + + /** + * @return string + */ + public function getStyle() + { + return $this->get('style'); + } + + /** + * @param boolean $explode + * @return $this + * @throws \Exception + */ + public function setExplode($explode) + { + $this->set('explode', $explode); + return $this; + } + + /** + * @return boolean + */ + public function getExplode() + { + return $this->get('explode'); + } + + /** + * @param boolean $allowReserved + * @return $this + * @throws \Exception + */ + public function setAllowReserved($allowReserved) + { + $this->set('allowReserved', $allowReserved); + return $this; + } + + /** + * @return boolean + */ + public function getAllowReserved() + { + return $this->get('allowReserved'); + } + +} \ No newline at end of file diff --git a/src/Definitions/NonBodyParameter.php b/src/Definitions/Encodings.php similarity index 85% rename from src/Definitions/NonBodyParameter.php rename to src/Definitions/Encodings.php index 0cb5443..0a086c9 100644 --- a/src/Definitions/NonBodyParameter.php +++ b/src/Definitions/Encodings.php @@ -4,7 +4,7 @@ use Calcinai\Strut\BaseSchema; -class NonBodyParameter extends BaseSchema +class Encodings extends BaseSchema { /** * Array to store schema data and default values @@ -28,7 +28,7 @@ class NonBodyParameter extends BaseSchema * Allowed additional properties * @var array */ - protected static $additional_properties = null; + protected static $additional_properties = ['Definitions\\Encoding']; /** * Array to store any allowed pattern properties diff --git a/src/Definitions/ApiKeySecurity.php b/src/Definitions/Example.php similarity index 54% rename from src/Definitions/ApiKeySecurity.php rename to src/Definitions/Example.php index 2481189..14ff384 100644 --- a/src/Definitions/ApiKeySecurity.php +++ b/src/Definitions/Example.php @@ -4,25 +4,25 @@ use Calcinai\Strut\BaseSchema; -class ApiKeySecurity extends BaseSchema +class Example extends BaseSchema { /** * Array to store schema data and default values * @var array */ - protected $data = ['type' => 'apiKey']; + protected $data = []; /** * Any enums that exist on this object * @var array */ - protected static $enums = ['type' => ['apiKey'], 'in' => ['header', 'query']]; + protected static $enums = []; /** * Properties and types * @var array */ - protected static $properties = ['type' => [], 'name' => [], 'in' => [], 'description' => []]; + protected static $properties = ['summary' => ['string'], 'description' => ['string'], 'value' => ['mixed'], 'externalValue' => ['string']]; /** * Allowed additional properties @@ -34,78 +34,82 @@ class ApiKeySecurity extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** - * @param string $type + * @param string $summary * @return $this + * @throws \Exception */ - public function setType($type) + public function setSummary($summary) { - $this->set('type', $type); + $this->set('summary', $summary); return $this; } /** * @return string */ - public function getType() + public function getSummary() { - return $this->get('type'); + return $this->get('summary'); } /** - * @param string $name + * @param string $description * @return $this + * @throws \Exception */ - public function setName($name) + public function setDescription($description) { - $this->set('name', $name); + $this->set('description', $description); return $this; } /** * @return string */ - public function getName() + public function getDescription() { - return $this->get('name'); + return $this->get('description'); } /** - * @param string $in + * @param mixed $value * @return $this + * @throws \Exception */ - public function setIn($in) + public function setValue($value) { - $this->set('in', $in); + $this->set('value', $value); return $this; } /** - * @return string + * @return mixed */ - public function getIn() + public function getValue() { - return $this->get('in'); + return $this->get('value'); } /** - * @param string $description + * @param string $externalValue * @return $this + * @throws \Exception */ - public function setDescription($description) + public function setExternalValue($externalValue) { - $this->set('description', $description); + $this->set('externalValue', $externalValue); return $this; } /** * @return string */ - public function getDescription() + public function getExternalValue() { - return $this->get('description'); + return $this->get('externalValue'); } } \ No newline at end of file diff --git a/src/Definitions/ExamplesOrReferences.php b/src/Definitions/ExamplesOrReferences.php new file mode 100644 index 0000000..5a74f0b --- /dev/null +++ b/src/Definitions/ExamplesOrReferences.php @@ -0,0 +1,39 @@ + [], 'url' => []]; + protected static $properties = ['description' => ['string'], 'url' => ['string']]; /** * Allowed additional properties @@ -37,11 +37,12 @@ class ExternalDocs extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** * @param string $description * @return $this + * @throws \Exception */ public function setDescription($description) { @@ -60,6 +61,7 @@ public function getDescription() /** * @param string $url * @return $this + * @throws \Exception */ public function setUrl($url) { diff --git a/src/Definitions/FileSchema.php b/src/Definitions/FileSchema.php deleted file mode 100644 index 120d3b4..0000000 --- a/src/Definitions/FileSchema.php +++ /dev/null @@ -1,206 +0,0 @@ - 'file']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['type' => ['file']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['format' => [], 'title' => [], 'description' => [], 'default' => [], 'required' => [], 'type' => [], 'readOnly' => [], 'externalDocs' => ['Definitions\\ExternalDocs'], 'example' => []]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * @param string $format - * @return $this - */ - public function setFormat($format) - { - $this->set('format', $format); - return $this; - } - - /** - * @return string - */ - public function getFormat() - { - return $this->get('format'); - } - - /** - * @param string $title - * @return $this - */ - public function setTitle($title) - { - $this->set('title', $title); - return $this; - } - - /** - * @return string - */ - public function getTitle() - { - return $this->get('title'); - } - - /** - * @param string $description - * @return $this - */ - public function setDescription($description) - { - $this->set('description', $description); - return $this; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->get('description'); - } - - /** - * @param mixed $default - * @return $this - */ - public function setDefault($default) - { - $this->set('default', $default); - return $this; - } - - /** - * @return mixed - */ - public function getDefault() - { - return $this->get('default'); - } - - /** - * @param string $required - * @return $this - */ - public function addRequired($required) - { - $this->add('required', $required); - return $this; - } - - /** - * @return string[] - */ - public function getRequired() - { - return $this->get('required'); - } - - /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param bool $readOnly - * @return $this - */ - public function setReadOnly($readOnly) - { - $this->set('readOnly', $readOnly); - return $this; - } - - /** - * @return bool - */ - public function getReadOnly() - { - return $this->get('readOnly'); - } - - /** - * information about external documentation - * @param ExternalDocs $externalDocs - * @return $this - */ - public function setExternalDocs(ExternalDocs $externalDocs) - { - $this->set('externalDocs', $externalDocs); - return $this; - } - - /** - * information about external documentation - * @return ExternalDocs - */ - public function getExternalDocs() - { - return $this->get('externalDocs'); - } - - /** - * @param mixed $example - * @return $this - */ - public function setExample($example) - { - $this->set('example', $example); - return $this; - } - - /** - * @return mixed - */ - public function getExample() - { - return $this->get('example'); - } - -} \ No newline at end of file diff --git a/src/Definitions/FormDataParameterSubSchema.php b/src/Definitions/FormDataParameterSubSchema.php deleted file mode 100644 index 1f1a57a..0000000 --- a/src/Definitions/FormDataParameterSubSchema.php +++ /dev/null @@ -1,445 +0,0 @@ - 'formData']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['in' => ['formData'], 'type' => ['string', 'number', 'boolean', 'integer', 'array', 'file'], 'collectionFormat' => ['csv', 'ssv', 'tsv', 'pipes', 'multi']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['required' => [], 'in' => [], 'description' => [], 'name' => [], 'allowEmptyValue' => [], 'type' => [], 'format' => [], 'items' => ['Definitions\\PrimitivesItems'], 'collectionFormat' => [], 'default' => [], 'maximum' => [], 'exclusiveMaximum' => [], 'minimum' => [], 'exclusiveMinimum' => [], 'maxLength' => [], 'minLength' => [], 'pattern' => [], 'maxItems' => [], 'minItems' => [], 'uniqueItems' => [], 'enum' => [], 'multipleOf' => []]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * Determines whether or not this parameter is required or optional. - * @param bool $required - * @return $this - */ - public function setRequired($required) - { - $this->set('required', $required); - return $this; - } - - /** - * Determines whether or not this parameter is required or optional. - * @return bool - */ - public function getRequired() - { - return $this->get('required'); - } - - /** - * Determines the location of the parameter. - * @param string $in - * @return $this - */ - public function setIn($in) - { - $this->set('in', $in); - return $this; - } - - /** - * Determines the location of the parameter. - * @return string - */ - public function getIn() - { - return $this->get('in'); - } - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @param string $description - * @return $this - */ - public function setDescription($description) - { - $this->set('description', $description); - return $this; - } - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @return string - */ - public function getDescription() - { - return $this->get('description'); - } - - /** - * The name of the parameter. - * @param string $name - * @return $this - */ - public function setName($name) - { - $this->set('name', $name); - return $this; - } - - /** - * The name of the parameter. - * @return string - */ - public function getName() - { - return $this->get('name'); - } - - /** - * allows sending a parameter by name only or with an empty value. - * @param bool $allowEmptyValue - * @return $this - */ - public function setAllowEmptyValue($allowEmptyValue) - { - $this->set('allowEmptyValue', $allowEmptyValue); - return $this; - } - - /** - * allows sending a parameter by name only or with an empty value. - * @return bool - */ - public function getAllowEmptyValue() - { - return $this->get('allowEmptyValue'); - } - - /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $format - * @return $this - */ - public function setFormat($format) - { - $this->set('format', $format); - return $this; - } - - /** - * @return string - */ - public function getFormat() - { - return $this->get('format'); - } - - /** - * @param PrimitivesItems $items - * @return $this - */ - public function setItems(PrimitivesItems $items) - { - $this->set('items', $items); - return $this; - } - - /** - * @return PrimitivesItems - */ - public function getItems() - { - return $this->get('items'); - } - - /** - * @param string $collectionFormat - * @return $this - */ - public function setCollectionFormat($collectionFormat) - { - $this->set('collectionFormat', $collectionFormat); - return $this; - } - - /** - * @return string - */ - public function getCollectionFormat() - { - return $this->get('collectionFormat'); - } - - /** - * @param mixed $default - * @return $this - */ - public function setDefault($default) - { - $this->set('default', $default); - return $this; - } - - /** - * @return mixed - */ - public function getDefault() - { - return $this->get('default'); - } - - /** - * @param int $maximum - * @return $this - */ - public function setMaximum($maximum) - { - $this->set('maximum', $maximum); - return $this; - } - - /** - * @return int - */ - public function getMaximum() - { - return $this->get('maximum'); - } - - /** - * @param bool $exclusiveMaximum - * @return $this - */ - public function setExclusiveMaximum($exclusiveMaximum) - { - $this->set('exclusiveMaximum', $exclusiveMaximum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMaximum() - { - return $this->get('exclusiveMaximum'); - } - - /** - * @param int $minimum - * @return $this - */ - public function setMinimum($minimum) - { - $this->set('minimum', $minimum); - return $this; - } - - /** - * @return int - */ - public function getMinimum() - { - return $this->get('minimum'); - } - - /** - * @param bool $exclusiveMinimum - * @return $this - */ - public function setExclusiveMinimum($exclusiveMinimum) - { - $this->set('exclusiveMinimum', $exclusiveMinimum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMinimum() - { - return $this->get('exclusiveMinimum'); - } - - /** - * @param int $maxLength - * @return $this - */ - public function setMaxLength($maxLength) - { - $this->set('maxLength', $maxLength); - return $this; - } - - /** - * @return int - */ - public function getMaxLength() - { - return $this->get('maxLength'); - } - - /** - * @param mixed $minLength - * @return $this - */ - public function setMinLength($minLength) - { - $this->set('minLength', $minLength); - return $this; - } - - /** - * @return mixed - */ - public function getMinLength() - { - return $this->get('minLength'); - } - - /** - * @param string $pattern - * @return $this - */ - public function setPattern($pattern) - { - $this->set('pattern', $pattern); - return $this; - } - - /** - * @return string - */ - public function getPattern() - { - return $this->get('pattern'); - } - - /** - * @param int $maxItems - * @return $this - */ - public function setMaxItems($maxItems) - { - $this->set('maxItems', $maxItems); - return $this; - } - - /** - * @return int - */ - public function getMaxItems() - { - return $this->get('maxItems'); - } - - /** - * @param mixed $minItems - * @return $this - */ - public function setMinItems($minItems) - { - $this->set('minItems', $minItems); - return $this; - } - - /** - * @return mixed - */ - public function getMinItems() - { - return $this->get('minItems'); - } - - /** - * @param bool $uniqueItems - * @return $this - */ - public function setUniqueItems($uniqueItems) - { - $this->set('uniqueItems', $uniqueItems); - return $this; - } - - /** - * @return bool - */ - public function getUniqueItems() - { - return $this->get('uniqueItems'); - } - - /** - * @param mixed $enum - * @return $this - */ - public function addEnum($enum) - { - $this->add('enum', $enum); - return $this; - } - - /** - * @return mixed[] - */ - public function getEnum() - { - return $this->get('enum'); - } - - /** - * @param int $multipleOf - * @return $this - */ - public function setMultipleOf($multipleOf) - { - $this->set('multipleOf', $multipleOf); - return $this; - } - - /** - * @return int - */ - public function getMultipleOf() - { - return $this->get('multipleOf'); - } - -} \ No newline at end of file diff --git a/src/Definitions/Header.php b/src/Definitions/Header.php index b6eb6cc..cba7484 100644 --- a/src/Definitions/Header.php +++ b/src/Definitions/Header.php @@ -3,6 +3,9 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; +/** + * The Header Object follows the structure of the Parameter Object with the following changes: 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. 1. `in` MUST NOT be specified, it is implicitly in `header`. 1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, `style`). + */ class Header extends BaseSchema { @@ -16,13 +19,13 @@ class Header extends BaseSchema * Any enums that exist on this object * @var array */ - protected static $enums = ['type' => ['string', 'number', 'integer', 'boolean', 'array'], 'collectionFormat' => ['csv', 'ssv', 'tsv', 'pipes']]; + protected static $enums = []; /** * Properties and types * @var array */ - protected static $properties = ['type' => [], 'format' => [], 'items' => ['Definitions\\PrimitivesItems'], 'collectionFormat' => [], 'default' => [], 'maximum' => [], 'exclusiveMaximum' => [], 'minimum' => [], 'exclusiveMinimum' => [], 'maxLength' => [], 'minLength' => [], 'pattern' => [], 'maxItems' => [], 'minItems' => [], 'uniqueItems' => [], 'enum' => [], 'multipleOf' => [], 'description' => []]; + protected static $properties = ['description' => ['string'], 'required' => ['boolean'], 'deprecated' => ['boolean'], 'allowEmptyValue' => ['boolean'], 'style' => ['string'], 'explode' => ['boolean'], 'allowReserved' => ['boolean'], 'schema' => ['Definitions\\Schema', 'Definitions\\Reference'], 'example' => ['mixed'], 'examples' => ['Definitions\\ExamplesOrReferences'], 'content' => ['Definitions\\MediaTypes']]; /** * Allowed additional properties @@ -34,330 +37,215 @@ class Header extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $format - * @return $this - */ - public function setFormat($format) - { - $this->set('format', $format); - return $this; - } - - /** - * @return string - */ - public function getFormat() - { - return $this->get('format'); - } - - /** - * @param PrimitivesItems $items - * @return $this - */ - public function setItems(PrimitivesItems $items) - { - $this->set('items', $items); - return $this; - } - - /** - * @return PrimitivesItems - */ - public function getItems() - { - return $this->get('items'); - } - - /** - * @param string $collectionFormat + * @param string $description * @return $this + * @throws \Exception */ - public function setCollectionFormat($collectionFormat) + public function setDescription($description) { - $this->set('collectionFormat', $collectionFormat); + $this->set('description', $description); return $this; } /** * @return string */ - public function getCollectionFormat() - { - return $this->get('collectionFormat'); - } - - /** - * @param mixed $default - * @return $this - */ - public function setDefault($default) - { - $this->set('default', $default); - return $this; - } - - /** - * @return mixed - */ - public function getDefault() - { - return $this->get('default'); - } - - /** - * @param int $maximum - * @return $this - */ - public function setMaximum($maximum) - { - $this->set('maximum', $maximum); - return $this; - } - - /** - * @return int - */ - public function getMaximum() - { - return $this->get('maximum'); - } - - /** - * @param bool $exclusiveMaximum - * @return $this - */ - public function setExclusiveMaximum($exclusiveMaximum) - { - $this->set('exclusiveMaximum', $exclusiveMaximum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMaximum() - { - return $this->get('exclusiveMaximum'); - } - - /** - * @param int $minimum - * @return $this - */ - public function setMinimum($minimum) - { - $this->set('minimum', $minimum); - return $this; - } - - /** - * @return int - */ - public function getMinimum() + public function getDescription() { - return $this->get('minimum'); + return $this->get('description'); } /** - * @param bool $exclusiveMinimum + * @param boolean $required * @return $this + * @throws \Exception */ - public function setExclusiveMinimum($exclusiveMinimum) + public function setRequired($required) { - $this->set('exclusiveMinimum', $exclusiveMinimum); + $this->set('required', $required); return $this; } /** - * @return bool + * @return boolean */ - public function getExclusiveMinimum() + public function getRequired() { - return $this->get('exclusiveMinimum'); + return $this->get('required'); } /** - * @param int $maxLength + * @param boolean $deprecated * @return $this + * @throws \Exception */ - public function setMaxLength($maxLength) + public function setDeprecated($deprecated) { - $this->set('maxLength', $maxLength); + $this->set('deprecated', $deprecated); return $this; } /** - * @return int + * @return boolean */ - public function getMaxLength() + public function getDeprecated() { - return $this->get('maxLength'); + return $this->get('deprecated'); } /** - * @param mixed $minLength + * @param boolean $allowEmptyValue * @return $this + * @throws \Exception */ - public function setMinLength($minLength) + public function setAllowEmptyValue($allowEmptyValue) { - $this->set('minLength', $minLength); + $this->set('allowEmptyValue', $allowEmptyValue); return $this; } /** - * @return mixed + * @return boolean */ - public function getMinLength() + public function getAllowEmptyValue() { - return $this->get('minLength'); + return $this->get('allowEmptyValue'); } /** - * @param string $pattern + * @param string $style * @return $this + * @throws \Exception */ - public function setPattern($pattern) + public function setStyle($style) { - $this->set('pattern', $pattern); + $this->set('style', $style); return $this; } /** * @return string */ - public function getPattern() + public function getStyle() { - return $this->get('pattern'); + return $this->get('style'); } /** - * @param int $maxItems + * @param boolean $explode * @return $this + * @throws \Exception */ - public function setMaxItems($maxItems) + public function setExplode($explode) { - $this->set('maxItems', $maxItems); + $this->set('explode', $explode); return $this; } /** - * @return int + * @return boolean */ - public function getMaxItems() + public function getExplode() { - return $this->get('maxItems'); + return $this->get('explode'); } /** - * @param mixed $minItems + * @param boolean $allowReserved * @return $this + * @throws \Exception */ - public function setMinItems($minItems) + public function setAllowReserved($allowReserved) { - $this->set('minItems', $minItems); + $this->set('allowReserved', $allowReserved); return $this; } /** - * @return mixed + * @return boolean */ - public function getMinItems() + public function getAllowReserved() { - return $this->get('minItems'); + return $this->get('allowReserved'); } /** - * @param bool $uniqueItems + * @param Schema|Reference $schema * @return $this + * @throws \Exception */ - public function setUniqueItems($uniqueItems) + public function setSchema($schema) { - $this->set('uniqueItems', $uniqueItems); + $this->set('schema', $schema); return $this; } /** - * @return bool + * @return Schema|Reference */ - public function getUniqueItems() + public function getSchema() { - return $this->get('uniqueItems'); + return $this->get('schema'); } /** - * @param mixed $enum + * @param mixed $example * @return $this + * @throws \Exception */ - public function addEnum($enum) + public function setExample($example) { - $this->add('enum', $enum); + $this->set('example', $example); return $this; } /** - * @return mixed[] + * @return mixed */ - public function getEnum() + public function getExample() { - return $this->get('enum'); + return $this->get('example'); } /** - * @param int $multipleOf + * @param ExamplesOrReferences $examples * @return $this + * @throws \Exception */ - public function setMultipleOf($multipleOf) + public function setExamples(ExamplesOrReferences $examples) { - $this->set('multipleOf', $multipleOf); + $this->set('examples', $examples); return $this; } /** - * @return int + * @return ExamplesOrReferences */ - public function getMultipleOf() + public function getExamples() { - return $this->get('multipleOf'); + return $this->get('examples'); } /** - * @param string $description + * @param MediaTypes $content * @return $this + * @throws \Exception */ - public function setDescription($description) + public function setContent(MediaTypes $content) { - $this->set('description', $description); + $this->set('content', $content); return $this; } /** - * @return string + * @return MediaTypes */ - public function getDescription() + public function getContent() { - return $this->get('description'); + return $this->get('content'); } } \ No newline at end of file diff --git a/src/Definitions/HeaderParameterSubSchema.php b/src/Definitions/HeaderParameterSubSchema.php deleted file mode 100644 index 1d219a0..0000000 --- a/src/Definitions/HeaderParameterSubSchema.php +++ /dev/null @@ -1,425 +0,0 @@ - 'header']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['in' => ['header'], 'type' => ['string', 'number', 'boolean', 'integer', 'array'], 'collectionFormat' => ['csv', 'ssv', 'tsv', 'pipes']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['required' => [], 'in' => [], 'description' => [], 'name' => [], 'type' => [], 'format' => [], 'items' => ['Definitions\\PrimitivesItems'], 'collectionFormat' => [], 'default' => [], 'maximum' => [], 'exclusiveMaximum' => [], 'minimum' => [], 'exclusiveMinimum' => [], 'maxLength' => [], 'minLength' => [], 'pattern' => [], 'maxItems' => [], 'minItems' => [], 'uniqueItems' => [], 'enum' => [], 'multipleOf' => []]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * Determines whether or not this parameter is required or optional. - * @param bool $required - * @return $this - */ - public function setRequired($required) - { - $this->set('required', $required); - return $this; - } - - /** - * Determines whether or not this parameter is required or optional. - * @return bool - */ - public function getRequired() - { - return $this->get('required'); - } - - /** - * Determines the location of the parameter. - * @param string $in - * @return $this - */ - public function setIn($in) - { - $this->set('in', $in); - return $this; - } - - /** - * Determines the location of the parameter. - * @return string - */ - public function getIn() - { - return $this->get('in'); - } - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @param string $description - * @return $this - */ - public function setDescription($description) - { - $this->set('description', $description); - return $this; - } - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @return string - */ - public function getDescription() - { - return $this->get('description'); - } - - /** - * The name of the parameter. - * @param string $name - * @return $this - */ - public function setName($name) - { - $this->set('name', $name); - return $this; - } - - /** - * The name of the parameter. - * @return string - */ - public function getName() - { - return $this->get('name'); - } - - /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $format - * @return $this - */ - public function setFormat($format) - { - $this->set('format', $format); - return $this; - } - - /** - * @return string - */ - public function getFormat() - { - return $this->get('format'); - } - - /** - * @param PrimitivesItems $items - * @return $this - */ - public function setItems(PrimitivesItems $items) - { - $this->set('items', $items); - return $this; - } - - /** - * @return PrimitivesItems - */ - public function getItems() - { - return $this->get('items'); - } - - /** - * @param string $collectionFormat - * @return $this - */ - public function setCollectionFormat($collectionFormat) - { - $this->set('collectionFormat', $collectionFormat); - return $this; - } - - /** - * @return string - */ - public function getCollectionFormat() - { - return $this->get('collectionFormat'); - } - - /** - * @param mixed $default - * @return $this - */ - public function setDefault($default) - { - $this->set('default', $default); - return $this; - } - - /** - * @return mixed - */ - public function getDefault() - { - return $this->get('default'); - } - - /** - * @param int $maximum - * @return $this - */ - public function setMaximum($maximum) - { - $this->set('maximum', $maximum); - return $this; - } - - /** - * @return int - */ - public function getMaximum() - { - return $this->get('maximum'); - } - - /** - * @param bool $exclusiveMaximum - * @return $this - */ - public function setExclusiveMaximum($exclusiveMaximum) - { - $this->set('exclusiveMaximum', $exclusiveMaximum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMaximum() - { - return $this->get('exclusiveMaximum'); - } - - /** - * @param int $minimum - * @return $this - */ - public function setMinimum($minimum) - { - $this->set('minimum', $minimum); - return $this; - } - - /** - * @return int - */ - public function getMinimum() - { - return $this->get('minimum'); - } - - /** - * @param bool $exclusiveMinimum - * @return $this - */ - public function setExclusiveMinimum($exclusiveMinimum) - { - $this->set('exclusiveMinimum', $exclusiveMinimum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMinimum() - { - return $this->get('exclusiveMinimum'); - } - - /** - * @param int $maxLength - * @return $this - */ - public function setMaxLength($maxLength) - { - $this->set('maxLength', $maxLength); - return $this; - } - - /** - * @return int - */ - public function getMaxLength() - { - return $this->get('maxLength'); - } - - /** - * @param mixed $minLength - * @return $this - */ - public function setMinLength($minLength) - { - $this->set('minLength', $minLength); - return $this; - } - - /** - * @return mixed - */ - public function getMinLength() - { - return $this->get('minLength'); - } - - /** - * @param string $pattern - * @return $this - */ - public function setPattern($pattern) - { - $this->set('pattern', $pattern); - return $this; - } - - /** - * @return string - */ - public function getPattern() - { - return $this->get('pattern'); - } - - /** - * @param int $maxItems - * @return $this - */ - public function setMaxItems($maxItems) - { - $this->set('maxItems', $maxItems); - return $this; - } - - /** - * @return int - */ - public function getMaxItems() - { - return $this->get('maxItems'); - } - - /** - * @param mixed $minItems - * @return $this - */ - public function setMinItems($minItems) - { - $this->set('minItems', $minItems); - return $this; - } - - /** - * @return mixed - */ - public function getMinItems() - { - return $this->get('minItems'); - } - - /** - * @param bool $uniqueItems - * @return $this - */ - public function setUniqueItems($uniqueItems) - { - $this->set('uniqueItems', $uniqueItems); - return $this; - } - - /** - * @return bool - */ - public function getUniqueItems() - { - return $this->get('uniqueItems'); - } - - /** - * @param mixed $enum - * @return $this - */ - public function addEnum($enum) - { - $this->add('enum', $enum); - return $this; - } - - /** - * @return mixed[] - */ - public function getEnum() - { - return $this->get('enum'); - } - - /** - * @param int $multipleOf - * @return $this - */ - public function setMultipleOf($multipleOf) - { - $this->set('multipleOf', $multipleOf); - return $this; - } - - /** - * @return int - */ - public function getMultipleOf() - { - return $this->get('multipleOf'); - } - -} \ No newline at end of file diff --git a/src/Definitions/Headers.php b/src/Definitions/HeadersOrReferences.php similarity index 89% rename from src/Definitions/Headers.php rename to src/Definitions/HeadersOrReferences.php index 9fbb65e..873433b 100644 --- a/src/Definitions/Headers.php +++ b/src/Definitions/HeadersOrReferences.php @@ -4,7 +4,7 @@ use Calcinai\Strut\BaseSchema; -class Headers extends BaseSchema +class HeadersOrReferences extends BaseSchema { /** * Array to store schema data and default values @@ -28,7 +28,7 @@ class Headers extends BaseSchema * Allowed additional properties * @var array */ - protected static $additional_properties = ['Definitions\\Header']; + protected static $additional_properties = ['Definitions\\Header', 'Definitions\\Reference']; /** * Array to store any allowed pattern properties diff --git a/src/Definitions/Info.php b/src/Definitions/Info.php index 6dd197f..4d37354 100644 --- a/src/Definitions/Info.php +++ b/src/Definitions/Info.php @@ -4,7 +4,7 @@ use Calcinai\Strut\BaseSchema; /** - * General information about the API. + * The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. */ class Info extends BaseSchema @@ -25,7 +25,7 @@ class Info extends BaseSchema * Properties and types * @var array */ - protected static $properties = ['title' => [], 'version' => [], 'description' => [], 'termsOfService' => [], 'contact' => ['Definitions\\Contact'], 'license' => ['Definitions\\License']]; + protected static $properties = ['title' => ['string'], 'description' => ['string'], 'termsOfService' => ['string'], 'contact' => ['Definitions\\Contact'], 'license' => ['Definitions\\License'], 'version' => ['string']]; /** * Allowed additional properties @@ -37,12 +37,12 @@ class Info extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** - * A unique and precise title of the API. * @param string $title * @return $this + * @throws \Exception */ public function setTitle($title) { @@ -51,7 +51,6 @@ public function setTitle($title) } /** - * A unique and precise title of the API. * @return string */ public function getTitle() @@ -60,29 +59,9 @@ public function getTitle() } /** - * A semantic version number of the API. - * @param string $version - * @return $this - */ - public function setVersion($version) - { - $this->set('version', $version); - return $this; - } - - /** - * A semantic version number of the API. - * @return string - */ - public function getVersion() - { - return $this->get('version'); - } - - /** - * A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed. * @param string $description * @return $this + * @throws \Exception */ public function setDescription($description) { @@ -91,7 +70,6 @@ public function setDescription($description) } /** - * A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed. * @return string */ public function getDescription() @@ -100,9 +78,9 @@ public function getDescription() } /** - * The terms of service for the API. * @param string $termsOfService * @return $this + * @throws \Exception */ public function setTermsOfService($termsOfService) { @@ -111,7 +89,6 @@ public function setTermsOfService($termsOfService) } /** - * The terms of service for the API. * @return string */ public function getTermsOfService() @@ -120,9 +97,10 @@ public function getTermsOfService() } /** - * Contact information for the owners of the API. + * Contact information for the exposed API. * @param Contact $contact * @return $this + * @throws \Exception */ public function setContact(Contact $contact) { @@ -131,7 +109,7 @@ public function setContact(Contact $contact) } /** - * Contact information for the owners of the API. + * Contact information for the exposed API. * @return Contact */ public function getContact() @@ -140,8 +118,10 @@ public function getContact() } /** + * License information for the exposed API. * @param License $license * @return $this + * @throws \Exception */ public function setLicense(License $license) { @@ -150,11 +130,31 @@ public function setLicense(License $license) } /** + * License information for the exposed API. * @return License */ public function getLicense() { return $this->get('license'); } + + /** + * @param string $version + * @return $this + * @throws \Exception + */ + public function setVersion($version) + { + $this->set('version', $version); + return $this; + } + + /** + * @return string + */ + public function getVersion() + { + return $this->get('version'); + } } \ No newline at end of file diff --git a/src/Definitions/License.php b/src/Definitions/License.php index 9b8585b..402b3e6 100644 --- a/src/Definitions/License.php +++ b/src/Definitions/License.php @@ -3,6 +3,9 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; +/** + * License information for the exposed API. + */ class License extends BaseSchema { @@ -22,7 +25,7 @@ class License extends BaseSchema * Properties and types * @var array */ - protected static $properties = ['name' => [], 'url' => []]; + protected static $properties = ['name' => ['string'], 'url' => ['string']]; /** * Allowed additional properties @@ -34,12 +37,12 @@ class License extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** - * The name of the license type. It's encouraged to use an OSI compatible license. * @param string $name * @return $this + * @throws \Exception */ public function setName($name) { @@ -48,7 +51,6 @@ public function setName($name) } /** - * The name of the license type. It's encouraged to use an OSI compatible license. * @return string */ public function getName() @@ -57,9 +59,9 @@ public function getName() } /** - * The URL pointing to the license. * @param string $url * @return $this + * @throws \Exception */ public function setUrl($url) { @@ -68,7 +70,6 @@ public function setUrl($url) } /** - * The URL pointing to the license. * @return string */ public function getUrl() diff --git a/src/Definitions/Link.php b/src/Definitions/Link.php new file mode 100644 index 0000000..cacf129 --- /dev/null +++ b/src/Definitions/Link.php @@ -0,0 +1,158 @@ + ['string'], 'operationId' => ['string'], 'parameters' => ['Definitions\\AnysOrExpressions'], 'requestBody' => ['mixed', 'Definitions\\Expression'], 'description' => ['string'], 'server' => ['Definitions\\Server']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param string $operationRef + * @return $this + * @throws \Exception + */ + public function setOperationRef($operationRef) + { + $this->set('operationRef', $operationRef); + return $this; + } + + /** + * @return string + */ + public function getOperationRef() + { + return $this->get('operationRef'); + } + + /** + * @param string $operationId + * @return $this + * @throws \Exception + */ + public function setOperationId($operationId) + { + $this->set('operationId', $operationId); + return $this; + } + + /** + * @return string + */ + public function getOperationId() + { + return $this->get('operationId'); + } + + /** + * @param AnysOrExpressions $parameters + * @return $this + * @throws \Exception + */ + public function setParameters(AnysOrExpressions $parameters) + { + $this->set('parameters', $parameters); + return $this; + } + + /** + * @return AnysOrExpressions + */ + public function getParameters() + { + return $this->get('parameters'); + } + + /** + * @param mixed|Expression $requestBody + * @return $this + * @throws \Exception + */ + public function setRequestBody($requestBody) + { + $this->set('requestBody', $requestBody); + return $this; + } + + /** + * @return mixed|Expression + */ + public function getRequestBody() + { + return $this->get('requestBody'); + } + + /** + * @param string $description + * @return $this + * @throws \Exception + */ + public function setDescription($description) + { + $this->set('description', $description); + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->get('description'); + } + + /** + * An object representing a Server. + * @param Server $server + * @return $this + * @throws \Exception + */ + public function setServer(Server $server) + { + $this->set('server', $server); + return $this; + } + + /** + * An object representing a Server. + * @return Server + */ + public function getServer() + { + return $this->get('server'); + } + +} \ No newline at end of file diff --git a/src/Definitions/LinksOrReferences.php b/src/Definitions/LinksOrReferences.php new file mode 100644 index 0000000..20960f0 --- /dev/null +++ b/src/Definitions/LinksOrReferences.php @@ -0,0 +1,39 @@ + ['Definitions\\Schema', 'Definitions\\Reference'], 'example' => ['mixed'], 'examples' => ['Definitions\\ExamplesOrReferences'], 'encoding' => ['Definitions\\Encodings']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param Schema|Reference $schema + * @return $this + * @throws \Exception + */ + public function setSchema($schema) + { + $this->set('schema', $schema); + return $this; + } + + /** + * @return Schema|Reference + */ + public function getSchema() + { + return $this->get('schema'); + } + + /** + * @param mixed $example + * @return $this + * @throws \Exception + */ + public function setExample($example) + { + $this->set('example', $example); + return $this; + } + + /** + * @return mixed + */ + public function getExample() + { + return $this->get('example'); + } + + /** + * @param ExamplesOrReferences $examples + * @return $this + * @throws \Exception + */ + public function setExamples(ExamplesOrReferences $examples) + { + $this->set('examples', $examples); + return $this; + } + + /** + * @return ExamplesOrReferences + */ + public function getExamples() + { + return $this->get('examples'); + } + + /** + * @param Encodings $encoding + * @return $this + * @throws \Exception + */ + public function setEncoding(Encodings $encoding) + { + $this->set('encoding', $encoding); + return $this; + } + + /** + * @return Encodings + */ + public function getEncoding() + { + return $this->get('encoding'); + } + +} \ No newline at end of file diff --git a/src/Definitions/MediaTypes.php b/src/Definitions/MediaTypes.php new file mode 100644 index 0000000..66b8a84 --- /dev/null +++ b/src/Definitions/MediaTypes.php @@ -0,0 +1,39 @@ + 'oauth2', 'flow' => 'application']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['type' => ['oauth2'], 'flow' => ['application']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['type' => [], 'flow' => [], 'scopes' => ['Definitions\\Oauth2Scopes'], 'tokenUrl' => [], 'description' => []]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $flow - * @return $this - */ - public function setFlow($flow) - { - $this->set('flow', $flow); - return $this; - } - - /** - * @return string - */ - public function getFlow() - { - return $this->get('flow'); - } - - /** - * @param Oauth2Scopes $scopes - * @return $this - */ - public function setScopes(Oauth2Scopes $scopes) - { - $this->set('scopes', $scopes); - return $this; - } - - /** - * @return Oauth2Scopes - */ - public function getScopes() - { - return $this->get('scopes'); - } - - /** - * @param string $tokenUrl - * @return $this - */ - public function setTokenUrl($tokenUrl) - { - $this->set('tokenUrl', $tokenUrl); - return $this; - } - - /** - * @return string - */ - public function getTokenUrl() - { - return $this->get('tokenUrl'); - } - - /** - * @param string $description - * @return $this - */ - public function setDescription($description) - { - $this->set('description', $description); - return $this; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->get('description'); - } - -} \ No newline at end of file diff --git a/src/Definitions/Oauth2ImplicitSecurity.php b/src/Definitions/Oauth2ImplicitSecurity.php deleted file mode 100644 index 07ad387..0000000 --- a/src/Definitions/Oauth2ImplicitSecurity.php +++ /dev/null @@ -1,129 +0,0 @@ - 'oauth2', 'flow' => 'implicit']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['type' => ['oauth2'], 'flow' => ['implicit']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['type' => [], 'flow' => [], 'scopes' => ['Definitions\\Oauth2Scopes'], 'authorizationUrl' => [], 'description' => []]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $flow - * @return $this - */ - public function setFlow($flow) - { - $this->set('flow', $flow); - return $this; - } - - /** - * @return string - */ - public function getFlow() - { - return $this->get('flow'); - } - - /** - * @param Oauth2Scopes $scopes - * @return $this - */ - public function setScopes(Oauth2Scopes $scopes) - { - $this->set('scopes', $scopes); - return $this; - } - - /** - * @return Oauth2Scopes - */ - public function getScopes() - { - return $this->get('scopes'); - } - - /** - * @param string $authorizationUrl - * @return $this - */ - public function setAuthorizationUrl($authorizationUrl) - { - $this->set('authorizationUrl', $authorizationUrl); - return $this; - } - - /** - * @return string - */ - public function getAuthorizationUrl() - { - return $this->get('authorizationUrl'); - } - - /** - * @param string $description - * @return $this - */ - public function setDescription($description) - { - $this->set('description', $description); - return $this; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->get('description'); - } - -} \ No newline at end of file diff --git a/src/Definitions/Oauth2PasswordSecurity.php b/src/Definitions/Oauth2PasswordSecurity.php deleted file mode 100644 index 3610ec7..0000000 --- a/src/Definitions/Oauth2PasswordSecurity.php +++ /dev/null @@ -1,129 +0,0 @@ - 'oauth2', 'flow' => 'password']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['type' => ['oauth2'], 'flow' => ['password']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['type' => [], 'flow' => [], 'scopes' => ['Definitions\\Oauth2Scopes'], 'tokenUrl' => [], 'description' => []]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $flow - * @return $this - */ - public function setFlow($flow) - { - $this->set('flow', $flow); - return $this; - } - - /** - * @return string - */ - public function getFlow() - { - return $this->get('flow'); - } - - /** - * @param Oauth2Scopes $scopes - * @return $this - */ - public function setScopes(Oauth2Scopes $scopes) - { - $this->set('scopes', $scopes); - return $this; - } - - /** - * @return Oauth2Scopes - */ - public function getScopes() - { - return $this->get('scopes'); - } - - /** - * @param string $tokenUrl - * @return $this - */ - public function setTokenUrl($tokenUrl) - { - $this->set('tokenUrl', $tokenUrl); - return $this; - } - - /** - * @return string - */ - public function getTokenUrl() - { - return $this->get('tokenUrl'); - } - - /** - * @param string $description - * @return $this - */ - public function setDescription($description) - { - $this->set('description', $description); - return $this; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->get('description'); - } - -} \ No newline at end of file diff --git a/src/Definitions/Oauth2AccessCodeSecurity.php b/src/Definitions/OauthFlow.php similarity index 54% rename from src/Definitions/Oauth2AccessCodeSecurity.php rename to src/Definitions/OauthFlow.php index bb91a02..fc2ad6b 100644 --- a/src/Definitions/Oauth2AccessCodeSecurity.php +++ b/src/Definitions/OauthFlow.php @@ -3,26 +3,29 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; +/** + * Configuration details for a supported OAuth Flow + */ -class Oauth2AccessCodeSecurity extends BaseSchema +class OauthFlow extends BaseSchema { /** * Array to store schema data and default values * @var array */ - protected $data = ['type' => 'oauth2', 'flow' => 'accessCode']; + protected $data = []; /** * Any enums that exist on this object * @var array */ - protected static $enums = ['type' => ['oauth2'], 'flow' => ['accessCode']]; + protected static $enums = []; /** * Properties and types * @var array */ - protected static $properties = ['type' => [], 'flow' => [], 'scopes' => ['Definitions\\Oauth2Scopes'], 'authorizationUrl' => [], 'tokenUrl' => [], 'description' => []]; + protected static $properties = ['authorizationUrl' => ['string'], 'tokenUrl' => ['string'], 'refreshUrl' => ['string'], 'scopes' => ['Definitions\\Strings']]; /** * Allowed additional properties @@ -34,114 +37,82 @@ class Oauth2AccessCodeSecurity extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $flow + * @param string $authorizationUrl * @return $this + * @throws \Exception */ - public function setFlow($flow) + public function setAuthorizationUrl($authorizationUrl) { - $this->set('flow', $flow); + $this->set('authorizationUrl', $authorizationUrl); return $this; } /** * @return string */ - public function getFlow() - { - return $this->get('flow'); - } - - /** - * @param Oauth2Scopes $scopes - * @return $this - */ - public function setScopes(Oauth2Scopes $scopes) - { - $this->set('scopes', $scopes); - return $this; - } - - /** - * @return Oauth2Scopes - */ - public function getScopes() + public function getAuthorizationUrl() { - return $this->get('scopes'); + return $this->get('authorizationUrl'); } /** - * @param string $authorizationUrl + * @param string $tokenUrl * @return $this + * @throws \Exception */ - public function setAuthorizationUrl($authorizationUrl) + public function setTokenUrl($tokenUrl) { - $this->set('authorizationUrl', $authorizationUrl); + $this->set('tokenUrl', $tokenUrl); return $this; } /** * @return string */ - public function getAuthorizationUrl() + public function getTokenUrl() { - return $this->get('authorizationUrl'); + return $this->get('tokenUrl'); } /** - * @param string $tokenUrl + * @param string $refreshUrl * @return $this + * @throws \Exception */ - public function setTokenUrl($tokenUrl) + public function setRefreshUrl($refreshUrl) { - $this->set('tokenUrl', $tokenUrl); + $this->set('refreshUrl', $refreshUrl); return $this; } /** * @return string */ - public function getTokenUrl() + public function getRefreshUrl() { - return $this->get('tokenUrl'); + return $this->get('refreshUrl'); } /** - * @param string $description + * @param Strings $scopes * @return $this + * @throws \Exception */ - public function setDescription($description) + public function setScopes(Strings $scopes) { - $this->set('description', $description); + $this->set('scopes', $scopes); return $this; } /** - * @return string + * @return Strings */ - public function getDescription() + public function getScopes() { - return $this->get('description'); + return $this->get('scopes'); } } \ No newline at end of file diff --git a/src/Definitions/OauthFlows.php b/src/Definitions/OauthFlows.php new file mode 100644 index 0000000..fb50584 --- /dev/null +++ b/src/Definitions/OauthFlows.php @@ -0,0 +1,126 @@ + ['Definitions\\OauthFlow'], 'password' => ['Definitions\\OauthFlow'], 'clientCredentials' => ['Definitions\\OauthFlow'], 'authorizationCode' => ['Definitions\\OauthFlow']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * Configuration details for a supported OAuth Flow + * @param OauthFlow $implicit + * @return $this + * @throws \Exception + */ + public function setImplicit(OauthFlow $implicit) + { + $this->set('implicit', $implicit); + return $this; + } + + /** + * Configuration details for a supported OAuth Flow + * @return OauthFlow + */ + public function getImplicit() + { + return $this->get('implicit'); + } + + /** + * Configuration details for a supported OAuth Flow + * @param OauthFlow $password + * @return $this + * @throws \Exception + */ + public function setPassword(OauthFlow $password) + { + $this->set('password', $password); + return $this; + } + + /** + * Configuration details for a supported OAuth Flow + * @return OauthFlow + */ + public function getPassword() + { + return $this->get('password'); + } + + /** + * Configuration details for a supported OAuth Flow + * @param OauthFlow $clientCredentials + * @return $this + * @throws \Exception + */ + public function setClientCredentials(OauthFlow $clientCredentials) + { + $this->set('clientCredentials', $clientCredentials); + return $this; + } + + /** + * Configuration details for a supported OAuth Flow + * @return OauthFlow + */ + public function getClientCredentials() + { + return $this->get('clientCredentials'); + } + + /** + * Configuration details for a supported OAuth Flow + * @param OauthFlow $authorizationCode + * @return $this + * @throws \Exception + */ + public function setAuthorizationCode(OauthFlow $authorizationCode) + { + $this->set('authorizationCode', $authorizationCode); + return $this; + } + + /** + * Configuration details for a supported OAuth Flow + * @return OauthFlow + */ + public function getAuthorizationCode() + { + return $this->get('authorizationCode'); + } + +} \ No newline at end of file diff --git a/src/Definitions/Operation.php b/src/Definitions/Operation.php index 002fc1e..4dc6ff1 100644 --- a/src/Definitions/Operation.php +++ b/src/Definitions/Operation.php @@ -3,6 +3,9 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; +/** + * Describes a single API operation on a path. + */ class Operation extends BaseSchema { @@ -22,7 +25,7 @@ class Operation extends BaseSchema * Properties and types * @var array */ - protected static $properties = ['tags' => [], 'summary' => [], 'description' => [], 'externalDocs' => ['Definitions\\ExternalDocs'], 'operationId' => [], 'produces' => [], 'consumes' => [], 'parameters' => ['Definitions\\BodyParameter', 'Definitions\\HeaderParameterSubSchema', 'Definitions\\FormDataParameterSubSchema', 'Definitions\\QueryParameterSubSchema', 'Definitions\\PathParameterSubSchema', 'Definitions\\JsonReference'], 'responses' => ['Definitions\\Responses'], 'schemes' => [], 'deprecated' => [], 'security' => ['Definitions\\SecurityRequirement']]; + protected static $properties = ['tags' => ['string'], 'summary' => ['string'], 'description' => ['string'], 'externalDocs' => ['Definitions\\ExternalDocs'], 'operationId' => ['string'], 'parameters' => ['Definitions\\Parameter', 'Definitions\\Reference'], 'requestBody' => ['Definitions\\RequestBody', 'Definitions\\Reference'], 'responses' => ['Definitions\\Responses'], 'callbacks' => ['Definitions\\CallbacksOrReferences'], 'deprecated' => ['boolean'], 'security' => ['Definitions\\SecurityRequirement'], 'servers' => ['Definitions\\Server']]; /** * Allowed additional properties @@ -34,11 +37,12 @@ class Operation extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** * @param string $tags * @return $this + * @throws \Exception */ public function addTag($tags) { @@ -55,9 +59,9 @@ public function getTags() } /** - * A brief summary of the operation. * @param string $summary * @return $this + * @throws \Exception */ public function setSummary($summary) { @@ -66,7 +70,6 @@ public function setSummary($summary) } /** - * A brief summary of the operation. * @return string */ public function getSummary() @@ -75,9 +78,9 @@ public function getSummary() } /** - * A longer description of the operation, GitHub Flavored Markdown is allowed. * @param string $description * @return $this + * @throws \Exception */ public function setDescription($description) { @@ -86,7 +89,6 @@ public function setDescription($description) } /** - * A longer description of the operation, GitHub Flavored Markdown is allowed. * @return string */ public function getDescription() @@ -95,9 +97,10 @@ public function getDescription() } /** - * information about external documentation + * Allows referencing an external resource for extended documentation. * @param ExternalDocs $externalDocs * @return $this + * @throws \Exception */ public function setExternalDocs(ExternalDocs $externalDocs) { @@ -106,7 +109,7 @@ public function setExternalDocs(ExternalDocs $externalDocs) } /** - * information about external documentation + * Allows referencing an external resource for extended documentation. * @return ExternalDocs */ public function getExternalDocs() @@ -115,9 +118,9 @@ public function getExternalDocs() } /** - * A unique identifier of the operation. * @param string $operationId * @return $this + * @throws \Exception */ public function setOperationId($operationId) { @@ -126,7 +129,6 @@ public function setOperationId($operationId) } /** - * A unique identifier of the operation. * @return string */ public function getOperationId() @@ -135,69 +137,48 @@ public function getOperationId() } /** - * A list of MIME types the API can produce. - * @param mixed $produces + * @param Parameter|Reference $parameters * @return $this + * @throws \Exception */ - public function setProduces($produces) + public function addParameter($parameters) { - $this->set('produces', $produces); + $this->add('parameters', $parameters); return $this; } /** - * A list of MIME types the API can produce. - * @return mixed + * @return Parameter|Reference[] */ - public function getProduces() + public function getParameters() { - return $this->get('produces'); + return $this->get('parameters'); } /** - * A list of MIME types the API can consume. - * @param mixed $consumes + * @param RequestBody|Reference $requestBody * @return $this + * @throws \Exception */ - public function setConsumes($consumes) + public function setRequestBody($requestBody) { - $this->set('consumes', $consumes); + $this->set('requestBody', $requestBody); return $this; } /** - * A list of MIME types the API can consume. - * @return mixed + * @return RequestBody|Reference */ - public function getConsumes() + public function getRequestBody() { - return $this->get('consumes'); + return $this->get('requestBody'); } /** - * The parameters needed to send a valid API call. - * @param BodyParameter|HeaderParameterSubSchema|FormDataParameterSubSchema|QueryParameterSubSchema|PathParameterSubSchema|JsonReference $parameters - * @return $this - */ - public function addParameter($parameters) - { - $this->add('parameters', $parameters); - return $this; - } - - /** - * The parameters needed to send a valid API call. - * @return BodyParameter|HeaderParameterSubSchema|FormDataParameterSubSchema|QueryParameterSubSchema|PathParameterSubSchema|JsonReference[] - */ - public function getParameters() - { - return $this->get('parameters'); - } - - /** - * Response objects names can either be any valid HTTP status code or 'default'. + * A container for the expected responses of an operation. The container maps a HTTP response code to the expected response. The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors. The `default` MAY be used as a default response object for all HTTP codes that are not covered individually by the specification. The `Responses Object` MUST contain at least one response code, and it SHOULD be the response for a successful operation call. * @param Responses $responses * @return $this + * @throws \Exception */ public function setResponses(Responses $responses) { @@ -206,7 +187,7 @@ public function setResponses(Responses $responses) } /** - * Response objects names can either be any valid HTTP status code or 'default'. + * A container for the expected responses of an operation. The container maps a HTTP response code to the expected response. The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors. The `default` MAY be used as a default response object for all HTTP codes that are not covered individually by the specification. The `Responses Object` MUST contain at least one response code, and it SHOULD be the response for a successful operation call. * @return Responses */ public function getResponses() @@ -215,28 +196,28 @@ public function getResponses() } /** - * The transfer protocol of the API. - * @param string $schemes + * @param CallbacksOrReferences $callbacks * @return $this + * @throws \Exception */ - public function addScheme($schemes) + public function setCallbacks(CallbacksOrReferences $callbacks) { - $this->add('schemes', $schemes); + $this->set('callbacks', $callbacks); return $this; } /** - * The transfer protocol of the API. - * @return string[] + * @return CallbacksOrReferences */ - public function getSchemes() + public function getCallbacks() { - return $this->get('schemes'); + return $this->get('callbacks'); } /** - * @param bool $deprecated + * @param boolean $deprecated * @return $this + * @throws \Exception */ public function setDeprecated($deprecated) { @@ -245,7 +226,7 @@ public function setDeprecated($deprecated) } /** - * @return bool + * @return boolean */ public function getDeprecated() { @@ -255,6 +236,7 @@ public function getDeprecated() /** * @param SecurityRequirement $security * @return $this + * @throws \Exception */ public function addSecurity(SecurityRequirement $security) { @@ -269,5 +251,24 @@ public function getSecurity() { return $this->get('security'); } + + /** + * @param Server $servers + * @return $this + * @throws \Exception + */ + public function addServer(Server $servers) + { + $this->add('servers', $servers); + return $this; + } + + /** + * @return Server[] + */ + public function getServers() + { + return $this->get('servers'); + } } \ No newline at end of file diff --git a/src/Definitions/Parameter.php b/src/Definitions/Parameter.php new file mode 100644 index 0000000..ce2c78b --- /dev/null +++ b/src/Definitions/Parameter.php @@ -0,0 +1,289 @@ + ['string'], 'in' => ['string'], 'description' => ['string'], 'required' => ['boolean'], 'deprecated' => ['boolean'], 'allowEmptyValue' => ['boolean'], 'style' => ['string'], 'explode' => ['boolean'], 'allowReserved' => ['boolean'], 'schema' => ['Definitions\\Schema', 'Definitions\\Reference'], 'example' => ['mixed'], 'examples' => ['Definitions\\ExamplesOrReferences'], 'content' => ['Definitions\\MediaTypes']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param string $name + * @return $this + * @throws \Exception + */ + public function setName($name) + { + $this->set('name', $name); + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->get('name'); + } + + /** + * @param string $in + * @return $this + * @throws \Exception + */ + public function setIn($in) + { + $this->set('in', $in); + return $this; + } + + /** + * @return string + */ + public function getIn() + { + return $this->get('in'); + } + + /** + * @param string $description + * @return $this + * @throws \Exception + */ + public function setDescription($description) + { + $this->set('description', $description); + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->get('description'); + } + + /** + * @param boolean $required + * @return $this + * @throws \Exception + */ + public function setRequired($required) + { + $this->set('required', $required); + return $this; + } + + /** + * @return boolean + */ + public function getRequired() + { + return $this->get('required'); + } + + /** + * @param boolean $deprecated + * @return $this + * @throws \Exception + */ + public function setDeprecated($deprecated) + { + $this->set('deprecated', $deprecated); + return $this; + } + + /** + * @return boolean + */ + public function getDeprecated() + { + return $this->get('deprecated'); + } + + /** + * @param boolean $allowEmptyValue + * @return $this + * @throws \Exception + */ + public function setAllowEmptyValue($allowEmptyValue) + { + $this->set('allowEmptyValue', $allowEmptyValue); + return $this; + } + + /** + * @return boolean + */ + public function getAllowEmptyValue() + { + return $this->get('allowEmptyValue'); + } + + /** + * @param string $style + * @return $this + * @throws \Exception + */ + public function setStyle($style) + { + $this->set('style', $style); + return $this; + } + + /** + * @return string + */ + public function getStyle() + { + return $this->get('style'); + } + + /** + * @param boolean $explode + * @return $this + * @throws \Exception + */ + public function setExplode($explode) + { + $this->set('explode', $explode); + return $this; + } + + /** + * @return boolean + */ + public function getExplode() + { + return $this->get('explode'); + } + + /** + * @param boolean $allowReserved + * @return $this + * @throws \Exception + */ + public function setAllowReserved($allowReserved) + { + $this->set('allowReserved', $allowReserved); + return $this; + } + + /** + * @return boolean + */ + public function getAllowReserved() + { + return $this->get('allowReserved'); + } + + /** + * @param Schema|Reference $schema + * @return $this + * @throws \Exception + */ + public function setSchema($schema) + { + $this->set('schema', $schema); + return $this; + } + + /** + * @return Schema|Reference + */ + public function getSchema() + { + return $this->get('schema'); + } + + /** + * @param mixed $example + * @return $this + * @throws \Exception + */ + public function setExample($example) + { + $this->set('example', $example); + return $this; + } + + /** + * @return mixed + */ + public function getExample() + { + return $this->get('example'); + } + + /** + * @param ExamplesOrReferences $examples + * @return $this + * @throws \Exception + */ + public function setExamples(ExamplesOrReferences $examples) + { + $this->set('examples', $examples); + return $this; + } + + /** + * @return ExamplesOrReferences + */ + public function getExamples() + { + return $this->get('examples'); + } + + /** + * @param MediaTypes $content + * @return $this + * @throws \Exception + */ + public function setContent(MediaTypes $content) + { + $this->set('content', $content); + return $this; + } + + /** + * @return MediaTypes + */ + public function getContent() + { + return $this->get('content'); + } + +} \ No newline at end of file diff --git a/src/Definitions/ParameterDefinitions.php b/src/Definitions/ParameterDefinitions.php deleted file mode 100644 index 4090617..0000000 --- a/src/Definitions/ParameterDefinitions.php +++ /dev/null @@ -1,42 +0,0 @@ - [], 'get' => ['Definitions\\Operation'], 'put' => ['Definitions\\Operation'], 'post' => ['Definitions\\Operation'], 'delete' => ['Definitions\\Operation'], 'options' => ['Definitions\\Operation'], 'head' => ['Definitions\\Operation'], 'patch' => ['Definitions\\Operation'], 'parameters' => ['Definitions\\BodyParameter', 'Definitions\\HeaderParameterSubSchema', 'Definitions\\FormDataParameterSubSchema', 'Definitions\\QueryParameterSubSchema', 'Definitions\\PathParameterSubSchema', 'Definitions\\JsonReference']]; + protected static $properties = ['$ref' => ['string'], 'summary' => ['string'], 'description' => ['string'], 'get' => ['Definitions\\Operation'], 'put' => ['Definitions\\Operation'], 'post' => ['Definitions\\Operation'], 'delete' => ['Definitions\\Operation'], 'options' => ['Definitions\\Operation'], 'head' => ['Definitions\\Operation'], 'patch' => ['Definitions\\Operation'], 'trace' => ['Definitions\\Operation'], 'servers' => ['Definitions\\Server'], 'parameters' => ['Definitions\\Parameter', 'Definitions\\Reference']]; /** * Allowed additional properties @@ -34,11 +37,12 @@ class PathItem extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** * @param string $ref * @return $this + * @throws \Exception */ public function setRef($ref) { @@ -55,8 +59,48 @@ public function getRef() } /** + * @param string $summary + * @return $this + * @throws \Exception + */ + public function setSummary($summary) + { + $this->set('summary', $summary); + return $this; + } + + /** + * @return string + */ + public function getSummary() + { + return $this->get('summary'); + } + + /** + * @param string $description + * @return $this + * @throws \Exception + */ + public function setDescription($description) + { + $this->set('description', $description); + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->get('description'); + } + + /** + * Describes a single API operation on a path. * @param Operation $get * @return $this + * @throws \Exception */ public function setGet(Operation $get) { @@ -65,6 +109,7 @@ public function setGet(Operation $get) } /** + * Describes a single API operation on a path. * @return Operation */ public function getGet() @@ -73,8 +118,10 @@ public function getGet() } /** + * Describes a single API operation on a path. * @param Operation $put * @return $this + * @throws \Exception */ public function setPut(Operation $put) { @@ -83,6 +130,7 @@ public function setPut(Operation $put) } /** + * Describes a single API operation on a path. * @return Operation */ public function getPut() @@ -91,8 +139,10 @@ public function getPut() } /** + * Describes a single API operation on a path. * @param Operation $post * @return $this + * @throws \Exception */ public function setPost(Operation $post) { @@ -101,6 +151,7 @@ public function setPost(Operation $post) } /** + * Describes a single API operation on a path. * @return Operation */ public function getPost() @@ -109,8 +160,10 @@ public function getPost() } /** + * Describes a single API operation on a path. * @param Operation $delete * @return $this + * @throws \Exception */ public function setDelete(Operation $delete) { @@ -119,6 +172,7 @@ public function setDelete(Operation $delete) } /** + * Describes a single API operation on a path. * @return Operation */ public function getDelete() @@ -127,8 +181,10 @@ public function getDelete() } /** + * Describes a single API operation on a path. * @param Operation $options * @return $this + * @throws \Exception */ public function setOptions(Operation $options) { @@ -137,6 +193,7 @@ public function setOptions(Operation $options) } /** + * Describes a single API operation on a path. * @return Operation */ public function getOptions() @@ -145,8 +202,10 @@ public function getOptions() } /** + * Describes a single API operation on a path. * @param Operation $head * @return $this + * @throws \Exception */ public function setHead(Operation $head) { @@ -155,6 +214,7 @@ public function setHead(Operation $head) } /** + * Describes a single API operation on a path. * @return Operation */ public function getHead() @@ -163,8 +223,10 @@ public function getHead() } /** + * Describes a single API operation on a path. * @param Operation $patch * @return $this + * @throws \Exception */ public function setPatch(Operation $patch) { @@ -173,6 +235,7 @@ public function setPatch(Operation $patch) } /** + * Describes a single API operation on a path. * @return Operation */ public function getPatch() @@ -181,9 +244,49 @@ public function getPatch() } /** - * The parameters needed to send a valid API call. - * @param BodyParameter|HeaderParameterSubSchema|FormDataParameterSubSchema|QueryParameterSubSchema|PathParameterSubSchema|JsonReference $parameters + * Describes a single API operation on a path. + * @param Operation $trace + * @return $this + * @throws \Exception + */ + public function setTrace(Operation $trace) + { + $this->set('trace', $trace); + return $this; + } + + /** + * Describes a single API operation on a path. + * @return Operation + */ + public function getTrace() + { + return $this->get('trace'); + } + + /** + * @param Server $servers + * @return $this + * @throws \Exception + */ + public function addServer(Server $servers) + { + $this->add('servers', $servers); + return $this; + } + + /** + * @return Server[] + */ + public function getServers() + { + return $this->get('servers'); + } + + /** + * @param Parameter|Reference $parameters * @return $this + * @throws \Exception */ public function addParameter($parameters) { @@ -192,8 +295,7 @@ public function addParameter($parameters) } /** - * The parameters needed to send a valid API call. - * @return BodyParameter|HeaderParameterSubSchema|FormDataParameterSubSchema|QueryParameterSubSchema|PathParameterSubSchema|JsonReference[] + * @return Parameter|Reference[] */ public function getParameters() { diff --git a/src/Definitions/PathParameterSubSchema.php b/src/Definitions/PathParameterSubSchema.php deleted file mode 100644 index c9cf292..0000000 --- a/src/Definitions/PathParameterSubSchema.php +++ /dev/null @@ -1,425 +0,0 @@ - true, 'in' => 'path']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['required' => [true], 'in' => ['path'], 'type' => ['string', 'number', 'boolean', 'integer', 'array'], 'collectionFormat' => ['csv', 'ssv', 'tsv', 'pipes']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['required' => [], 'in' => [], 'description' => [], 'name' => [], 'type' => [], 'format' => [], 'items' => ['Definitions\\PrimitivesItems'], 'collectionFormat' => [], 'default' => [], 'maximum' => [], 'exclusiveMaximum' => [], 'minimum' => [], 'exclusiveMinimum' => [], 'maxLength' => [], 'minLength' => [], 'pattern' => [], 'maxItems' => [], 'minItems' => [], 'uniqueItems' => [], 'enum' => [], 'multipleOf' => []]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * Determines whether or not this parameter is required or optional. - * @param bool $required - * @return $this - */ - public function setRequired($required) - { - $this->set('required', $required); - return $this; - } - - /** - * Determines whether or not this parameter is required or optional. - * @return bool - */ - public function getRequired() - { - return $this->get('required'); - } - - /** - * Determines the location of the parameter. - * @param string $in - * @return $this - */ - public function setIn($in) - { - $this->set('in', $in); - return $this; - } - - /** - * Determines the location of the parameter. - * @return string - */ - public function getIn() - { - return $this->get('in'); - } - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @param string $description - * @return $this - */ - public function setDescription($description) - { - $this->set('description', $description); - return $this; - } - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @return string - */ - public function getDescription() - { - return $this->get('description'); - } - - /** - * The name of the parameter. - * @param string $name - * @return $this - */ - public function setName($name) - { - $this->set('name', $name); - return $this; - } - - /** - * The name of the parameter. - * @return string - */ - public function getName() - { - return $this->get('name'); - } - - /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $format - * @return $this - */ - public function setFormat($format) - { - $this->set('format', $format); - return $this; - } - - /** - * @return string - */ - public function getFormat() - { - return $this->get('format'); - } - - /** - * @param PrimitivesItems $items - * @return $this - */ - public function setItems(PrimitivesItems $items) - { - $this->set('items', $items); - return $this; - } - - /** - * @return PrimitivesItems - */ - public function getItems() - { - return $this->get('items'); - } - - /** - * @param string $collectionFormat - * @return $this - */ - public function setCollectionFormat($collectionFormat) - { - $this->set('collectionFormat', $collectionFormat); - return $this; - } - - /** - * @return string - */ - public function getCollectionFormat() - { - return $this->get('collectionFormat'); - } - - /** - * @param mixed $default - * @return $this - */ - public function setDefault($default) - { - $this->set('default', $default); - return $this; - } - - /** - * @return mixed - */ - public function getDefault() - { - return $this->get('default'); - } - - /** - * @param int $maximum - * @return $this - */ - public function setMaximum($maximum) - { - $this->set('maximum', $maximum); - return $this; - } - - /** - * @return int - */ - public function getMaximum() - { - return $this->get('maximum'); - } - - /** - * @param bool $exclusiveMaximum - * @return $this - */ - public function setExclusiveMaximum($exclusiveMaximum) - { - $this->set('exclusiveMaximum', $exclusiveMaximum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMaximum() - { - return $this->get('exclusiveMaximum'); - } - - /** - * @param int $minimum - * @return $this - */ - public function setMinimum($minimum) - { - $this->set('minimum', $minimum); - return $this; - } - - /** - * @return int - */ - public function getMinimum() - { - return $this->get('minimum'); - } - - /** - * @param bool $exclusiveMinimum - * @return $this - */ - public function setExclusiveMinimum($exclusiveMinimum) - { - $this->set('exclusiveMinimum', $exclusiveMinimum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMinimum() - { - return $this->get('exclusiveMinimum'); - } - - /** - * @param int $maxLength - * @return $this - */ - public function setMaxLength($maxLength) - { - $this->set('maxLength', $maxLength); - return $this; - } - - /** - * @return int - */ - public function getMaxLength() - { - return $this->get('maxLength'); - } - - /** - * @param mixed $minLength - * @return $this - */ - public function setMinLength($minLength) - { - $this->set('minLength', $minLength); - return $this; - } - - /** - * @return mixed - */ - public function getMinLength() - { - return $this->get('minLength'); - } - - /** - * @param string $pattern - * @return $this - */ - public function setPattern($pattern) - { - $this->set('pattern', $pattern); - return $this; - } - - /** - * @return string - */ - public function getPattern() - { - return $this->get('pattern'); - } - - /** - * @param int $maxItems - * @return $this - */ - public function setMaxItems($maxItems) - { - $this->set('maxItems', $maxItems); - return $this; - } - - /** - * @return int - */ - public function getMaxItems() - { - return $this->get('maxItems'); - } - - /** - * @param mixed $minItems - * @return $this - */ - public function setMinItems($minItems) - { - $this->set('minItems', $minItems); - return $this; - } - - /** - * @return mixed - */ - public function getMinItems() - { - return $this->get('minItems'); - } - - /** - * @param bool $uniqueItems - * @return $this - */ - public function setUniqueItems($uniqueItems) - { - $this->set('uniqueItems', $uniqueItems); - return $this; - } - - /** - * @return bool - */ - public function getUniqueItems() - { - return $this->get('uniqueItems'); - } - - /** - * @param mixed $enum - * @return $this - */ - public function addEnum($enum) - { - $this->add('enum', $enum); - return $this; - } - - /** - * @return mixed[] - */ - public function getEnum() - { - return $this->get('enum'); - } - - /** - * @param int $multipleOf - * @return $this - */ - public function setMultipleOf($multipleOf) - { - $this->set('multipleOf', $multipleOf); - return $this; - } - - /** - * @return int - */ - public function getMultipleOf() - { - return $this->get('multipleOf'); - } - -} \ No newline at end of file diff --git a/src/Definitions/Paths.php b/src/Definitions/Paths.php index c3b19e5..8fe4edb 100644 --- a/src/Definitions/Paths.php +++ b/src/Definitions/Paths.php @@ -4,7 +4,7 @@ use Calcinai\Strut\BaseSchema; /** - * Relative paths to the individual endpoints. They must be relative to the 'basePath'. + * Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the `Server Object` in order to construct the full URL. The Paths MAY be empty, due to ACL constraints. */ class Paths extends BaseSchema @@ -37,6 +37,6 @@ class Paths extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => [], '^/' => ['Definitions\\PathItem']]; + protected static $pattern_properties = ['^/' => ['Definitions\\PathItem'], '^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; } \ No newline at end of file diff --git a/src/Definitions/PrimitivesItems.php b/src/Definitions/PrimitivesItems.php deleted file mode 100644 index 28fb829..0000000 --- a/src/Definitions/PrimitivesItems.php +++ /dev/null @@ -1,345 +0,0 @@ - ['string', 'number', 'integer', 'boolean', 'array'], 'collectionFormat' => ['csv', 'ssv', 'tsv', 'pipes']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['type' => [], 'format' => [], 'items' => ['Definitions\\PrimitivesItems'], 'collectionFormat' => [], 'default' => [], 'maximum' => [], 'exclusiveMaximum' => [], 'minimum' => [], 'exclusiveMinimum' => [], 'maxLength' => [], 'minLength' => [], 'pattern' => [], 'maxItems' => [], 'minItems' => [], 'uniqueItems' => [], 'enum' => [], 'multipleOf' => []]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $format - * @return $this - */ - public function setFormat($format) - { - $this->set('format', $format); - return $this; - } - - /** - * @return string - */ - public function getFormat() - { - return $this->get('format'); - } - - /** - * @param PrimitivesItems $items - * @return $this - */ - public function setItems(PrimitivesItems $items) - { - $this->set('items', $items); - return $this; - } - - /** - * @return PrimitivesItems - */ - public function getItems() - { - return $this->get('items'); - } - - /** - * @param string $collectionFormat - * @return $this - */ - public function setCollectionFormat($collectionFormat) - { - $this->set('collectionFormat', $collectionFormat); - return $this; - } - - /** - * @return string - */ - public function getCollectionFormat() - { - return $this->get('collectionFormat'); - } - - /** - * @param mixed $default - * @return $this - */ - public function setDefault($default) - { - $this->set('default', $default); - return $this; - } - - /** - * @return mixed - */ - public function getDefault() - { - return $this->get('default'); - } - - /** - * @param int $maximum - * @return $this - */ - public function setMaximum($maximum) - { - $this->set('maximum', $maximum); - return $this; - } - - /** - * @return int - */ - public function getMaximum() - { - return $this->get('maximum'); - } - - /** - * @param bool $exclusiveMaximum - * @return $this - */ - public function setExclusiveMaximum($exclusiveMaximum) - { - $this->set('exclusiveMaximum', $exclusiveMaximum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMaximum() - { - return $this->get('exclusiveMaximum'); - } - - /** - * @param int $minimum - * @return $this - */ - public function setMinimum($minimum) - { - $this->set('minimum', $minimum); - return $this; - } - - /** - * @return int - */ - public function getMinimum() - { - return $this->get('minimum'); - } - - /** - * @param bool $exclusiveMinimum - * @return $this - */ - public function setExclusiveMinimum($exclusiveMinimum) - { - $this->set('exclusiveMinimum', $exclusiveMinimum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMinimum() - { - return $this->get('exclusiveMinimum'); - } - - /** - * @param int $maxLength - * @return $this - */ - public function setMaxLength($maxLength) - { - $this->set('maxLength', $maxLength); - return $this; - } - - /** - * @return int - */ - public function getMaxLength() - { - return $this->get('maxLength'); - } - - /** - * @param mixed $minLength - * @return $this - */ - public function setMinLength($minLength) - { - $this->set('minLength', $minLength); - return $this; - } - - /** - * @return mixed - */ - public function getMinLength() - { - return $this->get('minLength'); - } - - /** - * @param string $pattern - * @return $this - */ - public function setPattern($pattern) - { - $this->set('pattern', $pattern); - return $this; - } - - /** - * @return string - */ - public function getPattern() - { - return $this->get('pattern'); - } - - /** - * @param int $maxItems - * @return $this - */ - public function setMaxItems($maxItems) - { - $this->set('maxItems', $maxItems); - return $this; - } - - /** - * @return int - */ - public function getMaxItems() - { - return $this->get('maxItems'); - } - - /** - * @param mixed $minItems - * @return $this - */ - public function setMinItems($minItems) - { - $this->set('minItems', $minItems); - return $this; - } - - /** - * @return mixed - */ - public function getMinItems() - { - return $this->get('minItems'); - } - - /** - * @param bool $uniqueItems - * @return $this - */ - public function setUniqueItems($uniqueItems) - { - $this->set('uniqueItems', $uniqueItems); - return $this; - } - - /** - * @return bool - */ - public function getUniqueItems() - { - return $this->get('uniqueItems'); - } - - /** - * @param mixed $enum - * @return $this - */ - public function addEnum($enum) - { - $this->add('enum', $enum); - return $this; - } - - /** - * @return mixed[] - */ - public function getEnum() - { - return $this->get('enum'); - } - - /** - * @param int $multipleOf - * @return $this - */ - public function setMultipleOf($multipleOf) - { - $this->set('multipleOf', $multipleOf); - return $this; - } - - /** - * @return int - */ - public function getMultipleOf() - { - return $this->get('multipleOf'); - } - -} \ No newline at end of file diff --git a/src/Definitions/QueryParameterSubSchema.php b/src/Definitions/QueryParameterSubSchema.php deleted file mode 100644 index f1df388..0000000 --- a/src/Definitions/QueryParameterSubSchema.php +++ /dev/null @@ -1,445 +0,0 @@ - 'query']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['in' => ['query'], 'type' => ['string', 'number', 'boolean', 'integer', 'array'], 'collectionFormat' => ['csv', 'ssv', 'tsv', 'pipes', 'multi']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['required' => [], 'in' => [], 'description' => [], 'name' => [], 'allowEmptyValue' => [], 'type' => [], 'format' => [], 'items' => ['Definitions\\PrimitivesItems'], 'collectionFormat' => [], 'default' => [], 'maximum' => [], 'exclusiveMaximum' => [], 'minimum' => [], 'exclusiveMinimum' => [], 'maxLength' => [], 'minLength' => [], 'pattern' => [], 'maxItems' => [], 'minItems' => [], 'uniqueItems' => [], 'enum' => [], 'multipleOf' => []]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * Determines whether or not this parameter is required or optional. - * @param bool $required - * @return $this - */ - public function setRequired($required) - { - $this->set('required', $required); - return $this; - } - - /** - * Determines whether or not this parameter is required or optional. - * @return bool - */ - public function getRequired() - { - return $this->get('required'); - } - - /** - * Determines the location of the parameter. - * @param string $in - * @return $this - */ - public function setIn($in) - { - $this->set('in', $in); - return $this; - } - - /** - * Determines the location of the parameter. - * @return string - */ - public function getIn() - { - return $this->get('in'); - } - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @param string $description - * @return $this - */ - public function setDescription($description) - { - $this->set('description', $description); - return $this; - } - - /** - * A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - * @return string - */ - public function getDescription() - { - return $this->get('description'); - } - - /** - * The name of the parameter. - * @param string $name - * @return $this - */ - public function setName($name) - { - $this->set('name', $name); - return $this; - } - - /** - * The name of the parameter. - * @return string - */ - public function getName() - { - return $this->get('name'); - } - - /** - * allows sending a parameter by name only or with an empty value. - * @param bool $allowEmptyValue - * @return $this - */ - public function setAllowEmptyValue($allowEmptyValue) - { - $this->set('allowEmptyValue', $allowEmptyValue); - return $this; - } - - /** - * allows sending a parameter by name only or with an empty value. - * @return bool - */ - public function getAllowEmptyValue() - { - return $this->get('allowEmptyValue'); - } - - /** - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->set('type', $type); - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->get('type'); - } - - /** - * @param string $format - * @return $this - */ - public function setFormat($format) - { - $this->set('format', $format); - return $this; - } - - /** - * @return string - */ - public function getFormat() - { - return $this->get('format'); - } - - /** - * @param PrimitivesItems $items - * @return $this - */ - public function setItems(PrimitivesItems $items) - { - $this->set('items', $items); - return $this; - } - - /** - * @return PrimitivesItems - */ - public function getItems() - { - return $this->get('items'); - } - - /** - * @param string $collectionFormat - * @return $this - */ - public function setCollectionFormat($collectionFormat) - { - $this->set('collectionFormat', $collectionFormat); - return $this; - } - - /** - * @return string - */ - public function getCollectionFormat() - { - return $this->get('collectionFormat'); - } - - /** - * @param mixed $default - * @return $this - */ - public function setDefault($default) - { - $this->set('default', $default); - return $this; - } - - /** - * @return mixed - */ - public function getDefault() - { - return $this->get('default'); - } - - /** - * @param int $maximum - * @return $this - */ - public function setMaximum($maximum) - { - $this->set('maximum', $maximum); - return $this; - } - - /** - * @return int - */ - public function getMaximum() - { - return $this->get('maximum'); - } - - /** - * @param bool $exclusiveMaximum - * @return $this - */ - public function setExclusiveMaximum($exclusiveMaximum) - { - $this->set('exclusiveMaximum', $exclusiveMaximum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMaximum() - { - return $this->get('exclusiveMaximum'); - } - - /** - * @param int $minimum - * @return $this - */ - public function setMinimum($minimum) - { - $this->set('minimum', $minimum); - return $this; - } - - /** - * @return int - */ - public function getMinimum() - { - return $this->get('minimum'); - } - - /** - * @param bool $exclusiveMinimum - * @return $this - */ - public function setExclusiveMinimum($exclusiveMinimum) - { - $this->set('exclusiveMinimum', $exclusiveMinimum); - return $this; - } - - /** - * @return bool - */ - public function getExclusiveMinimum() - { - return $this->get('exclusiveMinimum'); - } - - /** - * @param int $maxLength - * @return $this - */ - public function setMaxLength($maxLength) - { - $this->set('maxLength', $maxLength); - return $this; - } - - /** - * @return int - */ - public function getMaxLength() - { - return $this->get('maxLength'); - } - - /** - * @param mixed $minLength - * @return $this - */ - public function setMinLength($minLength) - { - $this->set('minLength', $minLength); - return $this; - } - - /** - * @return mixed - */ - public function getMinLength() - { - return $this->get('minLength'); - } - - /** - * @param string $pattern - * @return $this - */ - public function setPattern($pattern) - { - $this->set('pattern', $pattern); - return $this; - } - - /** - * @return string - */ - public function getPattern() - { - return $this->get('pattern'); - } - - /** - * @param int $maxItems - * @return $this - */ - public function setMaxItems($maxItems) - { - $this->set('maxItems', $maxItems); - return $this; - } - - /** - * @return int - */ - public function getMaxItems() - { - return $this->get('maxItems'); - } - - /** - * @param mixed $minItems - * @return $this - */ - public function setMinItems($minItems) - { - $this->set('minItems', $minItems); - return $this; - } - - /** - * @return mixed - */ - public function getMinItems() - { - return $this->get('minItems'); - } - - /** - * @param bool $uniqueItems - * @return $this - */ - public function setUniqueItems($uniqueItems) - { - $this->set('uniqueItems', $uniqueItems); - return $this; - } - - /** - * @return bool - */ - public function getUniqueItems() - { - return $this->get('uniqueItems'); - } - - /** - * @param mixed $enum - * @return $this - */ - public function addEnum($enum) - { - $this->add('enum', $enum); - return $this; - } - - /** - * @return mixed[] - */ - public function getEnum() - { - return $this->get('enum'); - } - - /** - * @param int $multipleOf - * @return $this - */ - public function setMultipleOf($multipleOf) - { - $this->set('multipleOf', $multipleOf); - return $this; - } - - /** - * @return int - */ - public function getMultipleOf() - { - return $this->get('multipleOf'); - } - -} \ No newline at end of file diff --git a/src/Definitions/JsonReference.php b/src/Definitions/Reference.php similarity index 65% rename from src/Definitions/JsonReference.php rename to src/Definitions/Reference.php index b5d80c1..9b573fe 100644 --- a/src/Definitions/JsonReference.php +++ b/src/Definitions/Reference.php @@ -3,8 +3,11 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; +/** + * A simple object to allow referencing other components in the specification, internally and externally. The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules. For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification. + */ -class JsonReference extends BaseSchema +class Reference extends BaseSchema { /** * Array to store schema data and default values @@ -22,7 +25,7 @@ class JsonReference extends BaseSchema * Properties and types * @var array */ - protected static $properties = ['$ref' => []]; + protected static $properties = ['$ref' => ['string']]; /** * Allowed additional properties @@ -39,6 +42,7 @@ class JsonReference extends BaseSchema /** * @param string $ref * @return $this + * @throws \Exception */ public function setRef($ref) { diff --git a/src/Definitions/RequestBodiesOrReferences.php b/src/Definitions/RequestBodiesOrReferences.php new file mode 100644 index 0000000..5761416 --- /dev/null +++ b/src/Definitions/RequestBodiesOrReferences.php @@ -0,0 +1,39 @@ + ['string'], 'content' => ['Definitions\\MediaTypes'], 'required' => ['boolean']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param string $description + * @return $this + * @throws \Exception + */ + public function setDescription($description) + { + $this->set('description', $description); + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->get('description'); + } + + /** + * @param MediaTypes $content + * @return $this + * @throws \Exception + */ + public function setContent(MediaTypes $content) + { + $this->set('content', $content); + return $this; + } + + /** + * @return MediaTypes + */ + public function getContent() + { + return $this->get('content'); + } + + /** + * @param boolean $required + * @return $this + * @throws \Exception + */ + public function setRequired($required) + { + $this->set('required', $required); + return $this; + } + + /** + * @return boolean + */ + public function getRequired() + { + return $this->get('required'); + } + +} \ No newline at end of file diff --git a/src/Definitions/Response.php b/src/Definitions/Response.php index 794d3a4..32d6435 100644 --- a/src/Definitions/Response.php +++ b/src/Definitions/Response.php @@ -3,6 +3,9 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; +/** + * Describes a single response from an API Operation, including design-time, static `links` to operations based on the response. + */ class Response extends BaseSchema { @@ -22,7 +25,7 @@ class Response extends BaseSchema * Properties and types * @var array */ - protected static $properties = ['description' => [], 'schema' => ['Definitions\\Schema', 'Definitions\\FileSchema'], 'headers' => ['Definitions\\Headers'], 'examples' => ['Definitions\\Examples']]; + protected static $properties = ['description' => ['string'], 'headers' => ['Definitions\\HeadersOrReferences'], 'content' => ['Definitions\\MediaTypes'], 'links' => ['Definitions\\LinksOrReferences']]; /** * Allowed additional properties @@ -34,11 +37,12 @@ class Response extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** * @param string $description * @return $this + * @throws \Exception */ public function setDescription($description) { @@ -55,57 +59,60 @@ public function getDescription() } /** - * @param Schema|FileSchema $schema + * @param HeadersOrReferences $headers * @return $this + * @throws \Exception */ - public function setSchema($schema) + public function setHeaders(HeadersOrReferences $headers) { - $this->set('schema', $schema); + $this->set('headers', $headers); return $this; } /** - * @return Schema|FileSchema + * @return HeadersOrReferences */ - public function getSchema() + public function getHeaders() { - return $this->get('schema'); + return $this->get('headers'); } /** - * @param Headers $headers + * @param MediaTypes $content * @return $this + * @throws \Exception */ - public function setHeaders(Headers $headers) + public function setContent(MediaTypes $content) { - $this->set('headers', $headers); + $this->set('content', $content); return $this; } /** - * @return Headers + * @return MediaTypes */ - public function getHeaders() + public function getContent() { - return $this->get('headers'); + return $this->get('content'); } /** - * @param Examples $examples + * @param LinksOrReferences $links * @return $this + * @throws \Exception */ - public function setExamples(Examples $examples) + public function setLinks(LinksOrReferences $links) { - $this->set('examples', $examples); + $this->set('links', $links); return $this; } /** - * @return Examples + * @return LinksOrReferences */ - public function getExamples() + public function getLinks() { - return $this->get('examples'); + return $this->get('links'); } } \ No newline at end of file diff --git a/src/Definitions/Responses.php b/src/Definitions/Responses.php index 7d82eb5..b8d6de5 100644 --- a/src/Definitions/Responses.php +++ b/src/Definitions/Responses.php @@ -4,7 +4,7 @@ use Calcinai\Strut\BaseSchema; /** - * Response objects names can either be any valid HTTP status code or 'default'. + * A container for the expected responses of an operation. The container maps a HTTP response code to the expected response. The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors. The `default` MAY be used as a default response object for all HTTP codes that are not covered individually by the specification. The `Responses Object` MUST contain at least one response code, and it SHOULD be the response for a successful operation call. */ class Responses extends BaseSchema @@ -25,7 +25,7 @@ class Responses extends BaseSchema * Properties and types * @var array */ - protected static $properties = []; + protected static $properties = ['default' => ['Definitions\\Response', 'Definitions\\Reference']]; /** * Allowed additional properties @@ -37,6 +37,25 @@ class Responses extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^([0-9]{3})$|^(default)$' => ['Definitions\\Response', 'Definitions\\JsonReference'], '^x-' => []]; + protected static $pattern_properties = ['^([0-9X]{3})$' => ['Definitions\\Response', 'Definitions\\Reference'], '^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param Response|Reference $default + * @return $this + * @throws \Exception + */ + public function setDefault($default) + { + $this->set('default', $default); + return $this; + } + + /** + * @return Response|Reference + */ + public function getDefault() + { + return $this->get('default'); + } } \ No newline at end of file diff --git a/src/Definitions/ResponseDefinitions.php b/src/Definitions/ResponsesOrReferences.php similarity index 86% rename from src/Definitions/ResponseDefinitions.php rename to src/Definitions/ResponsesOrReferences.php index 1763c15..b7ef315 100644 --- a/src/Definitions/ResponseDefinitions.php +++ b/src/Definitions/ResponsesOrReferences.php @@ -3,11 +3,8 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; -/** - * One or more JSON representations for parameters - */ -class ResponseDefinitions extends BaseSchema +class ResponsesOrReferences extends BaseSchema { /** * Array to store schema data and default values @@ -31,7 +28,7 @@ class ResponseDefinitions extends BaseSchema * Allowed additional properties * @var array */ - protected static $additional_properties = ['Definitions\\Response']; + protected static $additional_properties = ['Definitions\\Response', 'Definitions\\Reference']; /** * Array to store any allowed pattern properties diff --git a/src/Definitions/Schema.php b/src/Definitions/Schema.php index 71b4e7d..b3b53ca 100644 --- a/src/Definitions/Schema.php +++ b/src/Definitions/Schema.php @@ -5,7 +5,7 @@ use Calcinai\Strut\BaseSchema; use Calcinai\Strut\Definitions\Schema\Properties\Properties; /** - * A deterministic version of a JSON Schema object. + * The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00. For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema. */ class Schema extends BaseSchema @@ -26,7 +26,7 @@ class Schema extends BaseSchema * Properties and types * @var array */ - protected static $properties = ['$ref' => [], 'format' => [], 'title' => [], 'description' => [], 'default' => [], 'multipleOf' => [], 'maximum' => [], 'exclusiveMaximum' => [], 'minimum' => [], 'exclusiveMinimum' => [], 'maxLength' => [], 'minLength' => [], 'pattern' => [], 'maxItems' => [], 'minItems' => [], 'uniqueItems' => [], 'maxProperties' => [], 'minProperties' => [], 'required' => [], 'enum' => [], 'additionalProperties' => ['Definitions\\Schema'], 'type' => [], 'items' => ['Definitions\\Schema'], 'allOf' => ['Definitions\\Schema'], 'properties' => ['Definitions\\Schema\\Properties\\Properties'], 'discriminator' => [], 'readOnly' => [], 'xml' => ['Definitions\\Xml'], 'externalDocs' => ['Definitions\\ExternalDocs'], 'example' => []]; + protected static $properties = ['nullable' => ['boolean'], 'discriminator' => ['Definitions\\Discriminator'], 'readOnly' => ['boolean'], 'writeOnly' => ['boolean'], 'xml' => ['Definitions\\Xml'], 'externalDocs' => ['Definitions\\ExternalDocs'], 'example' => ['mixed'], 'deprecated' => ['boolean'], 'title' => ['string'], 'multipleOf' => ['integer'], 'maximum' => ['integer'], 'exclusiveMaximum' => ['boolean'], 'minimum' => ['integer'], 'exclusiveMinimum' => ['boolean'], 'maxLength' => ['integer'], 'minLength' => ['mixed'], 'pattern' => ['string'], 'maxItems' => ['integer'], 'minItems' => ['mixed'], 'uniqueItems' => ['boolean'], 'maxProperties' => ['integer'], 'minProperties' => ['mixed'], 'required' => ['string'], 'enum' => ['array'], 'type' => ['string'], 'allOf' => ['Definitions\\Schema', 'Definitions\\Reference'], 'oneOf' => ['Definitions\\Schema', 'Definitions\\Reference'], 'anyOf' => ['Definitions\\Schema', 'Definitions\\Reference'], 'not' => ['Definitions\\Schema'], 'items' => ['Definitions\\Schema', 'Definitions\\Reference'], 'properties' => ['Definitions\\Schema\\Properties\\Properties'], 'additionalProperties' => ['Definitions\\Schema', 'Definitions\\Reference', 'boolean'], 'default' => ['null', 'array', 'object', 'integer', 'boolean', 'string'], 'description' => ['string'], 'format' => ['string']]; /** * Allowed additional properties @@ -38,101 +38,189 @@ class Schema extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** - * @param string $ref + * @param boolean $nullable * @return $this + * @throws \Exception */ - public function setRef($ref) + public function setNullable($nullable) { - $this->set('$ref', $ref); + $this->set('nullable', $nullable); return $this; } /** - * @return string + * @return boolean */ - public function getRef() + public function getNullable() { - return $this->get('$ref'); + return $this->get('nullable'); } /** - * @param string $format + * When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. When using the discriminator, _inline_ schemas will not be considered. + * @param Discriminator $discriminator * @return $this + * @throws \Exception */ - public function setFormat($format) + public function setDiscriminator(Discriminator $discriminator) { - $this->set('format', $format); + $this->set('discriminator', $discriminator); return $this; } /** - * @return string + * When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. When using the discriminator, _inline_ schemas will not be considered. + * @return Discriminator */ - public function getFormat() + public function getDiscriminator() { - return $this->get('format'); + return $this->get('discriminator'); } /** - * @param string $title + * @param boolean $readOnly * @return $this + * @throws \Exception */ - public function setTitle($title) + public function setReadOnly($readOnly) { - $this->set('title', $title); + $this->set('readOnly', $readOnly); return $this; } /** - * @return string + * @return boolean */ - public function getTitle() + public function getReadOnly() { - return $this->get('title'); + return $this->get('readOnly'); } /** - * @param string $description + * @param boolean $writeOnly * @return $this + * @throws \Exception */ - public function setDescription($description) + public function setWriteOnly($writeOnly) { - $this->set('description', $description); + $this->set('writeOnly', $writeOnly); return $this; } /** - * @return string + * @return boolean */ - public function getDescription() + public function getWriteOnly() { - return $this->get('description'); + return $this->get('writeOnly'); } /** - * @param mixed $default + * A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. See examples for expected behavior. + * @param Xml $xml * @return $this + * @throws \Exception */ - public function setDefault($default) + public function setXml(Xml $xml) { - $this->set('default', $default); + $this->set('xml', $xml); + return $this; + } + + /** + * A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. See examples for expected behavior. + * @return Xml + */ + public function getXml() + { + return $this->get('xml'); + } + + /** + * Allows referencing an external resource for extended documentation. + * @param ExternalDocs $externalDocs + * @return $this + * @throws \Exception + */ + public function setExternalDocs(ExternalDocs $externalDocs) + { + $this->set('externalDocs', $externalDocs); + return $this; + } + + /** + * Allows referencing an external resource for extended documentation. + * @return ExternalDocs + */ + public function getExternalDocs() + { + return $this->get('externalDocs'); + } + + /** + * @param mixed $example + * @return $this + * @throws \Exception + */ + public function setExample($example) + { + $this->set('example', $example); return $this; } /** * @return mixed */ - public function getDefault() + public function getExample() { - return $this->get('default'); + return $this->get('example'); + } + + /** + * @param boolean $deprecated + * @return $this + * @throws \Exception + */ + public function setDeprecated($deprecated) + { + $this->set('deprecated', $deprecated); + return $this; } /** - * @param int $multipleOf + * @return boolean + */ + public function getDeprecated() + { + return $this->get('deprecated'); + } + + /** + * @param string $title * @return $this + * @throws \Exception + */ + public function setTitle($title) + { + $this->set('title', $title); + return $this; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->get('title'); + } + + /** + * @param integer $multipleOf + * @return $this + * @throws \Exception */ public function setMultipleOf($multipleOf) { @@ -141,7 +229,7 @@ public function setMultipleOf($multipleOf) } /** - * @return int + * @return integer */ public function getMultipleOf() { @@ -149,8 +237,9 @@ public function getMultipleOf() } /** - * @param int $maximum + * @param integer $maximum * @return $this + * @throws \Exception */ public function setMaximum($maximum) { @@ -159,7 +248,7 @@ public function setMaximum($maximum) } /** - * @return int + * @return integer */ public function getMaximum() { @@ -167,8 +256,9 @@ public function getMaximum() } /** - * @param bool $exclusiveMaximum + * @param boolean $exclusiveMaximum * @return $this + * @throws \Exception */ public function setExclusiveMaximum($exclusiveMaximum) { @@ -177,7 +267,7 @@ public function setExclusiveMaximum($exclusiveMaximum) } /** - * @return bool + * @return boolean */ public function getExclusiveMaximum() { @@ -185,8 +275,9 @@ public function getExclusiveMaximum() } /** - * @param int $minimum + * @param integer $minimum * @return $this + * @throws \Exception */ public function setMinimum($minimum) { @@ -195,7 +286,7 @@ public function setMinimum($minimum) } /** - * @return int + * @return integer */ public function getMinimum() { @@ -203,8 +294,9 @@ public function getMinimum() } /** - * @param bool $exclusiveMinimum + * @param boolean $exclusiveMinimum * @return $this + * @throws \Exception */ public function setExclusiveMinimum($exclusiveMinimum) { @@ -213,7 +305,7 @@ public function setExclusiveMinimum($exclusiveMinimum) } /** - * @return bool + * @return boolean */ public function getExclusiveMinimum() { @@ -221,8 +313,9 @@ public function getExclusiveMinimum() } /** - * @param int $maxLength + * @param integer $maxLength * @return $this + * @throws \Exception */ public function setMaxLength($maxLength) { @@ -231,7 +324,7 @@ public function setMaxLength($maxLength) } /** - * @return int + * @return integer */ public function getMaxLength() { @@ -241,6 +334,7 @@ public function getMaxLength() /** * @param mixed $minLength * @return $this + * @throws \Exception */ public function setMinLength($minLength) { @@ -259,6 +353,7 @@ public function getMinLength() /** * @param string $pattern * @return $this + * @throws \Exception */ public function setPattern($pattern) { @@ -275,8 +370,9 @@ public function getPattern() } /** - * @param int $maxItems + * @param integer $maxItems * @return $this + * @throws \Exception */ public function setMaxItems($maxItems) { @@ -285,7 +381,7 @@ public function setMaxItems($maxItems) } /** - * @return int + * @return integer */ public function getMaxItems() { @@ -295,6 +391,7 @@ public function getMaxItems() /** * @param mixed $minItems * @return $this + * @throws \Exception */ public function setMinItems($minItems) { @@ -311,8 +408,9 @@ public function getMinItems() } /** - * @param bool $uniqueItems + * @param boolean $uniqueItems * @return $this + * @throws \Exception */ public function setUniqueItems($uniqueItems) { @@ -321,7 +419,7 @@ public function setUniqueItems($uniqueItems) } /** - * @return bool + * @return boolean */ public function getUniqueItems() { @@ -329,8 +427,9 @@ public function getUniqueItems() } /** - * @param int $maxProperties + * @param integer $maxProperties * @return $this + * @throws \Exception */ public function setMaxProperties($maxProperties) { @@ -339,7 +438,7 @@ public function setMaxProperties($maxProperties) } /** - * @return int + * @return integer */ public function getMaxProperties() { @@ -349,6 +448,7 @@ public function getMaxProperties() /** * @param mixed $minProperties * @return $this + * @throws \Exception */ public function setMinProperties($minProperties) { @@ -367,6 +467,7 @@ public function getMinProperties() /** * @param string $required * @return $this + * @throws \Exception */ public function addRequired($required) { @@ -383,8 +484,9 @@ public function getRequired() } /** - * @param mixed $enum + * @param array $enum * @return $this + * @throws \Exception */ public function addEnum($enum) { @@ -393,7 +495,7 @@ public function addEnum($enum) } /** - * @return mixed[] + * @return array[] */ public function getEnum() { @@ -401,185 +503,214 @@ public function getEnum() } /** - * @param Schema|bool $additionalProperties + * @param string $type * @return $this + * @throws \Exception */ - public function setAdditionalProperties($additionalProperties) + public function setType($type) { - $this->set('additionalProperties', $additionalProperties); + $this->set('type', $type); return $this; } /** - * @return Schema|bool + * @return string */ - public function getAdditionalProperties() + public function getType() { - return $this->get('additionalProperties'); + return $this->get('type'); } /** - * @param mixed $type + * @param Schema|Reference $allOf * @return $this + * @throws \Exception */ - public function setType($type) + public function addAllOf($allOf) { - $this->set('type', $type); + $this->add('allOf', $allOf); return $this; } /** - * @return mixed + * @return Schema|Reference[] */ - public function getType() + public function getAllOf() { - return $this->get('type'); + return $this->get('allOf'); } /** - * @param Schema $items + * @param Schema|Reference $oneOf * @return $this + * @throws \Exception */ - public function setItems(Schema $items) + public function addOneOf($oneOf) { - $this->set('items', $items); + $this->add('oneOf', $oneOf); return $this; } /** - * @return Schema + * @return Schema|Reference[] */ - public function getItems() + public function getOneOf() { - return $this->get('items'); + return $this->get('oneOf'); } /** - * @param Schema $allOf + * @param Schema|Reference $anyOf * @return $this + * @throws \Exception */ - public function addAllOf(Schema $allOf) + public function addAnyOf($anyOf) { - $this->add('allOf', $allOf); + $this->add('anyOf', $anyOf); return $this; } /** - * @return Schema[] + * @return Schema|Reference[] */ - public function getAllOf() + public function getAnyOf() { - return $this->get('allOf'); + return $this->get('anyOf'); } /** - * @param Properties $properties + * The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00. For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema. + * @param Schema $not * @return $this + * @throws \Exception */ - public function setProperties(Properties $properties) + public function setNot(Schema $not) { - $this->set('properties', $properties); + $this->set('not', $not); return $this; } /** - * @return Properties + * The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00. For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema. + * @return Schema */ - public function getProperties() + public function getNot() { - return $this->get('properties'); + return $this->get('not'); } /** - * @param string $discriminator + * @param Schema|Reference $items * @return $this + * @throws \Exception */ - public function setDiscriminator($discriminator) + public function setItems($items) { - $this->set('discriminator', $discriminator); + $this->set('items', $items); return $this; } /** - * @return string + * @return Schema|Reference */ - public function getDiscriminator() + public function getItems() { - return $this->get('discriminator'); + return $this->get('items'); } /** - * @param bool $readOnly + * @param Properties $properties * @return $this + * @throws \Exception */ - public function setReadOnly($readOnly) + public function setProperties(Properties $properties) { - $this->set('readOnly', $readOnly); + $this->set('properties', $properties); return $this; } /** - * @return bool + * @return Properties */ - public function getReadOnly() + public function getProperties() { - return $this->get('readOnly'); + return $this->get('properties'); } /** - * @param Xml $xml + * @param Schema|Reference|boolean $additionalProperties * @return $this + * @throws \Exception */ - public function setXml(Xml $xml) + public function setAdditionalProperties($additionalProperties) { - $this->set('xml', $xml); + $this->set('additionalProperties', $additionalProperties); return $this; } /** - * @return Xml + * @return Schema|Reference|boolean */ - public function getXml() + public function getAdditionalProperties() { - return $this->get('xml'); + return $this->get('additionalProperties'); } /** - * information about external documentation - * @param ExternalDocs $externalDocs + * @param null|array|object|integer|boolean|string $default * @return $this + * @throws \Exception */ - public function setExternalDocs(ExternalDocs $externalDocs) + public function setDefault($default) { - $this->set('externalDocs', $externalDocs); + $this->set('default', $default); return $this; } /** - * information about external documentation - * @return ExternalDocs + * @return null|array|object|integer|boolean|string */ - public function getExternalDocs() + public function getDefault() { - return $this->get('externalDocs'); + return $this->get('default'); } /** - * @param mixed $example + * @param string $description * @return $this + * @throws \Exception */ - public function setExample($example) + public function setDescription($description) { - $this->set('example', $example); + $this->set('description', $description); return $this; } /** - * @return mixed + * @return string */ - public function getExample() + public function getDescription() { - return $this->get('example'); + return $this->get('description'); + } + + /** + * @param string $format + * @return $this + * @throws \Exception + */ + public function setFormat($format) + { + $this->set('format', $format); + return $this; + } + + /** + * @return string + */ + public function getFormat() + { + return $this->get('format'); } } \ No newline at end of file diff --git a/src/Definitions/Schema/Properties/Properties.php b/src/Definitions/Schema/Properties/Properties.php index f476c7d..8783ceb 100644 --- a/src/Definitions/Schema/Properties/Properties.php +++ b/src/Definitions/Schema/Properties/Properties.php @@ -28,7 +28,7 @@ class Properties extends BaseSchema * Allowed additional properties * @var array */ - protected static $additional_properties = ['Definitions\\Schema']; + protected static $additional_properties = ['Definitions\\Schema', 'Definitions\\Reference']; /** * Array to store any allowed pattern properties diff --git a/src/Definitions/Definitions.php b/src/Definitions/SchemasOrReferences.php similarity index 82% rename from src/Definitions/Definitions.php rename to src/Definitions/SchemasOrReferences.php index 567a21a..dc47448 100644 --- a/src/Definitions/Definitions.php +++ b/src/Definitions/SchemasOrReferences.php @@ -3,11 +3,8 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; -/** - * One or more JSON objects describing the schemas being consumed and produced by the API. - */ -class Definitions extends BaseSchema +class SchemasOrReferences extends BaseSchema { /** * Array to store schema data and default values @@ -31,7 +28,7 @@ class Definitions extends BaseSchema * Allowed additional properties * @var array */ - protected static $additional_properties = ['Definitions\\Schema']; + protected static $additional_properties = ['Definitions\\Schema', 'Definitions\\Reference']; /** * Array to store any allowed pattern properties diff --git a/src/Definitions/SecurityDefinitions.php b/src/Definitions/SecurityDefinitions.php deleted file mode 100644 index 70f9a02..0000000 --- a/src/Definitions/SecurityDefinitions.php +++ /dev/null @@ -1,39 +0,0 @@ - ['string']]; } \ No newline at end of file diff --git a/src/Definitions/SecurityScheme.php b/src/Definitions/SecurityScheme.php new file mode 100644 index 0000000..e3f711a --- /dev/null +++ b/src/Definitions/SecurityScheme.php @@ -0,0 +1,196 @@ + ['string'], 'description' => ['string'], 'name' => ['string'], 'in' => ['string'], 'scheme' => ['string'], 'bearerFormat' => ['string'], 'flows' => ['Definitions\\OauthFlows'], 'openIdConnectUrl' => ['string']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param string $type + * @return $this + * @throws \Exception + */ + public function setType($type) + { + $this->set('type', $type); + return $this; + } + + /** + * @return string + */ + public function getType() + { + return $this->get('type'); + } + + /** + * @param string $description + * @return $this + * @throws \Exception + */ + public function setDescription($description) + { + $this->set('description', $description); + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->get('description'); + } + + /** + * @param string $name + * @return $this + * @throws \Exception + */ + public function setName($name) + { + $this->set('name', $name); + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->get('name'); + } + + /** + * @param string $in + * @return $this + * @throws \Exception + */ + public function setIn($in) + { + $this->set('in', $in); + return $this; + } + + /** + * @return string + */ + public function getIn() + { + return $this->get('in'); + } + + /** + * @param string $scheme + * @return $this + * @throws \Exception + */ + public function setScheme($scheme) + { + $this->set('scheme', $scheme); + return $this; + } + + /** + * @return string + */ + public function getScheme() + { + return $this->get('scheme'); + } + + /** + * @param string $bearerFormat + * @return $this + * @throws \Exception + */ + public function setBearerFormat($bearerFormat) + { + $this->set('bearerFormat', $bearerFormat); + return $this; + } + + /** + * @return string + */ + public function getBearerFormat() + { + return $this->get('bearerFormat'); + } + + /** + * Allows configuration of the supported OAuth Flows. + * @param OauthFlows $flows + * @return $this + * @throws \Exception + */ + public function setFlows(OauthFlows $flows) + { + $this->set('flows', $flows); + return $this; + } + + /** + * Allows configuration of the supported OAuth Flows. + * @return OauthFlows + */ + public function getFlows() + { + return $this->get('flows'); + } + + /** + * @param string $openIdConnectUrl + * @return $this + * @throws \Exception + */ + public function setOpenIdConnectUrl($openIdConnectUrl) + { + $this->set('openIdConnectUrl', $openIdConnectUrl); + return $this; + } + + /** + * @return string + */ + public function getOpenIdConnectUrl() + { + return $this->get('openIdConnectUrl'); + } + +} \ No newline at end of file diff --git a/src/Definitions/SecuritySchemesOrReferences.php b/src/Definitions/SecuritySchemesOrReferences.php new file mode 100644 index 0000000..b91262e --- /dev/null +++ b/src/Definitions/SecuritySchemesOrReferences.php @@ -0,0 +1,39 @@ + ['string'], 'description' => ['string'], 'variables' => ['Definitions\\ServerVariables']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param string $url + * @return $this + * @throws \Exception + */ + public function setUrl($url) + { + $this->set('url', $url); + return $this; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->get('url'); + } + + /** + * @param string $description + * @return $this + * @throws \Exception + */ + public function setDescription($description) + { + $this->set('description', $description); + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->get('description'); + } + + /** + * @param ServerVariables $variables + * @return $this + * @throws \Exception + */ + public function setVariables(ServerVariables $variables) + { + $this->set('variables', $variables); + return $this; + } + + /** + * @return ServerVariables + */ + public function getVariables() + { + return $this->get('variables'); + } + +} \ No newline at end of file diff --git a/src/Definitions/BasicAuthenticationSecurity.php b/src/Definitions/ServerVariable.php similarity index 50% rename from src/Definitions/BasicAuthenticationSecurity.php rename to src/Definitions/ServerVariable.php index 2c3a11f..36b68e8 100644 --- a/src/Definitions/BasicAuthenticationSecurity.php +++ b/src/Definitions/ServerVariable.php @@ -3,26 +3,29 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; +/** + * An object representing a Server Variable for server URL template substitution. + */ -class BasicAuthenticationSecurity extends BaseSchema +class ServerVariable extends BaseSchema { /** * Array to store schema data and default values * @var array */ - protected $data = ['type' => 'basic']; + protected $data = []; /** * Any enums that exist on this object * @var array */ - protected static $enums = ['type' => ['basic']]; + protected static $enums = []; /** * Properties and types * @var array */ - protected static $properties = ['type' => [], 'description' => []]; + protected static $properties = ['enum' => ['string'], 'default' => ['string'], 'description' => ['string']]; /** * Allowed additional properties @@ -34,29 +37,50 @@ class BasicAuthenticationSecurity extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** - * @param string $type + * @param string $enum * @return $this + * @throws \Exception */ - public function setType($type) + public function addEnum($enum) { - $this->set('type', $type); + $this->add('enum', $enum); + return $this; + } + + /** + * @return string[] + */ + public function getEnum() + { + return $this->get('enum'); + } + + /** + * @param string $default + * @return $this + * @throws \Exception + */ + public function setDefault($default) + { + $this->set('default', $default); return $this; } /** * @return string */ - public function getType() + public function getDefault() { - return $this->get('type'); + return $this->get('default'); } /** * @param string $description * @return $this + * @throws \Exception */ public function setDescription($description) { diff --git a/src/Definitions/ServerVariables.php b/src/Definitions/ServerVariables.php new file mode 100644 index 0000000..36093ca --- /dev/null +++ b/src/Definitions/ServerVariables.php @@ -0,0 +1,39 @@ + [], 'description' => [], 'externalDocs' => ['Definitions\\ExternalDocs']]; + protected static $properties = ['name' => ['string'], 'description' => ['string'], 'externalDocs' => ['Definitions\\ExternalDocs']]; /** * Allowed additional properties @@ -34,11 +37,12 @@ class Tag extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** * @param string $name * @return $this + * @throws \Exception */ public function setName($name) { @@ -57,6 +61,7 @@ public function getName() /** * @param string $description * @return $this + * @throws \Exception */ public function setDescription($description) { @@ -73,9 +78,10 @@ public function getDescription() } /** - * information about external documentation + * Allows referencing an external resource for extended documentation. * @param ExternalDocs $externalDocs * @return $this + * @throws \Exception */ public function setExternalDocs(ExternalDocs $externalDocs) { @@ -84,7 +90,7 @@ public function setExternalDocs(ExternalDocs $externalDocs) } /** - * information about external documentation + * Allows referencing an external resource for extended documentation. * @return ExternalDocs */ public function getExternalDocs() diff --git a/src/Definitions/Xml.php b/src/Definitions/Xml.php index a22779a..8607e8d 100644 --- a/src/Definitions/Xml.php +++ b/src/Definitions/Xml.php @@ -3,6 +3,9 @@ namespace Calcinai\Strut\Definitions; use Calcinai\Strut\BaseSchema; +/** + * A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. See examples for expected behavior. + */ class Xml extends BaseSchema { @@ -22,7 +25,7 @@ class Xml extends BaseSchema * Properties and types * @var array */ - protected static $properties = ['name' => [], 'namespace' => [], 'prefix' => [], 'attribute' => [], 'wrapped' => []]; + protected static $properties = ['name' => ['string'], 'namespace' => ['string'], 'prefix' => ['string'], 'attribute' => ['boolean'], 'wrapped' => ['boolean']]; /** * Allowed additional properties @@ -34,11 +37,12 @@ class Xml extends BaseSchema * Array to store any allowed pattern properties * @var array */ - protected static $pattern_properties = ['^x-' => []]; + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; /** * @param string $name * @return $this + * @throws \Exception */ public function setName($name) { @@ -57,6 +61,7 @@ public function getName() /** * @param string $namespace * @return $this + * @throws \Exception */ public function setNamespace($namespace) { @@ -75,6 +80,7 @@ public function getNamespace() /** * @param string $prefix * @return $this + * @throws \Exception */ public function setPrefix($prefix) { @@ -91,8 +97,9 @@ public function getPrefix() } /** - * @param bool $attribute + * @param boolean $attribute * @return $this + * @throws \Exception */ public function setAttribute($attribute) { @@ -101,7 +108,7 @@ public function setAttribute($attribute) } /** - * @return bool + * @return boolean */ public function getAttribute() { @@ -109,8 +116,9 @@ public function getAttribute() } /** - * @param bool $wrapped + * @param boolean $wrapped * @return $this + * @throws \Exception */ public function setWrapped($wrapped) { @@ -119,7 +127,7 @@ public function setWrapped($wrapped) } /** - * @return bool + * @return boolean */ public function getWrapped() { diff --git a/src/OpenAPI.php b/src/OpenAPI.php new file mode 100644 index 0000000..a369bc6 --- /dev/null +++ b/src/OpenAPI.php @@ -0,0 +1,208 @@ + ['string'], 'info' => ['Definitions\\Info'], 'servers' => ['Definitions\\Server'], 'paths' => ['Definitions\\Paths'], 'components' => ['Definitions\\Components'], 'security' => ['Definitions\\SecurityRequirement'], 'tags' => ['Definitions\\Tag'], 'externalDocs' => ['Definitions\\ExternalDocs']]; + + /** + * Allowed additional properties + * @var array + */ + protected static $additional_properties = false; + + /** + * Array to store any allowed pattern properties + * @var array + */ + protected static $pattern_properties = ['^x-' => ['null', 'integer', 'boolean', 'string', 'object', 'array']]; + + /** + * @param string $openapi + * @return $this + * @throws \Exception + */ + public function setOpenapi($openapi) + { + $this->set('openapi', $openapi); + return $this; + } + + /** + * @return string + */ + public function getOpenapi() + { + return $this->get('openapi'); + } + + /** + * The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. + * @param Info $info + * @return $this + * @throws \Exception + */ + public function setInfo(Info $info) + { + $this->set('info', $info); + return $this; + } + + /** + * The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. + * @return Info + */ + public function getInfo() + { + return $this->get('info'); + } + + /** + * @param Server $servers + * @return $this + * @throws \Exception + */ + public function addServer(Server $servers) + { + $this->add('servers', $servers); + return $this; + } + + /** + * @return Server[] + */ + public function getServers() + { + return $this->get('servers'); + } + + /** + * Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the `Server Object` in order to construct the full URL. The Paths MAY be empty, due to ACL constraints. + * @param Paths $paths + * @return $this + * @throws \Exception + */ + public function setPaths(Paths $paths) + { + $this->set('paths', $paths); + return $this; + } + + /** + * Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the `Server Object` in order to construct the full URL. The Paths MAY be empty, due to ACL constraints. + * @return Paths + */ + public function getPaths() + { + return $this->get('paths'); + } + + /** + * Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. + * @param Components $components + * @return $this + * @throws \Exception + */ + public function setComponents(Components $components) + { + $this->set('components', $components); + return $this; + } + + /** + * Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. + * @return Components + */ + public function getComponents() + { + return $this->get('components'); + } + + /** + * @param SecurityRequirement $security + * @return $this + * @throws \Exception + */ + public function addSecurity(SecurityRequirement $security) + { + $this->add('security', $security); + return $this; + } + + /** + * @return SecurityRequirement[] + */ + public function getSecurity() + { + return $this->get('security'); + } + + /** + * @param Tag $tags + * @return $this + * @throws \Exception + */ + public function addTag(Tag $tags) + { + $this->add('tags', $tags); + return $this; + } + + /** + * @return Tag[] + */ + public function getTags() + { + return $this->get('tags'); + } + + /** + * Allows referencing an external resource for extended documentation. + * @param ExternalDocs $externalDocs + * @return $this + * @throws \Exception + */ + public function setExternalDocs(ExternalDocs $externalDocs) + { + $this->set('externalDocs', $externalDocs); + return $this; + } + + /** + * Allows referencing an external resource for extended documentation. + * @return ExternalDocs + */ + public function getExternalDocs() + { + return $this->get('externalDocs'); + } + +} \ No newline at end of file diff --git a/src/Swagger.php b/src/Swagger.php deleted file mode 100644 index 3caa85c..0000000 --- a/src/Swagger.php +++ /dev/null @@ -1,341 +0,0 @@ - '2.0']; - - /** - * Any enums that exist on this object - * @var array - */ - protected static $enums = ['swagger' => ['2.0']]; - - /** - * Properties and types - * @var array - */ - protected static $properties = ['swagger' => [], 'info' => ['Definitions\\Info'], 'host' => [], 'basePath' => [], 'schemes' => [], 'consumes' => [], 'produces' => [], 'paths' => ['Definitions\\Paths'], 'definitions' => ['Definitions\\Definitions'], 'parameters' => ['Definitions\\ParameterDefinitions'], 'responses' => ['Definitions\\ResponseDefinitions'], 'security' => ['Definitions\\SecurityRequirement'], 'securityDefinitions' => ['Definitions\\SecurityDefinitions'], 'tags' => ['Definitions\\Tag'], 'externalDocs' => ['Definitions\\ExternalDocs']]; - - /** - * Allowed additional properties - * @var array - */ - protected static $additional_properties = false; - - /** - * Array to store any allowed pattern properties - * @var array - */ - protected static $pattern_properties = ['^x-' => []]; - - /** - * The Swagger version of this document. - * @param string $swagger - * @return $this - */ - public function setSwagger($swagger) - { - $this->set('swagger', $swagger); - return $this; - } - - /** - * The Swagger version of this document. - * @return string - */ - public function getSwagger() - { - return $this->get('swagger'); - } - - /** - * General information about the API. - * @param Info $info - * @return $this - */ - public function setInfo(Info $info) - { - $this->set('info', $info); - return $this; - } - - /** - * General information about the API. - * @return Info - */ - public function getInfo() - { - return $this->get('info'); - } - - /** - * The host (name or ip) of the API. Example: 'swagger.io' - * @param string $host - * @return $this - */ - public function setHost($host) - { - $this->set('host', $host); - return $this; - } - - /** - * The host (name or ip) of the API. Example: 'swagger.io' - * @return string - */ - public function getHost() - { - return $this->get('host'); - } - - /** - * The base path to the API. Example: '/api'. - * @param string $basePath - * @return $this - */ - public function setBasePath($basePath) - { - $this->set('basePath', $basePath); - return $this; - } - - /** - * The base path to the API. Example: '/api'. - * @return string - */ - public function getBasePath() - { - return $this->get('basePath'); - } - - /** - * The transfer protocol of the API. - * @param string $schemes - * @return $this - */ - public function addScheme($schemes) - { - $this->add('schemes', $schemes); - return $this; - } - - /** - * The transfer protocol of the API. - * @return string[] - */ - public function getSchemes() - { - return $this->get('schemes'); - } - - /** - * A list of MIME types accepted by the API. - * @param mixed $consumes - * @return $this - */ - public function setConsumes($consumes) - { - $this->set('consumes', $consumes); - return $this; - } - - /** - * A list of MIME types accepted by the API. - * @return mixed - */ - public function getConsumes() - { - return $this->get('consumes'); - } - - /** - * A list of MIME types the API can produce. - * @param mixed $produces - * @return $this - */ - public function setProduces($produces) - { - $this->set('produces', $produces); - return $this; - } - - /** - * A list of MIME types the API can produce. - * @return mixed - */ - public function getProduces() - { - return $this->get('produces'); - } - - /** - * Relative paths to the individual endpoints. They must be relative to the 'basePath'. - * @param Paths $paths - * @return $this - */ - public function setPaths(Paths $paths) - { - $this->set('paths', $paths); - return $this; - } - - /** - * Relative paths to the individual endpoints. They must be relative to the 'basePath'. - * @return Paths - */ - public function getPaths() - { - return $this->get('paths'); - } - - /** - * One or more JSON objects describing the schemas being consumed and produced by the API. - * @param Definitions $definitions - * @return $this - */ - public function setDefinitions(Definitions $definitions) - { - $this->set('definitions', $definitions); - return $this; - } - - /** - * One or more JSON objects describing the schemas being consumed and produced by the API. - * @return Definitions - */ - public function getDefinitions() - { - return $this->get('definitions'); - } - - /** - * One or more JSON representations for parameters - * @param ParameterDefinitions $parameters - * @return $this - */ - public function setParameters(ParameterDefinitions $parameters) - { - $this->set('parameters', $parameters); - return $this; - } - - /** - * One or more JSON representations for parameters - * @return ParameterDefinitions - */ - public function getParameters() - { - return $this->get('parameters'); - } - - /** - * One or more JSON representations for parameters - * @param ResponseDefinitions $responses - * @return $this - */ - public function setResponses(ResponseDefinitions $responses) - { - $this->set('responses', $responses); - return $this; - } - - /** - * One or more JSON representations for parameters - * @return ResponseDefinitions - */ - public function getResponses() - { - return $this->get('responses'); - } - - /** - * @param SecurityRequirement $security - * @return $this - */ - public function addSecurity(SecurityRequirement $security) - { - $this->add('security', $security); - return $this; - } - - /** - * @return SecurityRequirement[] - */ - public function getSecurity() - { - return $this->get('security'); - } - - /** - * @param SecurityDefinitions $securityDefinitions - * @return $this - */ - public function setSecurityDefinitions(SecurityDefinitions $securityDefinitions) - { - $this->set('securityDefinitions', $securityDefinitions); - return $this; - } - - /** - * @return SecurityDefinitions - */ - public function getSecurityDefinitions() - { - return $this->get('securityDefinitions'); - } - - /** - * @param Tag $tags - * @return $this - */ - public function addTag(Tag $tags) - { - $this->add('tags', $tags); - return $this; - } - - /** - * @return Tag[] - */ - public function getTags() - { - return $this->get('tags'); - } - - /** - * information about external documentation - * @param ExternalDocs $externalDocs - * @return $this - */ - public function setExternalDocs(ExternalDocs $externalDocs) - { - $this->set('externalDocs', $externalDocs); - return $this; - } - - /** - * information about external documentation - * @return ExternalDocs - */ - public function getExternalDocs() - { - return $this->get('externalDocs'); - } - -} \ No newline at end of file