コード例 #1
0
 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\Operation();
     if (!isset($context['rootSchema'])) {
         $context['rootSchema'] = $object;
     }
     if (isset($data->{'tags'})) {
         $values_61 = [];
         foreach ($data->{'tags'} as $value_62) {
             $values_61[] = $value_62;
         }
         $object->setTags($values_61);
     }
     if (isset($data->{'summary'})) {
         $object->setSummary($data->{'summary'});
     }
     if (isset($data->{'description'})) {
         $object->setDescription($data->{'description'});
     }
     if (isset($data->{'externalDocs'})) {
         $object->setExternalDocs($this->serializer->deserialize($data->{'externalDocs'}, 'Joli\\Jane\\OpenApi\\Model\\ExternalDocs', 'raw', $context));
     }
     if (isset($data->{'operationId'})) {
         $object->setOperationId($data->{'operationId'});
     }
     if (isset($data->{'produces'})) {
         $values_63 = [];
         foreach ($data->{'produces'} as $value_64) {
             $values_63[] = $value_64;
         }
         $object->setProduces($values_63);
     }
     if (isset($data->{'consumes'})) {
         $values_65 = [];
         foreach ($data->{'consumes'} as $value_66) {
             $values_65[] = $value_66;
         }
         $object->setConsumes($values_65);
     }
     if (isset($data->{'parameters'})) {
         $values_67 = [];
         foreach ($data->{'parameters'} as $value_68) {
             $value_69 = $value_68;
             if (is_object($value_68) and isset($value_68->{'name'}) and (isset($value_68->{'in'}) and $value_68->{'in'} == 'body') and isset($value_68->{'schema'})) {
                 $value_69 = $this->serializer->deserialize($value_68, 'Joli\\Jane\\OpenApi\\Model\\BodyParameter', 'raw', $context);
             }
             if (is_object($value_68) and (isset($value_68->{'in'}) and $value_68->{'in'} == 'header') and isset($value_68->{'name'}) and (isset($value_68->{'type'}) and ($value_68->{'type'} == 'string' or $value_68->{'type'} == 'number' or $value_68->{'type'} == 'boolean' or $value_68->{'type'} == 'integer' or $value_68->{'type'} == 'array'))) {
                 $value_69 = $this->serializer->deserialize($value_68, 'Joli\\Jane\\OpenApi\\Model\\HeaderParameterSubSchema', 'raw', $context);
             }
             if (is_object($value_68) and (isset($value_68->{'in'}) and $value_68->{'in'} == 'formData') and isset($value_68->{'name'}) and (isset($value_68->{'type'}) and ($value_68->{'type'} == 'string' or $value_68->{'type'} == 'number' or $value_68->{'type'} == 'boolean' or $value_68->{'type'} == 'integer' or $value_68->{'type'} == 'array' or $value_68->{'type'} == 'file'))) {
                 $value_69 = $this->serializer->deserialize($value_68, 'Joli\\Jane\\OpenApi\\Model\\FormDataParameterSubSchema', 'raw', $context);
             }
             if (is_object($value_68) and (isset($value_68->{'in'}) and $value_68->{'in'} == 'query') and isset($value_68->{'name'}) and (isset($value_68->{'type'}) and ($value_68->{'type'} == 'string' or $value_68->{'type'} == 'number' or $value_68->{'type'} == 'boolean' or $value_68->{'type'} == 'integer' or $value_68->{'type'} == 'array'))) {
                 $value_69 = $this->serializer->deserialize($value_68, 'Joli\\Jane\\OpenApi\\Model\\QueryParameterSubSchema', 'raw', $context);
             }
             if (is_object($value_68) and (isset($value_68->{'required'}) and $value_68->{'required'} == '1') and (isset($value_68->{'in'}) and $value_68->{'in'} == 'path') and isset($value_68->{'name'}) and (isset($value_68->{'type'}) and ($value_68->{'type'} == 'string' or $value_68->{'type'} == 'number' or $value_68->{'type'} == 'boolean' or $value_68->{'type'} == 'integer' or $value_68->{'type'} == 'array'))) {
                 $value_69 = $this->serializer->deserialize($value_68, 'Joli\\Jane\\OpenApi\\Model\\PathParameterSubSchema', 'raw', $context);
             }
             if (is_object($value_68) and isset($value_68->{'$ref'})) {
                 $value_69 = $this->serializer->deserialize($value_68, 'Joli\\Jane\\OpenApi\\Model\\JsonReference', 'raw', $context);
             }
             $values_67[] = $value_69;
         }
         $object->setParameters($values_67);
     }
     if (isset($data->{'responses'})) {
         $values_70 = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
         foreach ($data->{'responses'} as $key_72 => $value_71) {
             if (preg_match('/^([0-9]{3})$|^(default)$/', $key_72) && isset($value_71)) {
                 $value_73 = $value_71;
                 if (is_object($value_71) and isset($value_71->{'description'})) {
                     $value_73 = $this->serializer->deserialize($value_71, 'Joli\\Jane\\OpenApi\\Model\\Response', 'raw', $context);
                 }
                 if (is_object($value_71) and isset($value_71->{'$ref'})) {
                     $value_73 = $this->serializer->deserialize($value_71, 'Joli\\Jane\\OpenApi\\Model\\JsonReference', 'raw', $context);
                 }
                 $values_70[$key_72] = $value_73;
                 continue;
             }
             if (preg_match('/^x-/', $key_72) && isset($value_71)) {
                 $values_70[$key_72] = $value_71;
                 continue;
             }
         }
         $object->setResponses($values_70);
     }
     if (isset($data->{'schemes'})) {
         $values_74 = [];
         foreach ($data->{'schemes'} as $value_75) {
             $values_74[] = $value_75;
         }
         $object->setSchemes($values_74);
     }
     if (isset($data->{'deprecated'})) {
         $object->setDeprecated($data->{'deprecated'});
     }
     if (isset($data->{'security'})) {
         $values_76 = [];
         foreach ($data->{'security'} as $value_77) {
             $values_78 = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
             foreach ($value_77 as $key_80 => $value_79) {
                 $values_81 = [];
                 foreach ($value_79 as $value_82) {
                     $values_81[] = $value_82;
                 }
                 $values_78[$key_80] = $values_81;
             }
             $values_76[] = $values_78;
         }
         $object->setSecurity($values_76);
     }
     return $object;
 }
