public function doIndex() { $resourceListing = new ResourceListing('1.0'); $resources = $this->resourceListing->getResourceIndex(); foreach ($resources as $resource) { $path = '/*'; $path .= ApiGeneration::transformRoutePlaceholder($resource->getPath()); $resourceListing->addResource(new ResourceObject($path)); } $this->setBody($resourceListing, WriterInterface::JSON); }
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); }