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()); }
/** * Create a request for an operation with a uri merged onto a base URI */ private function createCommandWithUri(Operation $operation, CommandInterface $command, ServiceClientInterface $client) { // Get the path values and use the client config settings $variables = []; foreach ($operation->getParams() as $name => $arg) { /* @var Parameter $arg */ if ($arg->getLocation() == 'uri') { if (isset($command[$name])) { $variables[$name] = $arg->filter($command[$name]); if (!is_array($variables[$name])) { $variables[$name] = (string) $variables[$name]; } } } } // Expand the URI template. $uri = Utils::uriTemplate($operation->getUri(), $variables); return $client->getHttpClient()->createRequest($operation->getHttpMethod(), $this->description->getBaseUrl()->combine($uri), $command['request_options'] ?: []); }