示例#1
0
 public function testExternalDocs()
 {
     $filename = __DIR__ . '/fixtures/petstore-with-external-docs.json';
     $swagger = Swagger::fromFile($filename);
     $this->assertEquals($this->fileToArray($filename), $swagger->toArray());
     $external = $swagger->getExternalDocs();
     $this->assertEquals('find more info here', $external->getDescription());
     $this->assertEquals('https://swagger.io/about', $external->getUrl());
     $info = $swagger->getInfo();
     $this->assertEquals('1.0.0', $info->getVersion());
     $this->assertEquals('Swagger Petstore', $info->getTitle());
     $this->assertEquals('A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification', $info->getDescription());
     $this->assertEquals('http://swagger.io/terms/', $info->getTerms());
     $this->assertEquals('1.0.1', $info->setVersion('1.0.1')->getVersion());
     $this->assertEquals('Pets', $info->setTitle('Pets')->getTitle());
     $this->assertEquals('desc', $info->setDescription('desc')->getDescription());
     $this->assertEquals('T-O-S', $info->setTerms('T-O-S')->getTerms());
     $contact = $info->getContact();
     $this->assertEquals('Swagger API Team', $contact->getName());
     $this->assertEquals('*****@*****.**', $contact->getEmail());
     $this->assertEquals('http://swagger.io', $contact->getUrl());
     $this->assertEquals('Swaggers', $contact->setName('Swaggers')->getName());
     $this->assertEquals('*****@*****.**', $contact->setEmail('*****@*****.**')->getEmail());
     $this->assertEquals('https://swagger.io', $contact->setUrl('https://swagger.io')->getUrl());
     $license = $info->getLicense();
     $this->assertEquals('MIT', $license->getName());
     $this->assertEquals('http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT', $license->getUrl());
     $this->assertEquals('APL', $license->setName('APL')->getName());
     $this->assertEquals('https://www.apache.org/licenses/LICENSE-2.0', $license->setUrl('https://www.apache.org/licenses/LICENSE-2.0')->getUrl());
 }
示例#2
0
 public function testSecurityDefinitions()
 {
     $filename = __DIR__ . '/fixtures/security-definitions.json';
     $swagger = Swagger::fromFile($filename);
     $this->assertEquals($this->fileToArray($filename), $swagger->toArray());
     $definitions = $swagger->getSecurityDefinitions();
     $oauth = $definitions->get('OauthSecurity');
     $this->assertEquals('oauth2', $oauth->getType());
     $this->assertEquals('accessCode', $oauth->getFlow());
     $this->assertEquals('https://oauth.simple.api/authorization', $oauth->getAuthorizationUrl());
     $this->assertEquals('https://oauth.simple.api/token', $oauth->getTokenUrl());
     $this->assertEquals(['admin' => 'Admin scope', 'user' => 'User scope'], $oauth->getScopes()->toArray());
     $this->assertTrue($definitions->has('MediaSecurity'));
     $this->assertTrue($definitions->has('LegacySecurity'));
     $definitions->remove('LegacySecurity');
     $this->assertFalse($definitions->has('LegacySecurity'));
 }
示例#3
0
 public function testUser()
 {
     $filename = __DIR__ . '/fixtures/keeko-user.json';
     $swagger = Swagger::fromFile($filename);
     $this->assertEquals($this->fileToArray($filename), $swagger->toArray());
 }