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);
 }
示例#2
0
文件: Resource.php 项目: seytar/psx
 public function __construct($status, $path)
 {
     $this->status = $status;
     $this->path = $path;
     $this->pathParameters = Property::getComplex('path');
     $this->methods = array();
 }
示例#3
0
 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);
 }
示例#4
0
文件: Schema.php 项目: seytar/psx
 public function getDefinition()
 {
     $sb = $this->getSchemaBuilder('person');
     $sb->setReference('PSX\\Data\\Record\\Importer\\Test\\Person');
     $sb->string('title')->setRequired(true);
     $person = $sb->getProperty();
     $sb = $this->getSchemaBuilder('entry');
     $sb->setReference('PSX\\Data\\Record\\Importer\\Test\\Entry');
     $sb->string('title')->setRequired(true);
     $entry = $sb->getProperty();
     $sb = $this->getSchemaBuilder('token');
     $sb->setReference('PSX\\Data\\Record\\Importer\\Test\\Factory');
     $sb->string('alg')->setRequired(true);
     $sb->string('sig')->setRequired(true);
     $token = $sb->getProperty();
     $sb = $this->getSchemaBuilder('news');
     $sb->integer('id')->setRequired(true);
     $sb->string('title')->setPattern('[A-z]{3,16}')->setRequired(true);
     $sb->boolean('active')->setRequired(true);
     $sb->boolean('disabled')->setRequired(true);
     $sb->integer('count')->setEnumeration(array(6, 12))->setRequired(true);
     $sb->float('rating')->setMin(8)->setMax(14)->setRequired(true);
     $sb->dateTime('date')->setRequired(true);
     $sb->complexType($person);
     $sb->arrayType('tags')->setPrototype(Property::getString('tag'))->setMinLength(0)->setMaxLength(4);
     $sb->arrayType('entry')->setPrototype($entry);
     $sb->complexType($token);
     $sb->string('url')->setReference('PSX\\Url')->setRequired(true);
     return $sb->getProperty();
 }
示例#5
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;
 }
示例#6
0
文件: TestSchema.php 项目: seytar/psx
 public function getDefinition()
 {
     $sb = $this->getSchemaBuilder('location')->setDescription('Location of the person');
     $sb->integer('lat');
     $sb->integer('long');
     $location = $sb->getProperty();
     $sb = $this->getSchemaBuilder('web')->setDescription('An application');
     $sb->string('name');
     $sb->string('url');
     $web = $sb->getProperty();
     $sb = $this->getSchemaBuilder('author')->setDescription('An simple author element with some description');
     $sb->string('title')->setPattern('[A-z]{3,16}')->setRequired(true);
     $sb->string('email')->setDescription('We will send no spam to this addresss');
     $sb->arrayType('categories')->setPrototype(Property::getString('category'))->setMaxLength(8);
     $sb->arrayType('locations')->setPrototype($location)->setDescription('Array of locations');
     $sb->complexType('origin', $location);
     $author = $sb->getProperty();
     $sb = $this->getSchemaBuilder('news')->setDescription('An general news entry');
     $sb->arrayType('tags')->setPrototype(Property::getString('tag'))->setMinLength(1)->setMaxLength(6);
     $sb->arrayType('receiver')->setPrototype($author)->setMinLength(1)->setRequired(true);
     $sb->arrayType('resources')->setPrototype(Property::getChoice('resource')->add($location)->add($web));
     $sb->boolean('read');
     $sb->choiceType('source')->add($author)->add($web);
     $sb->complexType($author)->setRequired(true);
     $sb->date('sendDate');
     $sb->dateTime('readDate');
     $sb->duration('expires');
     $sb->float('price')->setMin(1)->setMax(100)->setRequired(true);
     $sb->integer('rating')->setMin(1)->setMax(5);
     $sb->string('content')->setDescription('Contains the main content of the news entry')->setMinLength(3)->setMaxLength(512)->setRequired(true);
     $sb->string('question')->setEnumeration(array('foo', 'bar'));
     $sb->time('coffeeTime');
     return $sb->getProperty();
 }
