public function getDocumentation() { $table = $this->getTableSchema($this->getTable()); $collection = $this->getCollectionSchema($table); $message = $this->getMessageSchema(); $path = $this->context->get(Context::KEY_PATH); $resource = new Resource(Resource::STATUS_ACTIVE, $path); $method = new Resource\Get(); $method->addQueryParameter(Property::getInteger('startIndex')); $method->addQueryParameter(Property::getInteger('count')); $method->addQueryParameter(Property::getInteger('totalResults')); $method->addResponse(200, $collection); $resource->addMethod($method); $method = new Resource\Post(); $method->setRequest($table); $method->addResponse(200, $message); $resource->addMethod($method); $method = new Resource\Put(); $method->setRequest($table); $method->addResponse(200, $message); $resource->addMethod($method); $method = new Resource\Delete(); $method->setRequest($table); $method->addResponse(200, $message); $resource->addMethod($method); return new Documentation\Simple($resource); }
public function getDocumentation() { $resource = new Resource(Resource::STATUS_ACTIVE, $this->context->get(Context::KEY_PATH)); $resource->addMethod(Resource\Factory::getMethod('GET')->addQueryParameter(Property::getInteger('type'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Property'))); $resource->addMethod(Resource\Factory::getMethod('POST')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Property'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Property'))); return new Documentation\Simple($resource); }
public function getDocumentation() { $doc = new Documentation\Version(); $resource = new Resource(Resource::STATUS_CLOSED, $this->context->get(Context::KEY_PATH)); $resource->addMethod(Resource\Factory::getMethod('GET')->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Collection'))); $resource->addMethod(Resource\Factory::getMethod('POST')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Create'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $resource->addMethod(Resource\Factory::getMethod('PUT')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Update'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $resource->addMethod(Resource\Factory::getMethod('DELETE')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Delete'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $doc->addResource(1, $resource); $resource = new Resource(Resource::STATUS_DEPRECATED, $this->context->get(Context::KEY_PATH)); $resource->addMethod(Resource\Factory::getMethod('GET')->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Collection'))); $resource->addMethod(Resource\Factory::getMethod('POST')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Create'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $resource->addMethod(Resource\Factory::getMethod('PUT')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Update'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $resource->addMethod(Resource\Factory::getMethod('DELETE')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Delete'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $doc->addResource(2, $resource); $resource = new Resource(Resource::STATUS_ACTIVE, $this->context->get(Context::KEY_PATH)); $resource->setTitle('foo'); $resource->setDescription('lorem ipsum'); $resource->addPathParameter(Property::getString('name')->setDescription('Name parameter')->setRequired(false)->setMinLength(0)->setMaxLength(16)->setPattern('[A-z]+')); $resource->addPathParameter(Property::getString('type')->setEnumeration(['foo', 'bar'])); $resource->addMethod(Resource\Factory::getMethod('GET')->setDescription('Returns a collection')->addQueryParameter(Property::getInteger('startIndex')->setDescription('startIndex parameter')->setRequired(false)->setMin(0)->setMax(32))->addQueryParameter(Property::getFloat('float'))->addQueryParameter(Property::getBoolean('boolean'))->addQueryParameter(Property::getDate('date'))->addQueryParameter(Property::getDateTime('datetime'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Collection'))); $resource->addMethod(Resource\Factory::getMethod('POST')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Create'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $resource->addMethod(Resource\Factory::getMethod('PUT')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Update'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $resource->addMethod(Resource\Factory::getMethod('DELETE')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Delete'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $doc->addResource(3, $resource); return $doc; }
public function getDocumentation() { $resource = new Resource(Resource::STATUS_ACTIVE, $this->context->get(Context::KEY_PATH)); $resource->addPathParameter(Property::getInteger('fooId')); $resource->addMethod(Resource\Factory::getMethod('GET')->addQueryParameter(Property::getInteger('startIndex'))->addQueryParameter(Property::getInteger('count'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Collection'))); $resource->addMethod(Resource\Factory::getMethod('PUT')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Update'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); $resource->addMethod(Resource\Factory::getMethod('DELETE')->setRequest($this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\Delete'))->addResponse(200, $this->schemaManager->getSchema('PSX\\Controller\\Foo\\Schema\\SuccessMessage'))); return new Documentation\Simple($resource); }
public function testGetId() { $property = Property::getChoice('test'); $this->assertEquals('1cb150947b4fb85659239644eeafd2fd', $property->getId()); $complexFoo = Property::getComplex('foo')->add(Property::getInteger('foo')->setRequired(true))->add(Property::getInteger('bar')->setRequired(true)); $complexBar = Property::getComplex('bar')->add(Property::getInteger('foo')->setRequired(true))->add(Property::getInteger('baz')->setRequired(true)); $property = Property::getChoice('test')->add($complexFoo)->add($complexBar); $this->assertEquals('0faf795063796275fc246ec2b8c27929', $property->getId()); }
protected function getPropertyType($type, $name) { switch ($type) { case 'integer': return Property::getInteger($name); case 'number': return Property::getFloat($name); case 'date': return Property::getDateTime($name); case 'boolean': return Property::getBoolean($name); case 'string': default: return Property::getString($name); } }
protected function parseInteger(array $data, $name) { $property = Property::getInteger($name); $this->parseScalar($property, $data); return $property; }
public function testVisitIntegerNull() { $visitor = new ValidationVisitor(); $property = Property::getInteger('test'); $this->assertTrue($visitor->visitInteger(null, $property, '')); }
public function testVisitIntegerInvalidFormat() { $visitor = new AssimilationVisitor(); $property = Property::getInteger('test'); $this->assertEquals(0, $visitor->visitInteger('foo', $property, '')); }
public function testGetTypeName() { $this->assertEquals('integer', Property::getInteger('test')->getTypeName()); }