Exemplo n.º 1
0
 private function applyAnnotation($key, Annotation $annotation, Operation &$operation, $in_hint)
 {
     $fix_case = array('operationid' => 'operationId');
     $key = isset($fix_case[$key]) ? $fix_case[$key] : $key;
     switch ($key) {
         case 'summary':
         case 'description':
         case 'operationId':
             $operation->{$key} = $annotation->getValue();
             break;
         case 'deprecated':
             $operation->{$key} = in_array($annotation->getValue(), array(1, true, '1', 'true'), true);
             break;
         case 'tags':
         case 'consumes':
         case 'produces':
         case 'schemes':
             $operation->{$key}->merge(array_map(function ($v) {
                 return trim($v);
             }, explode(',', $annotation->getValue())));
             break;
         case 'parameter':
             $operation->addParameter($this->parseParameter($annotation->getValue(), $in_hint));
             break;
         case 'params':
         case 'validate':
             $operation->mergeParameters($this->resolveSchema($annotation->getValue(), $in_hint));
             break;
         case 'response':
             $operation->addResponse($this->parseResponseParameter($annotation->getValue()));
     }
 }
Exemplo n.º 2
0
 public function __construct($key, $value, $from_class = null)
 {
     parent::__construct($key, $value, $from_class);
     $this->parameters = $this->parseParameters();
     $this->validate($from_class);
     if (!empty($this->errors)) {
         throw new InvalidAnnotationException('Annotation format error, ' . implode(', ', $this->errors), 0);
     }
     $this->build();
 }
Exemplo n.º 3
0
 public function addAnnotation(Annotation $annotation)
 {
     if (!array_key_exists($annotation->getKey(), $this->annotations)) {
         $this->annotations[$annotation->getKey()] = array();
     }
     $this->annotations[$annotation->getKey()][] = $annotation;
     $annotation->apply($this);
 }