Beispiel #1
0
    public function testSerialize()
    {
        $info = new InfoObject();
        $info->setTitle('Swagger Sample App');
        $info->setDescription('This is a sample server Petstore server');
        $info->setTermsOfServiceUrl('http://helloreverb.com/terms/');
        $info->setContact('*****@*****.**');
        $info->setLicense('Apache 2.0');
        $info->setLicenseUrl('http://www.apache.org/licenses/LICENSE-2.0.html');
        $content = <<<JSON
{
  "title": "Swagger Sample App",
  "description": "This is a sample server Petstore server",
  "termsOfServiceUrl": "http://helloreverb.com/terms/",
  "contact": "*****@*****.**",
  "license": "Apache 2.0",
  "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
JSON;
        $this->assertRecordEqualsContent($info, $content);
    }
Beispiel #2
0
    public function testSerialize()
    {
        $info = new InfoObject();
        $info->setTitle('Swagger Sample App');
        $info->setDescription('This is a sample server Petstore server');
        $info->setTermsOfServiceUrl('http://helloreverb.com/terms/');
        $info->setContact('*****@*****.**');
        $info->setLicense('Apache 2.0');
        $info->setLicenseUrl('http://www.apache.org/licenses/LICENSE-2.0.html');
        $resourceListing = new ResourceListing('1.0');
        $resourceListing->setInfo($info);
        $resourceListing->addResource(new ResourceObject('/foo', 'Foobar'));
        $resourceListing->addResource(new ResourceObject('/bar', 'Barfoo'));
        $content = <<<JSON
{
  "swaggerVersion": "1.2",
  "apiVersion": "1.0",
  "info": {
    "title": "Swagger Sample App",
    "description": "This is a sample server Petstore server",
    "termsOfServiceUrl": "http://helloreverb.com/terms/",
    "contact": "*****@*****.**",
    "license": "Apache 2.0",
    "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.html"
  },
  "apis": [{
    "path": "/foo",
    "description": "Foobar"
  },{
    "path": "/bar",
    "description": "Barfoo"
  }]
}
JSON;
        $this->assertRecordEqualsContent($resourceListing, $content);
    }