예제 #1
0
 /**
  * Build service description from remote docs.
  * @return ServiceDescription
  */
 public function testServiceBuild()
 {
     $builder = new Swizzle('pets', 'Swagger Pet store');
     //$builder->verbose( STDERR );
     $builder->registerCommandClass('', '\\Loco\\Utils\\Swizzle\\Command\\StrictCommand');
     $builder->setBaseUrl('http://petstore.swagger.wordnik.com/api');
     $builder->build('http://petstore.swagger.wordnik.com/api/api-docs');
     //die( $builder->toJson() );
     $service = $builder->getServiceDescription();
     $this->assertCount(6, $service->getModels());
     $this->assertCount(20, $service->getOperations());
     return $service;
 }
예제 #2
0
#!/usr/bin/env php
<?php 
/**
 * Swizzle example.
 * Pulls down the Official Swagger example API and outputs the Guzzle service description.
 * @see http://petstore.swagger.wordnik.com/
 */
// All we need is the Swizzle class.
require __DIR__ . '/../vendor/autoload.php';
use Loco\Utils\Swizzle\Swizzle;
// Intialize service with name and description
$builder = new Swizzle('pets', 'Swagger Pet Store');
// show progress messages in output
$builder->verbose(STDERR);
// Now we're ready to build from a live endpoint
// This must be a Valid Swagger JSON resource listing.
$builder->build('http://petstore.swagger.wordnik.com/api/api-docs');
// export service description to JSON:
echo $builder->toJson();
예제 #3
0
파일: loco.php 프로젝트: rodsouto/swizzle
#!/usr/bin/env php
<?php 
/**
 * Swizzle example.
 * Pulls down the Loco API and outputs the Guzzle service description.
 */
// All we need is the Swizzle class.
require __DIR__ . '/../vendor/autoload.php';
use Loco\Utils\Swizzle\Swizzle;
// Intialize service with name and description
$builder = new Swizzle('loco', 'Loco REST API');
// show progress messages in output
$builder->verbose(STDERR);
// Register custom Guzzle response classes - such things are meaningless to Swagger.
// These classes don't have have to exist in this runtime, they just go into the service definition.
$builder->registerResponseClass('exportArchive', '\\Loco\\Http\\Response\\ZipResponse');
// Register custom Guzzle command class to use instead of default OperationCommand
// Passing empty command name, so it is used for all.
$builder->registerCommandClass('', '\\Loco\\Http\\LocoCommand');
// Now we're ready to build from a live endpoint
// This must be a Valid Swagger JSON resource listing.
$builder->build('https://localise.biz/api/swagger');
// export service description to PHP source:
echo $builder->export();