示例#7
0
文件: Property.php 项目: seytar/psx
 public function getDefinition()
 {
     $sb = $this->getSchemaBuilder('a');
     $sb->string('foo');
     $complexA = $sb->getProperty();
     $sb = $this->getSchemaBuilder('b');
     $sb->string('bar');
     $complexB = $sb->getProperty();
     $choice = SchemaProperty::getChoice("choice")->add($complexA)->add($complexB);
     $sb = $this->getSchemaBuilder('complex');
     $sb->string('foo');
     $complex = $sb->getProperty();
     $sb = $this->getSchemaBuilder('property');
     $sb->arrayType('array')->setPrototype(SchemaProperty::getString('foo'));
     $sb->arrayType('arrayComplex')->setPrototype($complex);
     $sb->arrayType('arrayChoice')->setPrototype($choice);
     $sb->boolean('boolean');
     $sb->choiceType($choice);
     $sb->complexType($complex);
     $sb->date('date');
     $sb->dateTime('dateTime');
     $sb->duration('duration');
     $sb->float('float');
     $sb->integer('integer');
     $sb->string('string');
     $sb->time('time');
     return $sb->getProperty();
 }
示例#8
0
文件: Action.php 项目: virusvn/fusio
 public function getDefinition()
 {
     $sb = $this->getSchemaBuilder('action');
     $sb->integer('id');
     $sb->string('name')->setPattern('[A-z0-9\\-\\_]{3,64}');
     $sb->string('class');
     $sb->anyType('config')->setPrototype(Property::getString('value'));
     return $sb->getProperty();
 }
示例#9
0
 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);
 }
示例#10
0
文件: User.php 项目: uqiauto/fusio
 public function getDefinition()
 {
     $sb = $this->getSchemaBuilder('user');
     $sb->integer('id');
     $sb->integer('status');
     $sb->string('name')->setPattern('[A-z0-9\\-\\_\\.]{3,32}');
     $sb->arrayType('scopes')->setPrototype(Property::getString('name'));
     $sb->arrayType('apps')->setPrototype($this->getSchema('Fusio\\Impl\\Backend\\Schema\\App'));
     $sb->dateTime('date');
     return $sb->getProperty();
 }
示例#11
0
文件: App.php 项目: virusvn/fusio
 public function getDefinition()
 {
     $sb = $this->getSchemaBuilder('app');
     $sb->integer('id');
     $sb->integer('userId');
     $sb->integer('status');
     $sb->string('name')->setPattern('[A-z0-9\\-\\_]{3,64}');
     $sb->string('url');
     $sb->string('appKey');
     $sb->string('appSecret');
     $sb->arrayType('scopes')->setPrototype(Property::getString('name'));
     $sb->arrayType('tokens')->setPrototype($this->getSchema('Fusio\\Backend\\Schema\\App\\Token'));
     return $sb->getProperty();
 }
示例#12
0
 public function testMethod()
 {
     $method = Factory::getMethod('POST');
     $method->setDescription('foobar');
     $method->addQueryParameter(Property::getString('foo'));
     $method->setRequest(new Schema(Property::getString('foo')));
     $method->addResponse(200, new Schema(Property::getString('foo')));
     $this->assertEquals('foobar', $method->getDescription());
     $this->assertInstanceOf('PSX\\Data\\SchemaInterface', $method->getQueryParameters());
     $this->assertTrue($method->hasRequest());
     $this->assertInstanceOf('PSX\\Data\\SchemaInterface', $method->getRequest());
     $this->assertInstanceOf('PSX\\Data\\SchemaInterface', $method->getResponse(200));
     $this->assertTrue($method->hasResponse(200));
     $this->assertFalse($method->hasResponse(201));
 }
