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