Example #1
0
 protected function generateRootElement(Property\ComplexType $type)
 {
     $properties = $type->getProperties();
     $description = $type->getDescription();
     $props = array();
     $required = array();
     $this->definitions = array();
     foreach ($properties as $name => $property) {
         $props[$name] = $this->generateType($property);
         if ($property->isRequired()) {
             $required[] = $name;
         }
     }
     $definitions = array();
     foreach ($this->definitions as $name => $type) {
         $definitions[$name] = $type;
     }
     $result = array('$schema' => self::SCHEMA, 'id' => $this->targetNamespace, 'type' => 'object');
     if (!empty($description)) {
         $result['description'] = $description;
     }
     if (!empty($definitions)) {
         $result['definitions'] = $definitions;
     }
     if (!empty($props)) {
         $result['properties'] = $props;
     }
     if (!empty($required)) {
         $result['required'] = $required;
     }
     $result['additionalProperties'] = false;
     return $result;
 }
Example #2
0
File: Xsd.php Project: seytar/psx
 protected function generateRootElement(Property\ComplexType $type)
 {
     $this->writer->startElement('xs:element');
     $this->writer->writeAttribute('name', $type->getName());
     $this->writer->startElement('xs:complexType');
     $documentation = $type->getDescription();
     if (!empty($documentation)) {
         $this->writer->startElement('xs:annotation');
         $this->writer->writeElement('xs:documentation', $documentation);
         $this->writer->endElement();
     }
     $this->writer->startElement('xs:sequence');
     $this->generateProperties($type->getProperties());
     $this->writer->endElement();
     $this->writer->endElement();
     $this->writer->endElement();
     $this->generateTypes($type->getProperties());
 }