示例#1
0
 /**
  * @param Operation $operation
  * @param ProcessEvent $event
  * @return ResponseInterface
  */
 public static function fromOperation(Operation $operation, ProcessEvent $event)
 {
     $operationConfig = $operation->toArray();
     if (!isset($operationConfig['responseDataRoot'])) {
         throw new Exception\RuntimeException(sprintf('No response data root configured for operation "%s"', $operation->getName()));
     }
     return new static($event->getResponse(), $operationConfig['responseDataRoot']);
 }
 public function testOperationIsDataObject()
 {
     $description = new Description([]);
     $c = new Operation(array('name' => 'test', 'summary' => 'doc', 'notes' => 'notes', 'documentationUrl' => 'http://www.example.com', 'httpMethod' => 'POST', 'uri' => '/api/v1', 'responseModel' => 'abc', 'deprecated' => true, 'parameters' => array('key' => array('required' => true, 'type' => 'string', 'maxLength' => 10, 'name' => 'key'), 'key_2' => array('required' => true, 'type' => 'integer', 'default' => 10, 'name' => 'key_2'))), $description);
     $this->assertEquals('test', $c->getName());
     $this->assertEquals('doc', $c->getSummary());
     $this->assertEquals('http://www.example.com', $c->getDocumentationUrl());
     $this->assertEquals('POST', $c->getHttpMethod());
     $this->assertEquals('/api/v1', $c->getUri());
     $this->assertEquals('abc', $c->getResponseModel());
     $this->assertTrue($c->getDeprecated());
     $params = array_map(function ($c) {
         return $c->toArray();
     }, $c->getParams());
     $this->assertEquals(['key' => ['required' => true, 'type' => 'string', 'maxLength' => 10, 'name' => 'key'], 'key_2' => ['required' => true, 'type' => 'integer', 'default' => 10, 'name' => 'key_2']], $params);
     $this->assertEquals(['required' => true, 'type' => 'integer', 'default' => 10, 'name' => 'key_2'], $c->getParam('key_2')->toArray());
     $this->assertNull($c->getParam('afefwef'));
     $this->assertArrayNotHasKey('parent', $c->getParam('key_2')->toArray());
 }
示例#3
0
 public function getName()
 {
     return $this->operation->getName();
 }