示例#13
0
 public function testResource()
 {
     $resource = new Resource(Resource::STATUS_ACTIVE, '/foo');
     $resource->setTitle('foobar');
     $resource->setDescription('foobar');
     $resource->addPathParameter(Property::getString('foo'));
     $resource->addMethod(Factory::getMethod('GET'));
     $this->assertEquals(Resource::STATUS_ACTIVE, $resource->getStatus());
     $this->assertTrue($resource->isActive());
     $this->assertFalse($resource->isDeprecated());
     $this->assertFalse($resource->isClosed());
     $this->assertEquals('/foo', $resource->getPath());
     $this->assertEquals('foobar', $resource->getTitle());
     $this->assertEquals('foobar', $resource->getDescription());
     $this->assertInstanceOf('PSX\\Data\\SchemaInterface', $resource->getPathParameters());
     $this->assertInstanceOf('PSX\\Api\\Resource\\MethodAbstract', $resource->getMethod('GET'));
     $this->assertEquals(['GET' => $resource->getMethod('GET')], $resource->getMethods());
     $this->assertEquals(['GET'], $resource->getAllowedMethods());
     $this->assertTrue($resource->hasMethod('GET'));
     $this->assertFalse($resource->hasMethod('POST'));
 }
示例#14
0
 public function testGetTypeName()
 {
     $this->assertEquals('time', Property::getTime('test')->getTypeName());
 }
示例#15
0
文件: Raml.php 项目: 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);
     }
 }
示例#16
0
 public function testGetTypeName()
 {
     $this->assertEquals('float', Property::getFloat('test')->getTypeName());
 }
示例#17
0
 /**
  * @expectedException \PSX\Data\Schema\ValidationException
  */
 public function testVisitTimeInvalidFormat()
 {
     $visitor = new AssimilationVisitor();
     $property = Property::getTime('test');
     $visitor->visitTime('foo', $property, '');
 }
示例#18
0
文件: Document.php 项目: seytar/psx
 protected function parseOneOf(array $data, $name, $depth)
 {
     $choiceType = Property::getChoice($name);
     foreach ($data['oneOf'] as $row) {
         if (isset($row['title'])) {
             $property = $this->getRecProperty($row, null, $depth);
             if ($property instanceof Property\ComplexType) {
                 $choiceType->add($property);
             }
         }
     }
     return $choiceType;
 }
示例#19
0
 public function testGetTypeName()
 {
     $this->assertEquals('duration', Property::getDuration('test')->getTypeName());
 }
示例#20
0
 public function testGetTypeName()
 {
     $this->assertEquals('complex', Property::getComplex('test')->getTypeName());
 }
示例#21
0
 public function testGetTypeName()
 {
     $this->assertEquals('array', Property::getArray('test')->getTypeName());
 }
示例#22
0
 public function testGetTypeName()
 {
     $this->assertEquals('integer', Property::getInteger('test')->getTypeName());
 }
示例#23
0
 public function testGetTypeName()
 {
     $this->assertEquals('boolean', Property::getBoolean('test')->getTypeName());
 }
示例#24
0
 public function testGetTypeName()
 {
     $this->assertEquals('string', Property::getString('test')->getTypeName());
 }
示例#25
0
 public function getDefinition()
 {
     $sb = $this->getSchemaBuilder('location');
     $sb->string('lat');
     $sb->string('long');
     $location = $sb->getProperty();
     $sb = $this->getSchemaBuilder('author');
     $sb->string('title');
     $sb->string('email');
     $sb->complexType($location);
     $author = $sb->getProperty();
     $sb = $this->getSchemaBuilder('news');
     $sb->string('content')->setRequired(true);
     $sb->integer('rating');
     $sb->float('price');
     $sb->boolean('read');
     $sb->complexType($location);
     $sb->arrayType('receiver')->setPrototype($author);
     $sb->arrayType('tags')->setPrototype(Property::getString('tag'));
     $sb->date('date');
     return $sb->getProperty();
 }
示例#26
0
 public function testVisitTimeDateTime()
 {
     $visitor = new ValidationVisitor();
     $property = Property::getTime('test');
     $this->assertTrue($visitor->visitTime(new \DateTime(), $property, ''));
 }
示例#27
0
 public function __construct()
 {
     $this->queryParameters = Property::getComplex('query');
     $this->responses = array();
 }