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())); } }
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(); }
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); }