* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class OpenRPCTest extends TestCase { public function testModel() { $license = new License(); $license->setName('MIT'); $info = new Info(); $info->setVersion('1.0.0'); $info->setTitle('Petstore'); $info->setLicense($license); $server = new Server(); $server->setUrl('http://localhost:8080'); $tag = new Tag(); $tag->setName('pets'); $params = []; $content = new ContentDescriptor(); $content->setName('limit'); $content->setDescription('How many items to return at one time (max 100)'); $content->setRequired(false); $content->setSchema((object) ['type' => 'integer', 'minimum' => 1]); $params[] = $content; $result = new ContentDescriptor(); $result->setName('pets'); $result->setDescription('A paged array of pets'); $result->setSchema((object) ['$ref' => '#/components/schemas/Pets']); $errors = []; $error = new Error(); $error->setCode(100); $error->setMessage('pets busy'); $errors[] = $error; $examples = []; $paramExample = new ExampleObject(); $paramExample->setName('limit'); $paramExample->setValue(1); $resultExample = new ExampleObject(); $resultExample->setName('listPetResultExample'); $resultExample->setValue([ (object) [ 'id' => 7, 'name' => 'fluffy', 'tag' => 'poodle', ] ]); $example = new ExamplePairingObject(); $example->setName('listPetExample'); $example->setDescription('List pet example'); $example->setParams([$paramExample]); $example->setResult($resultExample); $examples[] = $example; $methods = []; $method = new Method(); $method->setName('list_pets'); $method->setSummary('List all pets'); $method->setTags([$tag]); $method->setParams($params); $method->setResult($result); $method->setErrors($errors); $method->setExamples($examples); $methods[] = $method; $components = new Components(); $openRPC = new OpenRPC(); $openRPC->setInfo($info); $openRPC->setServers([$server]); $openRPC->setMethods($methods); $openRPC->setComponents($components); $dumper = new Dumper(); $actual = json_encode($dumper->dump($openRPC), JSON_PRETTY_PRINT); $expect = file_get_contents(__DIR__ . '/resources/openrpc.json'); $this->assertJsonStringEqualsJsonString($expect, $actual, $actual); } } __halt_compiler();----SIGNATURE:----lGwCj/GB2r2boaQh5o55mNBaGJHI5ilu7/X89x8U1UGHX3qhgPRPVfPDyXoCqaJBPiRPP+GqLlMZZGkyeYigMzNQc9MWyb1jW/6n7WLttvFdOpBj2wUBWY9VS/ZOkmroR2KNGS8Y+oMdzU8hCw8KK88XT8Ywf5Ix+UTU4GBWozr+0G2Dubqb0dK/XaQZK+z7WDpSJ0W7xhEnGG0q0X1XvhfqGed0AnS/mTb2MvlxHcV+S3fVt+l/ypNgWCe118s23SCFh3nTMlY3oz9KNw1+Epl66M32KbokfBSvaYDwQ3UeGImube8KrAqNAMGoRcqn7wEMtGgajOYVjBj81I1a8A/yzZkNjy6VCRpNfH1K0a9x9nNZAcPfsHQFGk5QxVIUVzrmjhnFJij8gVJLW8B9WDZHUhXM1uDwQ5g1TASGTnOK8ErFmG7QV4Kmo1gR91iIrv5OH/VOJa1Zo02Sm5W6YuhYWpitDqQQ5MTqQaNqX3lnz2uit9kgLoEYHaS29U8T9oD01F2n1SilopOmgxJZv2RY0/igIlCPFcMsvzju8YK4ElHx1EvB2QmPQgVp5mCNejaE0nsRX0q21unmzQcjb2fx6bLYi8OHH66Lgx62wQcuXQ1Nkto7wwHLhz3s/VKzhkzqP8+dZppC9oV0PbubgxKD5x8LDSKTB7c2SUcnFo0=----ATTACHMENT:----OTIyMjgzNjY2NDMzNjIzMSA0ODY5MTcyMjcxNDM0MTI3IDEwNjIwNDE0OTIyNzE0MzM=