Esempio n. 1
0
 public function denormalize($data, $class, $format = null, array $context = [])
 {
     if (isset($data->{'$ref'})) {
         return new Reference($data->{'$ref'}, $context['rootSchema'] ?: null);
     }
     $object = new \Joli\Jane\OpenApi\Model\Schema();
     if (!isset($context['rootSchema'])) {
         $context['rootSchema'] = $object;
     }
     if (property_exists($data, '$ref')) {
         $object->setDollarRef($data->{'$ref'});
     }
     if (property_exists($data, 'format')) {
         $object->setFormat($data->{'format'});
     }
     if (property_exists($data, 'title')) {
         $object->setTitle($data->{'title'});
     }
     if (property_exists($data, 'description')) {
         $object->setDescription($data->{'description'});
     }
     if (property_exists($data, 'default')) {
         $object->setDefault($data->{'default'});
     }
     if (property_exists($data, 'multipleOf')) {
         $object->setMultipleOf($data->{'multipleOf'});
     }
     if (property_exists($data, 'maximum')) {
         $object->setMaximum($data->{'maximum'});
     }
     if (property_exists($data, 'exclusiveMaximum')) {
         $object->setExclusiveMaximum($data->{'exclusiveMaximum'});
     }
     if (property_exists($data, 'minimum')) {
         $object->setMinimum($data->{'minimum'});
     }
     if (property_exists($data, 'exclusiveMinimum')) {
         $object->setExclusiveMinimum($data->{'exclusiveMinimum'});
     }
     if (property_exists($data, 'maxLength')) {
         $object->setMaxLength($data->{'maxLength'});
     }
     if (property_exists($data, 'minLength')) {
         $object->setMinLength($data->{'minLength'});
     }
     if (property_exists($data, 'pattern')) {
         $object->setPattern($data->{'pattern'});
     }
     if (property_exists($data, 'maxItems')) {
         $object->setMaxItems($data->{'maxItems'});
     }
     if (property_exists($data, 'minItems')) {
         $object->setMinItems($data->{'minItems'});
     }
     if (property_exists($data, 'uniqueItems')) {
         $object->setUniqueItems($data->{'uniqueItems'});
     }
     if (property_exists($data, 'maxProperties')) {
         $object->setMaxProperties($data->{'maxProperties'});
     }
     if (property_exists($data, 'minProperties')) {
         $object->setMinProperties($data->{'minProperties'});
     }
     if (property_exists($data, 'required')) {
         $values = [];
         foreach ($data->{'required'} as $value) {
             $values[] = $value;
         }
         $object->setRequired($values);
     }
     if (property_exists($data, 'enum')) {
         $values_1 = [];
         foreach ($data->{'enum'} as $value_1) {
             $values_1[] = $value_1;
         }
         $object->setEnum($values_1);
     }
     if (property_exists($data, 'additionalProperties')) {
         $value_2 = $data->{'additionalProperties'};
         if (is_object($data->{'additionalProperties'})) {
             $value_2 = $this->serializer->deserialize($data->{'additionalProperties'}, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
         }
         if (is_bool($data->{'additionalProperties'})) {
             $value_2 = $data->{'additionalProperties'};
         }
         $object->setAdditionalProperties($value_2);
     }
     if (property_exists($data, 'type')) {
         $value_3 = $data->{'type'};
         if (isset($data->{'type'})) {
             $value_3 = $data->{'type'};
         }
         if (is_array($data->{'type'})) {
             $values_2 = [];
             foreach ($data->{'type'} as $value_4) {
                 $values_2[] = $value_4;
             }
             $value_3 = $values_2;
         }
         $object->setType($value_3);
     }
     if (property_exists($data, 'items')) {
         $value_5 = $data->{'items'};
         if (is_object($data->{'items'})) {
             $value_5 = $this->serializer->deserialize($data->{'items'}, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
         }
         if (is_array($data->{'items'})) {
             $values_3 = [];
             foreach ($data->{'items'} as $value_6) {
                 $values_3[] = $this->serializer->deserialize($value_6, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
             }
             $value_5 = $values_3;
         }
         $object->setItems($value_5);
     }
     if (property_exists($data, 'allOf')) {
         $values_4 = [];
         foreach ($data->{'allOf'} as $value_7) {
             $values_4[] = $this->serializer->deserialize($value_7, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
         }
         $object->setAllOf($values_4);
     }
     if (property_exists($data, 'properties')) {
         $values_5 = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
         foreach ($data->{'properties'} as $key => $value_8) {
             $values_5[$key] = $this->serializer->deserialize($value_8, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
         }
         $object->setProperties($values_5);
     }
     if (property_exists($data, 'discriminator')) {
         $object->setDiscriminator($data->{'discriminator'});
     }
     if (property_exists($data, 'readOnly')) {
         $object->setReadOnly($data->{'readOnly'});
     }
     if (property_exists($data, 'xml')) {
         $object->setXml($this->serializer->deserialize($data->{'xml'}, 'Joli\\Jane\\OpenApi\\Model\\Xml', 'raw', $context));
     }
     if (property_exists($data, 'externalDocs')) {
         $object->setExternalDocs($this->serializer->deserialize($data->{'externalDocs'}, 'Joli\\Jane\\OpenApi\\Model\\ExternalDocs', 'raw', $context));
     }
     if (property_exists($data, 'example')) {
         $object->setExample($data->{'example'});
     }
     return $object;
 }
 public function denormalize($data, $class, $format = null, array $context = [])
 {
     if (empty($data)) {
         return null;
     }
     if (isset($data->{'$ref'})) {
         return new Reference($data->{'$ref'}, $context['rootSchema'] ?: null);
     }
     $object = new \Joli\Jane\OpenApi\Model\Schema();
     if (!isset($context['rootSchema'])) {
         $context['rootSchema'] = $object;
     }
     if (isset($data->{'$ref'})) {
         $object->setDollarRef($data->{'$ref'});
     }
     if (isset($data->{'format'})) {
         $object->setFormat($data->{'format'});
     }
     if (isset($data->{'title'})) {
         $object->setTitle($data->{'title'});
     }
     if (isset($data->{'description'})) {
         $object->setDescription($data->{'description'});
     }
     if (isset($data->{'default'})) {
         $object->setDefault($data->{'default'});
     }
     if (isset($data->{'multipleOf'})) {
         $object->setMultipleOf($data->{'multipleOf'});
     }
     if (isset($data->{'maximum'})) {
         $object->setMaximum($data->{'maximum'});
     }
     if (isset($data->{'exclusiveMaximum'})) {
         $object->setExclusiveMaximum($data->{'exclusiveMaximum'});
     }
     if (isset($data->{'minimum'})) {
         $object->setMinimum($data->{'minimum'});
     }
     if (isset($data->{'exclusiveMinimum'})) {
         $object->setExclusiveMinimum($data->{'exclusiveMinimum'});
     }
     if (isset($data->{'maxLength'})) {
         $object->setMaxLength($data->{'maxLength'});
     }
     if (isset($data->{'minLength'})) {
         $object->setMinLength($data->{'minLength'});
     }
     if (isset($data->{'pattern'})) {
         $object->setPattern($data->{'pattern'});
     }
     if (isset($data->{'maxItems'})) {
         $object->setMaxItems($data->{'maxItems'});
     }
     if (isset($data->{'minItems'})) {
         $object->setMinItems($data->{'minItems'});
     }
     if (isset($data->{'uniqueItems'})) {
         $object->setUniqueItems($data->{'uniqueItems'});
     }
     if (isset($data->{'maxProperties'})) {
         $object->setMaxProperties($data->{'maxProperties'});
     }
     if (isset($data->{'minProperties'})) {
         $object->setMinProperties($data->{'minProperties'});
     }
     if (isset($data->{'required'})) {
         $values_145 = [];
         foreach ($data->{'required'} as $value_146) {
             $values_145[] = $value_146;
         }
         $object->setRequired($values_145);
     }
     if (isset($data->{'enum'})) {
         $values_147 = [];
         foreach ($data->{'enum'} as $value_148) {
             $values_147[] = $value_148;
         }
         $object->setEnum($values_147);
     }
     if (isset($data->{'additionalProperties'})) {
         $value_149 = $data->{'additionalProperties'};
         if (is_object($data->{'additionalProperties'})) {
             $value_149 = $this->serializer->deserialize($data->{'additionalProperties'}, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
         }
         if (is_bool($data->{'additionalProperties'})) {
             $value_149 = $data->{'additionalProperties'};
         }
         $object->setAdditionalProperties($value_149);
     }
     if (isset($data->{'type'})) {
         $value_150 = $data->{'type'};
         if (isset($data->{'type'})) {
             $value_150 = $data->{'type'};
         }
         if (is_array($data->{'type'})) {
             $values_151 = [];
             foreach ($data->{'type'} as $value_152) {
                 $values_151[] = $value_152;
             }
             $value_150 = $values_151;
         }
         $object->setType($value_150);
     }
     if (isset($data->{'items'})) {
         $value_153 = $data->{'items'};
         if (is_object($data->{'items'})) {
             $value_153 = $this->serializer->deserialize($data->{'items'}, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
         }
         if (is_array($data->{'items'})) {
             $values_154 = [];
             foreach ($data->{'items'} as $value_155) {
                 $values_154[] = $this->serializer->deserialize($value_155, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
             }
             $value_153 = $values_154;
         }
         $object->setItems($value_153);
     }
     if (isset($data->{'allOf'})) {
         $values_156 = [];
         foreach ($data->{'allOf'} as $value_157) {
             $values_156[] = $this->serializer->deserialize($value_157, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
         }
         $object->setAllOf($values_156);
     }
     if (isset($data->{'properties'})) {
         $values_158 = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
         foreach ($data->{'properties'} as $key_160 => $value_159) {
             $values_158[$key_160] = $this->serializer->deserialize($value_159, 'Joli\\Jane\\OpenApi\\Model\\Schema', 'raw', $context);
         }
         $object->setProperties($values_158);
     }
     if (isset($data->{'discriminator'})) {
         $object->setDiscriminator($data->{'discriminator'});
     }
     if (isset($data->{'readOnly'})) {
         $object->setReadOnly($data->{'readOnly'});
     }
     if (isset($data->{'xml'})) {
         $object->setXml($this->serializer->deserialize($data->{'xml'}, 'Joli\\Jane\\OpenApi\\Model\\Xml', 'raw', $context));
     }
     if (isset($data->{'externalDocs'})) {
         $object->setExternalDocs($this->serializer->deserialize($data->{'externalDocs'}, 'Joli\\Jane\\OpenApi\\Model\\ExternalDocs', 'raw', $context));
     }
     if (isset($data->{'example'})) {
         $object->setExample($data->{'example'});
     }
     return $object;
 }