* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class OpenAPITest extends GeneratorTestCase { public function testGenerate() { $reader = new SimpleAnnotationReader(); $reader->addNamespace('PSX\\Schema\\Annotation'); $generator = new OpenAPI($reader, 1, 'http://api.phpsx.org', 'http://foo.phpsx.org'); $actual = $generator->generate($this->getSpecification()); $expect = file_get_contents(__DIR__ . '/resource/openapi.json'); $this->assertJsonStringEqualsJsonString($expect, $actual, $actual); } public function testGenerateAll() { $reader = new SimpleAnnotationReader(); $reader->addNamespace('PSX\\Schema\\Annotation'); $generator = new OpenAPI($reader, 1, 'http://api.phpsx.org', 'http://foo.phpsx.org'); $actual = $generator->generate($this->getSpecificationCollection()); $expect = file_get_contents(__DIR__ . '/resource/openapi_collection.json'); $this->assertJsonStringEqualsJsonString($expect, $actual, $actual); } public function testGenerateComplex() { $reader = new SimpleAnnotationReader(); $reader->addNamespace('PSX\\Schema\\Annotation'); $generator = new OpenAPI($reader, 1, 'http://api.phpsx.org', 'http://foo.phpsx.org'); $generator->setTitle('Sample Pet Store App'); $generator->setDescription('This is a sample server for a pet store.'); $generator->setTermsOfService('http://example.com/terms/'); $generator->setContactName('API Support'); $generator->setContactUrl('http://www.example.com/support'); $generator->setContactEmail('support@example.com'); $generator->setLicenseName('Apache 2.0'); $generator->setLicenseUrl('https://www.apache.org/licenses/LICENSE-2.0.html'); $generator->setAuthorizationFlow('OAuth2', OpenAPI::FLOW_AUTHORIZATION_CODE, 'http://api.phpsx.org/authorization', 'http://api.phpsx.org/token', null, ['foo' => 'Foo sope', 'bar' => 'Bar scope']); $generator->addTag('foo', 'Foo tag'); $generator->addTag('bar', 'Boo tag'); $actual = $generator->generate($this->getSpecificationComplex()); $expect = file_get_contents(__DIR__ . '/resource/openapi_complex.json'); $this->assertJsonStringEqualsJsonString($expect, $actual, $actual); } } __halt_compiler();----SIGNATURE:----WepiAX+278fNTdF1n1yEd0uPfyg9UH52F9QqrI6AYDG2hWa5Dm0EB1OtAhyX1A0colUPfWARR4gwKZuM1so/LZRITZeQhtkAiu3BNChAnTHd3a6ZQ709xcVfE6epOwZFQil/0vvHhzsvHkn12m16bVn7GibKmhDJZGW0vX3mzotcrGGiTVjXWKlXOSGoxH2EEUnrYdndNqb91QXSCXeemVIo9fZ/LTGIrbXsUVMSRG8DrU0ZVInImNHA6wJF8O+vJEouFRwsVoi4s+fvfaNZhVJBDcts53XnbNS668kR2SA0AuYtEGx0Urz0EvT9GZ1IJZGUse8kwzlBgW2jdc7+UdIgoVt0lKFXpaU9RVNCvCw28Zb9x+yeMUH7/LHF3ZMgGeGNr0vzufJw2seo4k8fX+5q4pgO4E7kvYaY0adg+S4QvTFym0PF1D0aHPGCyApIQHWkO3JsIdE9StEPSry56TxjHicxSXUi14WCgSLv15XI3Sxo/hPfy8Yo4f2YJENVggUmrto7WC9bWPyx5lxI4BgNSvxsUEQk14HpzAIkXVseC/0ZALUQrv7qHcAz7uVs80NOjWBFOvcB82Exd3b5uEg5/JkhZGENQF30Nm8/J0QS/QrHoKuiwcDdH/othMI/GjT+1q/WbtTP2G6dZSr6Sww8owdSTGxLT2fCKOdZi+8=----ATTACHMENT:----NDg5OTIxODY5NjUxODEzNiA3MDgxNzA1ODEzNzMzNjA5IDEwMzU0MTkyMDk2MjE2MDE=