@@ -337,23 +337,23 @@ |
||
| 337 | 337 | . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - public function testObjectPropertiesReadOnly() |
|
| 341 | - { |
|
| 342 | - $object = new \SwaggerGen\SwaggerGen(); |
|
| 343 | - $array = $object->getSwagger(array(' |
|
| 340 | + public function testObjectPropertiesReadOnly() |
|
| 341 | + { |
|
| 342 | + $object = new \SwaggerGen\SwaggerGen(); |
|
| 343 | + $array = $object->getSwagger(array(' |
|
| 344 | 344 | api Test |
| 345 | 345 | endpoint /test |
| 346 | 346 | method GET something |
| 347 | 347 | response 200 object(a!:array(A),b:array(B)) |
| 348 | 348 | ')); |
| 349 | 349 | |
| 350 | - $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
| 351 | - . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something"' |
|
| 352 | - . ',"responses":{"200":{"description":"OK","schema":{"type":"object","required":["b"]' |
|
| 353 | - . ',"properties":{"a":{"type":"array","items":{"$ref":"#\/definitions\/A"}}' |
|
| 354 | - . ',"b":{"type":"array","items":{"$ref":"#\/definitions\/B"}}}}}}}}}' |
|
| 355 | - . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
| 356 | - } |
|
| 350 | + $this->assertSame('{"swagger":2,"info":{"title":"undefined","version":0}' |
|
| 351 | + . ',"paths":{"\/test":{"get":{"tags":["Test"],"summary":"something"' |
|
| 352 | + . ',"responses":{"200":{"description":"OK","schema":{"type":"object","required":["b"]' |
|
| 353 | + . ',"properties":{"a":{"type":"array","items":{"$ref":"#\/definitions\/A"}}' |
|
| 354 | + . ',"b":{"type":"array","items":{"$ref":"#\/definitions\/B"}}}}}}}}}' |
|
| 355 | + . ',"tags":[{"name":"Test"}]}', json_encode($array, JSON_NUMERIC_CHECK)); |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | 358 | public function testDeepObjectProperties() |
| 359 | 359 | { |
@@ -81,20 +81,20 @@ |
||
| 81 | 81 | ), $object->toArray()); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct |
|
| 86 | - */ |
|
| 87 | - public function testConstructReadOnly() |
|
| 88 | - { |
|
| 89 | - $object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string', 'Some words here', true); |
|
| 90 | - $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object); |
|
| 91 | - |
|
| 92 | - $this->assertSame(array( |
|
| 93 | - 'type' => 'string', |
|
| 94 | - 'description' => 'Some words here', |
|
| 95 | - 'readOnly' => true |
|
| 96 | - ), $object->toArray()); |
|
| 97 | - } |
|
| 84 | + /** |
|
| 85 | + * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct |
|
| 86 | + */ |
|
| 87 | + public function testConstructReadOnly() |
|
| 88 | + { |
|
| 89 | + $object = new SwaggerGen\Swagger\Type\Property($this->parent, 'string', 'Some words here', true); |
|
| 90 | + $this->assertInstanceOf('\SwaggerGen\Swagger\Type\Property', $object); |
|
| 91 | + |
|
| 92 | + $this->assertSame(array( |
|
| 93 | + 'type' => 'string', |
|
| 94 | + 'description' => 'Some words here', |
|
| 95 | + 'readOnly' => true |
|
| 96 | + ), $object->toArray()); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * @covers \SwaggerGen\Swagger\Type\PropertyType::__construct |
@@ -29,7 +29,8 @@ |
||
| 29 | 29 | * |
| 30 | 30 | * @rest\api Users Get some useful information on users |
| 31 | 31 | */ |
| 32 | -class Example { |
|
| 32 | +class Example |
|
| 33 | +{ |
|
| 33 | 34 | |
| 34 | 35 | private $data = array(); |
| 35 | 36 | |
@@ -30,10 +30,11 @@ |
||
| 30 | 30 | ); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function provideAllCases() { |
|
| 33 | + public function provideAllCases() |
|
| 34 | + { |
|
| 34 | 35 | $cases = array(); |
| 35 | 36 | |
| 36 | - foreach (glob(__DIR__ . '/*', GLOB_ONLYDIR) as $dir) { |
|
| 37 | + foreach (glob(__DIR__ . '/*', GLOB_ONLYDIR) as $dir) { |
|
| 37 | 38 | $path = realpath($dir); |
| 38 | 39 | $json = $this->normalizeJson(file_get_contents($path . '/expected.json')); |
| 39 | 40 | |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | private $description; |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Whether property is read only |
|
| 53 | - * @var bool |
|
| 54 | - */ |
|
| 51 | + /** |
|
| 52 | + * Whether property is read only |
|
| 53 | + * @var bool |
|
| 54 | + */ |
|
| 55 | 55 | private $readOnly; |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param \SwaggerGen\Swagger\AbstractObject $parent |
| 66 | 66 | * @param string $definition Either a built-in type or a definition name |
| 67 | 67 | * @param string $description description of the property |
| 68 | - * @param bool $readOnly Whether the property is read only |
|
| 68 | + * @param bool $readOnly Whether the property is read only |
|
| 69 | 69 | * @throws \SwaggerGen\Exception |
| 70 | 70 | */ |
| 71 | 71 | public function __construct(\SwaggerGen\Swagger\AbstractObject $parent, $definition, $description = null, $readOnly = null) |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | return self::arrayFilterNull(array_merge($valueType, array( |
| 132 | 132 | 'description' => empty($this->description) ? null : $this->description, |
| 133 | - 'readOnly' => $this->readOnly |
|
| 133 | + 'readOnly' => $this->readOnly |
|
| 134 | 134 | ), parent::toArray())); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | return $this; |
| 143 | 143 | |
| 144 | 144 | case 'model': |
| 145 | - case 'model!': |
|
| 145 | + case 'model!': |
|
| 146 | 146 | case 'definition': |
| 147 | - case 'definition!': |
|
| 147 | + case 'definition!': |
|
| 148 | 148 | $name = self::wordShift($data); |
| 149 | 149 | if (empty($name)) { |
| 150 | 150 | throw new \SwaggerGen\Exception('Missing definition name'); |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | $definition = new Schema($this, $typeDef); |
| 158 | 158 | if(substr($command, -1) === '!') { |
| 159 | - $definition->setReadOnly(); |
|
| 160 | - } |
|
| 159 | + $definition->setReadOnly(); |
|
| 160 | + } |
|
| 161 | 161 | $this->definitions[$name] = $definition; |
| 162 | 162 | return $definition; |
| 163 | 163 | |
@@ -155,7 +155,7 @@ |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $definition = new Schema($this, $typeDef); |
| 158 | - if(substr($command, -1) === '!') { |
|
| 158 | + if (substr($command, -1) === '!') { |
|
| 159 | 159 | $definition->setReadOnly(); |
| 160 | 160 | } |
| 161 | 161 | $this->definitions[$name] = $definition; |
@@ -120,7 +120,7 @@ |
||
| 120 | 120 | // Internal type if type known and not overwritten by definition |
| 121 | 121 | if (isset(self::$classTypes[$format])) { |
| 122 | 122 | $type = self::$classTypes[$format]; |
| 123 | - $class = "SwaggerGen\\Swagger\\Type\\{$type}Type"; |
|
| 123 | + $class = "SwaggerGen\\Swagger\\Type\\{$type}type"; |
|
| 124 | 124 | return new $class($parent, $definition); |
| 125 | 125 | } else { |
| 126 | 126 | return new ReferenceObjectType($parent, $definition); |
@@ -55,6 +55,10 @@ discard block |
||
| 55 | 55 | $this->parseRange($definition, $match); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | + /** |
|
| 59 | + * @param string $definition |
|
| 60 | + * @param string[] $match |
|
| 61 | + */ |
|
| 58 | 62 | private function parseFormat($definition, $match) |
| 59 | 63 | { |
| 60 | 64 | if (strtolower($match[1]) !== 'object') { |
@@ -62,6 +66,10 @@ discard block |
||
| 62 | 66 | } |
| 63 | 67 | } |
| 64 | 68 | |
| 69 | + /** |
|
| 70 | + * @param string $definition |
|
| 71 | + * @param string[] $match |
|
| 72 | + */ |
|
| 65 | 73 | private function parseProperties($definition, $match) |
| 66 | 74 | { |
| 67 | 75 | if (!empty($match[2])) { |
@@ -80,6 +88,10 @@ discard block |
||
| 80 | 88 | } |
| 81 | 89 | } |
| 82 | 90 | |
| 91 | + /** |
|
| 92 | + * @param string $definition |
|
| 93 | + * @param string[] $match |
|
| 94 | + */ |
|
| 83 | 95 | private function parseRange($definition, $match) |
| 84 | 96 | { |
| 85 | 97 | if (!empty($match[3])) { |
@@ -100,6 +112,9 @@ discard block |
||
| 100 | 112 | } |
| 101 | 113 | } |
| 102 | 114 | |
| 115 | + /** |
|
| 116 | + * @param string|false $discriminator |
|
| 117 | + */ |
|
| 103 | 118 | private function setDiscriminator($discriminator) |
| 104 | 119 | { |
| 105 | 120 | if (!empty($this->discriminator)) { |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | if (!empty($this->discriminator)) { |
| 106 | 106 | throw new \SwaggerGen\Exception("Discriminator may only be set once, " |
| 107 | - . "trying to change it " |
|
| 108 | - . "from '{$this->discriminator}' " |
|
| 109 | - . "to '{$discriminator}'"); |
|
| 107 | + . "trying to change it " |
|
| 108 | + . "from '{$this->discriminator}' " |
|
| 109 | + . "to '{$discriminator}'"); |
|
| 110 | 110 | } |
| 111 | 111 | if (isset($this->properties[$discriminator]) && empty($this->required[$discriminator])) { |
| 112 | 112 | throw new \SwaggerGen\Exception("Discriminator must be a required property, " |
| 113 | - . "property '{$discriminator}' is not required"); |
|
| 113 | + . "property '{$discriminator}' is not required"); |
|
| 114 | 114 | } |
| 115 | 115 | $this->discriminator = $discriminator; |
| 116 | 116 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | if (($name === $this->discriminator) && !$required) { |
| 154 | 154 | throw new \SwaggerGen\Exception("Discriminator must be a required property, " |
| 155 | - . "property '{$name}' is not required"); |
|
| 155 | + . "property '{$name}' is not required"); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | unset($this->required[$name]); |