Пример #1
0
 /**
  *
  * @param Property|Parameter|Operation $annotation
  * @return bool
  */
 public static function validateContainer($annotation)
 {
     // Interpret `items="$ref:Model"` as `@SWG\Items(type="Model")`
     if (is_string($annotation->items) && preg_match('/\\$ref:[\\s]*(.+)[\\s]*$/', $annotation->items, $matches)) {
         $annotation->items = new Items();
         $annotation->items->type = array_pop($matches);
     }
     // Validate if items are inside a container type.
     if ($annotation->items !== null) {
         if ($annotation->type !== 'array') {
             Logger::warning('Unexcepted items for type "' . $annotation->type . '" in ' . $annotation->identity() . ', expecting "array"');
             $annotation->items = null;
         } else {
             Swagger::checkDataType($annotation->items->type, $annotation->items->_context);
         }
     }
     return true;
 }
Пример #2
0
 public function validate()
 {
     if (count($this->_partials) !== 0) {
         return true;
     }
     if (empty($this->nickname)) {
         Logger::notice('Required field "nickname" is missing for "' . $this->identity() . '" in ' . $this->_context);
     }
     Swagger::checkDataType($this->type, $this->_context);
     foreach ($this->parameters as $parameter) {
         if ($parameter->validate() == false) {
             return false;
         }
     }
     Items::validateContainer($this);
     Produces::validateContainer($this);
     Consumes::validateContainer($this);
     return true;
 }
Пример #3
0
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     Swagger::checkDataType($this->type, $this->_context);
     if (is_string($this->enum)) {
         $values = $this->decode($this->enum);
         if (is_object($values)) {
             $this->enum = array();
             foreach ($values as $key => $value) {
                 $this->enum[] = $key . '-' . $value;
             }
         } else {
             $this->enum = $values;
         }
     }
 }