コード例 #2
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\Operation();
     if (!isset($context['rootSchema'])) {
         $context['rootSchema'] = $object;
     }
     if (property_exists($data, 'tags')) {
         $values = [];
         foreach ($data->{'tags'} as $value) {
             $values[] = $value;
         }
         $object->setTags($values);
     }
     if (property_exists($data, 'summary')) {
         $object->setSummary($data->{'summary'});
     }
     if (property_exists($data, 'description')) {
         $object->setDescription($data->{'description'});
     }
     if (property_exists($data, 'externalDocs')) {
         $object->setExternalDocs($this->serializer->deserialize($data->{'externalDocs'}, 'Joli\\Jane\\OpenApi\\Model\\ExternalDocs', 'raw', $context));
     }
     if (property_exists($data, 'operationId')) {
         $object->setOperationId($data->{'operationId'});
     }
     if (property_exists($data, 'produces')) {
         $values_1 = [];
         foreach ($data->{'produces'} as $value_1) {
             $values_1[] = $value_1;
         }
         $object->setProduces($values_1);
     }
     if (property_exists($data, 'consumes')) {
         $values_2 = [];
         foreach ($data->{'consumes'} as $value_2) {
             $values_2[] = $value_2;
         }
         $object->setConsumes($values_2);
     }
     if (property_exists($data, 'parameters')) {
         $values_3 = [];
         foreach ($data->{'parameters'} as $value_3) {
             $value_4 = $value_3;
             if (is_object($value_3) and isset($value_3->{'name'}) and (isset($value_3->{'in'}) and $value_3->{'in'} == 'body') and isset($value_3->{'schema'})) {
                 $value_4 = $this->serializer->deserialize($value_3, 'Joli\\Jane\\OpenApi\\Model\\BodyParameter', 'raw', $context);
             }
             if (is_object($value_3) and (isset($value_3->{'in'}) and $value_3->{'in'} == 'header') and isset($value_3->{'name'}) and (isset($value_3->{'type'}) and ($value_3->{'type'} == 'string' or $value_3->{'type'} == 'number' or $value_3->{'type'} == 'boolean' or $value_3->{'type'} == 'integer' or $value_3->{'type'} == 'array'))) {
                 $value_4 = $this->serializer->deserialize($value_3, 'Joli\\Jane\\OpenApi\\Model\\HeaderParameterSubSchema', 'raw', $context);
             }
             if (is_object($value_3) and (isset($value_3->{'in'}) and $value_3->{'in'} == 'formData') and isset($value_3->{'name'}) and (isset($value_3->{'type'}) and ($value_3->{'type'} == 'string' or $value_3->{'type'} == 'number' or $value_3->{'type'} == 'boolean' or $value_3->{'type'} == 'integer' or $value_3->{'type'} == 'array' or $value_3->{'type'} == 'file'))) {
                 $value_4 = $this->serializer->deserialize($value_3, 'Joli\\Jane\\OpenApi\\Model\\FormDataParameterSubSchema', 'raw', $context);
             }
             if (is_object($value_3) and (isset($value_3->{'in'}) and $value_3->{'in'} == 'query') and isset($value_3->{'name'}) and (isset($value_3->{'type'}) and ($value_3->{'type'} == 'string' or $value_3->{'type'} == 'number' or $value_3->{'type'} == 'boolean' or $value_3->{'type'} == 'integer' or $value_3->{'type'} == 'array'))) {
                 $value_4 = $this->serializer->deserialize($value_3, 'Joli\\Jane\\OpenApi\\Model\\QueryParameterSubSchema', 'raw', $context);
             }
             if (is_object($value_3) and (isset($value_3->{'required'}) and $value_3->{'required'} == '1') and (isset($value_3->{'in'}) and $value_3->{'in'} == 'path') and isset($value_3->{'name'}) and (isset($value_3->{'type'}) and ($value_3->{'type'} == 'string' or $value_3->{'type'} == 'number' or $value_3->{'type'} == 'boolean' or $value_3->{'type'} == 'integer' or $value_3->{'type'} == 'array'))) {
                 $value_4 = $this->serializer->deserialize($value_3, 'Joli\\Jane\\OpenApi\\Model\\PathParameterSubSchema', 'raw', $context);
             }
             if (is_object($value_3) and isset($value_3->{'$ref'})) {
                 $value_4 = $this->serializer->deserialize($value_3, 'Joli\\Jane\\OpenApi\\Model\\JsonReference', 'raw', $context);
             }
             $values_3[] = $value_4;
         }
         $object->setParameters($values_3);
     }
     if (property_exists($data, 'responses')) {
         $values_4 = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
         foreach ($data->{'responses'} as $key => $value_5) {
             if (preg_match('/^([0-9]{3})$|^(default)$/', $key) && isset($value_5)) {
                 $value_6 = $value_5;
                 if (is_object($value_5) and isset($value_5->{'description'})) {
                     $value_6 = $this->serializer->deserialize($value_5, 'Joli\\Jane\\OpenApi\\Model\\Response', 'raw', $context);
                 }
                 if (is_object($value_5) and isset($value_5->{'$ref'})) {
                     $value_6 = $this->serializer->deserialize($value_5, 'Joli\\Jane\\OpenApi\\Model\\JsonReference', 'raw', $context);
                 }
                 $values_4[$key] = $value_6;
                 continue;
             }
             if (preg_match('/^x-/', $key) && isset($value_5)) {
                 $values_4[$key] = $value_5;
                 continue;
             }
         }
         $object->setResponses($values_4);
     }
     if (property_exists($data, 'schemes')) {
         $values_5 = [];
         foreach ($data->{'schemes'} as $value_7) {
             $values_5[] = $value_7;
         }
         $object->setSchemes($values_5);
     }
     if (property_exists($data, 'deprecated')) {
         $object->setDeprecated($data->{'deprecated'});
     }
     if (property_exists($data, 'security')) {
         $values_6 = [];
         foreach ($data->{'security'} as $value_8) {
             $values_7 = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
             foreach ($value_8 as $key_1 => $value_9) {
                 $values_8 = [];
                 foreach ($value_9 as $value_10) {
                     $values_8[] = $value_10;
                 }
                 $values_7[$key_1] = $values_8;
             }
             $values_6[] = $values_7;
         }
         $object->setSecurity($values_6);
     }
     return $object;
 }