@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | - spl_autoload_register(function ($classname) { |
|
| 3 | + spl_autoload_register(function($classname) { |
|
| 4 | 4 | $file = __DIR__ . '/../../' . $classname . '.php'; |
| 5 | 5 | if (is_file($file)) { |
| 6 | 6 | include_once $file; |
@@ -2,9 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | require_once __DIR__ . '/autoloader.php'; |
| 4 | 4 | |
| 5 | - $files = array('Example.class.php');
|
|
| 5 | + $files = array('Example.class.php');
|
|
| 6 | 6 | |
| 7 | - $SwaggerGen = new \SwaggerGen\SwaggerGen($_SERVER['HTTP_HOST'], dirname($_SERVER['REQUEST_URI'])); |
|
| 7 | + $SwaggerGen = new \SwaggerGen\SwaggerGen($_SERVER['HTTP_HOST'], dirname($_SERVER['REQUEST_URI'])); |
|
| 8 | 8 | //$SwaggerGen->define('admin');
|
| 9 | 9 | //$SwaggerGen->define('root');
|
| 10 | 10 | |
@@ -35,6 +35,9 @@ |
||
| 35 | 35 | return $this->consumes; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | + /** |
|
| 39 | + * @param string $summary |
|
| 40 | + */ |
|
| 38 | 41 | public function __construct(AbstractObject $parent, $summary = null, Tag $tag = null) |
| 39 | 42 | { |
| 40 | 43 | parent::__construct($parent); |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | $format = strtolower($match[1]); |
| 99 | 99 | if (isset(self::$classTypes[$format])) { |
| 100 | 100 | $type = self::$classTypes[$format]; |
| 101 | - $class = "SwaggerGen\\Swagger\\Type\\{$type}Type"; |
|
| 101 | + $class = "SwaggerGen\\Swagger\\Type\\{$type}type"; |
|
| 102 | 102 | $this->Type = new $class($this, $definition); |
| 103 | 103 | } else { |
| 104 | 104 | throw new \SwaggerGen\Exception("Type format not recognized: '{$format}'"); |
@@ -69,6 +69,10 @@ discard block |
||
| 69 | 69 | $this->parseRange($definition, $match); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | + /** |
|
| 73 | + * @param string $definition |
|
| 74 | + * @param string[] $match |
|
| 75 | + */ |
|
| 72 | 76 | private function parseFormat($definition, $match) |
| 73 | 77 | { |
| 74 | 78 | $type = strtolower($match[1]); |
@@ -86,6 +90,10 @@ discard block |
||
| 86 | 90 | $this->collectionFormat = self::$collectionFormats[$type]; |
| 87 | 91 | } |
| 88 | 92 | |
| 93 | + /** |
|
| 94 | + * @param string $definition |
|
| 95 | + * @param string[] $match |
|
| 96 | + */ |
|
| 89 | 97 | private function parseItems($definition, $match) |
| 90 | 98 | { |
| 91 | 99 | if (!empty($match[2])) { |
@@ -93,6 +101,10 @@ discard block |
||
| 93 | 101 | } |
| 94 | 102 | } |
| 95 | 103 | |
| 104 | + /** |
|
| 105 | + * @param string $definition |
|
| 106 | + * @param string[] $match |
|
| 107 | + */ |
|
| 96 | 108 | private function parseRange($definition, $match) |
| 97 | 109 | { |
| 98 | 110 | if (!empty($match[3])) { |
@@ -41,6 +41,9 @@ discard block |
||
| 41 | 41 | $this->parseDefault($definition, $match); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | + /** |
|
| 45 | + * @param string[] $match |
|
| 46 | + */ |
|
| 44 | 47 | private function parseFormat($definition, $match) |
| 45 | 48 | { |
| 46 | 49 | if (!isset(self::$formats[strtolower($match[1])])) { |
@@ -49,6 +52,9 @@ discard block |
||
| 49 | 52 | $this->format = self::$formats[strtolower($match[1])]; |
| 50 | 53 | } |
| 51 | 54 | |
| 55 | + /** |
|
| 56 | + * @param string[] $match |
|
| 57 | + */ |
|
| 52 | 58 | private function parseRange($definition, $match) |
| 53 | 59 | { |
| 54 | 60 | if (!empty($match[2])) { |
@@ -67,6 +73,9 @@ discard block |
||
| 67 | 73 | } |
| 68 | 74 | } |
| 69 | 75 | |
| 76 | + /** |
|
| 77 | + * @param string[] $match |
|
| 78 | + */ |
|
| 70 | 79 | private function parseDefault($definition, $match) |
| 71 | 80 | { |
| 72 | 81 | $this->default = isset($match[6]) && $match[6] !== '' ? $this->validateDefault($match[6]) : null; |
@@ -81,6 +81,10 @@ |
||
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | + /** |
|
| 85 | + * @param string $definition |
|
| 86 | + * @param string[] $match |
|
| 87 | + */ |
|
| 84 | 88 | private function parseDefault($definition, $match) |
| 85 | 89 | { |
| 86 | 90 | $this->default = isset($match[6]) && $match[6] !== '' ? $this->validateDefault($match[6]) : null; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $match = array(); |
| 47 | 47 | if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT_START . $this->regex . self::REGEX_DEFAULT_END . self::REGEX_END, $definition, $match) !== 1) { |
| 48 | - throw new \SwaggerGen\Exception("Unparseable {$this->format} definition: '{$definition}'"); |
|
| 48 | + throw new \SwaggerGen\Exception("unparseable {$this->format} definition: '{$definition}'"); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if (strtolower($match[1] !== $this->format)) { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $value = parent::validateDefault($value); |
| 62 | 62 | |
| 63 | 63 | if (preg_match('/' . $this->pattern . '/', $value) !== 1) { |
| 64 | - throw new \SwaggerGen\Exception("Invalid {$this->format} default value"); |
|
| 64 | + throw new \SwaggerGen\Exception("invalid {$this->format} default value"); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return $value; |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | if (empty($value)) { |
| 163 | 163 | $type = $this->format ?: ($this->enum ? 'enum' : 'string'); |
| 164 | - throw new \SwaggerGen\Exception("Empty {$type} default"); |
|
| 164 | + throw new \SwaggerGen\Exception("empty {$type} default"); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if (!empty($this->enum) && !in_array($value, $this->enum)) { |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | if ($this->maxLength !== null && mb_strlen($value) > $this->maxLength) { |
| 172 | 172 | $type = $this->format ?: ($this->enum ? 'enum' : 'string'); |
| 173 | - throw new \SwaggerGen\Exception("Default {$type} length beyond maximum: '{$value}'"); |
|
| 173 | + throw new \SwaggerGen\Exception("default {$type} length beyond maximum: '{$value}'"); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | if ($this->minLength !== null && mb_strlen($value) < $this->minLength) { |
| 177 | 177 | $type = $this->format ?: ($this->enum ? 'enum' : 'string'); |
| 178 | - throw new \SwaggerGen\Exception("Default {$type} length beyond minimum: '{$value}'"); |
|
| 178 | + throw new \SwaggerGen\Exception("default {$type} length beyond minimum: '{$value}'"); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | return $value; |