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(); }
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(); }
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; }
public function testGetTypeName() { $this->assertEquals('choice', Property::getChoice('test')->getTypeName()); }