Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
Archivo: Raml.php Proyecto: seytar/psx
 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);
     }
 }
Ejemplo n.º 3
0
 protected function parseBoolean(array $data, $name)
 {
     $property = Property::getBoolean($name);
     $this->parseScalar($property, $data);
     return $property;
 }
Ejemplo n.º 4
0
 public function testVisitBooleanNull()
 {
     $visitor = new ValidationVisitor();
     $property = Property::getBoolean('test');
     $this->assertTrue($visitor->visitBoolean(null, $property, ''));
 }
Ejemplo n.º 5
0
 public function testVisitBooleanInvalidFormat()
 {
     $visitor = new AssimilationVisitor();
     $property = Property::getBoolean('test');
     $this->assertEquals(true, $visitor->visitBoolean(4, $property, ''));
 }
Ejemplo n.º 6
0
 public function testGetTypeName()
 {
     $this->assertEquals('boolean', Property::getBoolean('test')->getTypeName());
 }