/** * Build service description from remote docs. * @return ServiceDescription */ public function testServiceBuild() { $builder = new Swizzle('pets', 'Swagger Pet store'); //$builder->verbose( STDERR ); $builder->registerCommandClass('', '\\Loco\\Utils\\Swizzle\\Command\\StrictCommand'); $builder->setBaseUrl('http://petstore.swagger.wordnik.com/api'); $builder->build('http://petstore.swagger.wordnik.com/api/api-docs'); //die( $builder->toJson() ); $service = $builder->getServiceDescription(); $this->assertCount(6, $service->getModels()); $this->assertCount(20, $service->getOperations()); return $service; }
/** * Test an operation that responds with an array of primatives * @depends testServiceConstruct */ public function testDynamicArrayResponse(Swizzle $builder) { $api = array('path' => '/test/type_ints', 'operations' => array(array('type' => 'array', 'items' => array('type' => 'integer')))); $builder->addApi($api); $descr = $builder->getServiceDescription(); $op = $descr->getOperation('get_test_type_ints'); // anonymous model should have been created on the fly // $this->assertEquals( 'model', $op->getResponseType() ); // $this->assertEquals( 'anon_type_integer_array', $op->getResponseClass() ); // root array modelling disabled - will be unvalidated primitive $this->assertEquals('primitive', $op->getResponseType()); $this->assertEquals('array', $op->getResponseClass()); }