forked from loafle/openapi-generator-original
[Slim] Abstract API controllers (#1483)
* [Slim] Add abstract prefix to API controllers * [Slim] Add userClassname property to codegen * [Slim] Add src folder to Composer autoload * [Slim] Change template to produce abstract controllers * [Slim] Update API tests template * [Slim] Add implementation note * [Slim] Remove deprecated AbstractApiController * [Slim] Refresh samples
This commit is contained in:
parent
f1831533d4
commit
72dcee9d86
@ -36,6 +36,7 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class);
|
||||
|
||||
public static final String PHPCS_STANDARD = "phpcsStandard";
|
||||
public static final String USER_CLASSNAME_KEY = "userClassname";
|
||||
|
||||
protected String groupId = "org.openapitools";
|
||||
protected String artifactId = "openapi-server";
|
||||
@ -125,7 +126,6 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json"));
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "", "index.php"));
|
||||
supportingFiles.add(new SupportingFile(".htaccess", "", ".htaccess"));
|
||||
supportingFiles.add(new SupportingFile("AbstractApiController.mustache", toSrcPath(invokerPackage, srcBasePath), toAbstractName("ApiController") + ".php"));
|
||||
supportingFiles.add(new SupportingFile("SlimRouter.mustache", toSrcPath(invokerPackage, srcBasePath), "SlimRouter.php"));
|
||||
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist"));
|
||||
}
|
||||
@ -134,6 +134,7 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
addUserClassnameToOperations(operations);
|
||||
escapeMediaType(operationList);
|
||||
return objs;
|
||||
}
|
||||
@ -160,8 +161,41 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
return objs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets PHP CodeSniffer <standard> option. Accepts name or path of the coding standard to use.
|
||||
*
|
||||
* @param phpcsStandard standard option value
|
||||
*/
|
||||
public void setPhpcsStandard(String phpcsStandard) {
|
||||
this.phpcsStandard = phpcsStandard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return toAbstractName("DefaultApi");
|
||||
}
|
||||
return toAbstractName(initialCaps(name) + "Api");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApiTest";
|
||||
}
|
||||
return initialCaps(name) + "ApiTest";
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips out abstract prefix and suffix from classname and puts it in "userClassname" property of operations object.
|
||||
*
|
||||
* @param operations codegen object with operations
|
||||
*/
|
||||
private void addUserClassnameToOperations(Map<String, Object> operations) {
|
||||
String classname = (String) operations.get("classname");
|
||||
classname = classname.replaceAll("^" + abstractNamePrefix, "");
|
||||
classname = classname.replaceAll(abstractNameSuffix + "$", "");
|
||||
operations.put(USER_CLASSNAME_KEY, classname);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Abstract Api Controller
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
|
||||
/**
|
||||
{{#appName}}
|
||||
* {{{appName}}}
|
||||
*
|
||||
{{/appName}}
|
||||
{{#appDescription}}
|
||||
* {{{appDescription}}}
|
||||
{{/appDescription}}
|
||||
{{#version}}
|
||||
* OpenAPI spec version: {{{version}}}
|
||||
{{/version}}
|
||||
{{#infoEmail}}
|
||||
* Contact: {{{infoEmail}}}
|
||||
{{/infoEmail}}
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the openapi generator program.
|
||||
* https://github.com/openapitools/openapi-generator
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
namespace {{invokerPackage}};
|
||||
|
||||
/**
|
||||
* ApiServer Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
abstract class {{abstractNamePrefix}}ApiController{{abstractNameSuffix}}
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
@ -44,12 +44,41 @@ Command | Tool | Target
|
||||
`$ composer run phpcs` | PHP CodeSniffer | All files
|
||||
`$ composer run phplint` | phplint | All files
|
||||
|
||||
## Show errors
|
||||
|
||||
Change line in `./index.php`:
|
||||
```diff
|
||||
--- $router = new SlimRouter();
|
||||
+++ $router = new SlimRouter(['settings' => ['displayErrorDetails' => true]]);
|
||||
```
|
||||
|
||||
{{#generateApiDocs}}
|
||||
## API Endpoints
|
||||
|
||||
All URIs are relative to *{{{basePath}}}*
|
||||
|
||||
> Important! Do not modify abstract API controllers directly! Instead extend them by implementation classes like:
|
||||
|
||||
```php
|
||||
// src/Api/PetApi.php
|
||||
|
||||
namespace {{apiPackage}};
|
||||
|
||||
use {{apiPackage}}\AbstractPetApi;
|
||||
|
||||
class PetApi extends AbstractPetApi
|
||||
{
|
||||
|
||||
public function addPet($request, $response, $args)
|
||||
{
|
||||
// your implementation of addPet method here
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Place all your implementation classes in `./src` folder accordingly.
|
||||
For instance, when abstract class located at `./lib/Api/AbstractPetApi.php` you need to create implementation class at `./src/Api/PetApi.php`.
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | **{{operationId}}** | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}}
|
||||
|
@ -33,9 +33,6 @@
|
||||
*/
|
||||
namespace {{invokerPackage}};
|
||||
|
||||
{{#apis}}
|
||||
use {{apiPackage}}\{{classname}};
|
||||
{{/apis}}
|
||||
use Slim\App;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use InvalidArgumentException;
|
||||
@ -47,7 +44,7 @@ use Tuupola\Middleware\HttpBasicAuthentication;
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package {{apiPackage}}
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
@ -59,6 +56,37 @@ class SlimRouter
|
||||
*/
|
||||
private $slimApp;
|
||||
|
||||
/** @var array[] list of all api operations */
|
||||
private $operations = [
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
[
|
||||
'httpMethod' => '{{httpMethod}}',
|
||||
'basePathWithoutHost' => '{{{basePathWithoutHost}}}',
|
||||
'path' => '{{path}}',
|
||||
'apiPackage' => '{{apiPackage}}',
|
||||
'classname' => '{{classname}}',
|
||||
'userClassname' => '{{userClassname}}',
|
||||
'operationId' => '{{operationId}}',
|
||||
'authMethods' => [
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
[
|
||||
'type' => '{{type}}',
|
||||
'isBasic' => true,
|
||||
],
|
||||
{{/isBasic}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
],
|
||||
],
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
];
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
@ -67,7 +95,7 @@ class SlimRouter
|
||||
*/
|
||||
public function __construct($container = [])
|
||||
{
|
||||
$app = new App($container);
|
||||
$this->slimApp = new App($container);
|
||||
|
||||
$basicAuth = new HttpBasicAuthentication([
|
||||
"secure" => false,
|
||||
@ -78,26 +106,53 @@ class SlimRouter
|
||||
}
|
||||
]);
|
||||
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
$app->{{httpMethod}}(
|
||||
'{{{basePathWithoutHost}}}{{{path}}}',
|
||||
{{classname}}::class . ':{{operationId}}'
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
)->add(
|
||||
$basicAuth
|
||||
{{/isBasic}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
);
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
foreach ($this->operations as $operation) {
|
||||
$callback = function ($request, $response, $arguments) use ($operation) {
|
||||
$message = "How about extending {$operation['classname']} by {$operation['apiPackage']}\\{$operation['userClassname']} class implementing {$operation['operationId']} as a {$operation['httpMethod']} method?";
|
||||
throw new \Exception($message);
|
||||
return $response->withStatus(501)->write($message);
|
||||
};
|
||||
$middlewares = [];
|
||||
|
||||
$this->slimApp = $app;
|
||||
if (class_exists("\\{$operation['apiPackage']}\\{$operation['userClassname']}")) {
|
||||
$callback = "\\{$operation['apiPackage']}\\{$operation['userClassname']}:{$operation['operationId']}";
|
||||
}
|
||||
|
||||
|
||||
foreach ($operation['authMethods'] as $authMethod) {
|
||||
if ($authMethod['type'] === 'http') {
|
||||
$middlewares[] = $basicAuth;
|
||||
}
|
||||
}
|
||||
|
||||
$this->addRoute(
|
||||
[$operation['httpMethod']],
|
||||
"{$operation['basePathWithoutHost']}{$operation['path']}",
|
||||
$callback,
|
||||
$middlewares
|
||||
)->setName($operation['operationId']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add route with multiple methods
|
||||
*
|
||||
* @param string[] $methods Numeric array of HTTP method names
|
||||
* @param string $pattern The route URI pattern
|
||||
* @param callable|string $callable The route callback routine
|
||||
* @param array|null $middlewares List of middlewares
|
||||
*
|
||||
* @return Slim\Interfaces\RouteInterface
|
||||
*
|
||||
* @throws InvalidArgumentException if the route pattern isn't a string
|
||||
*/
|
||||
public function addRoute($methods, $pattern, $callable, $middlewares = [])
|
||||
{
|
||||
$route = $this->slimApp->map($methods, $pattern, $callable);
|
||||
foreach ($middlewares as $middleware) {
|
||||
$route->add($middleware);
|
||||
}
|
||||
return $route;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,8 +34,6 @@
|
||||
*/
|
||||
namespace {{apiPackage}};
|
||||
|
||||
use {{invokerPackage}}\{{abstractNamePrefix}}ApiController{{abstractNameSuffix}};
|
||||
|
||||
/**
|
||||
* {{classname}} Class Doc Comment
|
||||
*
|
||||
@ -46,8 +44,24 @@ use {{invokerPackage}}\{{abstractNamePrefix}}ApiController{{abstractNameSuffix}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
class {{classname}} extends {{abstractNamePrefix}}ApiController{{abstractNameSuffix}}
|
||||
abstract class {{classname}}
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
|
||||
@ -66,6 +80,8 @@ class {{classname}} extends {{abstractNamePrefix}}ApiController{{abstractNameSuf
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function {{operationId}}($request, $response, $args)
|
||||
{
|
||||
@ -99,8 +115,10 @@ class {{classname}} extends {{abstractNamePrefix}}ApiController{{abstractNameSuf
|
||||
{{#hasBodyParam}}
|
||||
$body = $request->getParsedBody();
|
||||
{{/hasBodyParam}}
|
||||
$response->write('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
||||
return $response;
|
||||
$message = "How about implementing {{nickname}} as a {{httpMethod}} method in {{apiPackage}}\{{userClassname}} class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* {{classname}}Test
|
||||
{{#operations}}/**
|
||||
* {{userClassname}}Test
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
@ -34,19 +34,19 @@
|
||||
namespace {{apiPackage}};
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use {{apiPackage}}\{{classname}};
|
||||
use {{apiPackage}}\{{userClassname}};
|
||||
|
||||
/**
|
||||
* {{classname}}Test Class Doc Comment
|
||||
* {{userClassname}}Test Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @description {{#description}}{{description}}{{/description}}{{^description}}{{classname}}{{/description}}
|
||||
* @description {{#description}}{{description}}{{/description}}{{^description}}{{userClassname}}{{/description}}
|
||||
* @package {{apiPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \{{modelPackage}}\{{classname}}
|
||||
* @coversDefaultClass \{{apiPackage}}\{{userClassname}}
|
||||
*/
|
||||
{{#operations}}class {{classname}}Test extends TestCase
|
||||
class {{userClassname}}Test extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,10 @@
|
||||
"squizlabs/php_codesniffer": "^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "{{escapedInvokerPackage}}\\": "{{srcBasePath}}/" }
|
||||
"psr-4": { "{{escapedInvokerPackage}}\\": [
|
||||
"{{srcBasePath}}/",
|
||||
"src/"
|
||||
]}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "{{escapedInvokerPackage}}\\": "{{testBasePath}}/" }
|
||||
|
@ -44,14 +44,43 @@ Command | Tool | Target
|
||||
`$ composer run phpcs` | PHP CodeSniffer | All files
|
||||
`$ composer run phplint` | phplint | All files
|
||||
|
||||
## Show errors
|
||||
|
||||
Change line in `./index.php`:
|
||||
```diff
|
||||
--- $router = new SlimRouter();
|
||||
+++ $router = new SlimRouter(['settings' => ['displayErrorDetails' => true]]);
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r*
|
||||
|
||||
> Important! Do not modify abstract API controllers directly! Instead extend them by implementation classes like:
|
||||
|
||||
```php
|
||||
// src/Api/PetApi.php
|
||||
|
||||
namespace OpenAPIServer\Api;
|
||||
|
||||
use OpenAPIServer\Api\AbstractPetApi;
|
||||
|
||||
class PetApi extends AbstractPetApi
|
||||
{
|
||||
|
||||
public function addPet($request, $response, $args)
|
||||
{
|
||||
// your implementation of addPet method here
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Place all your implementation classes in `./src` folder accordingly.
|
||||
For instance, when abstract class located at `./lib/Api/AbstractPetApi.php` you need to create implementation class at `./src/Api/PetApi.php`.
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*FakeApi* | **testCodeInjectEndRnNR** | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*AbstractFakeApi* | **testCodeInjectEndRnNR** | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
|
||||
|
||||
## Models
|
||||
|
@ -11,7 +11,10 @@
|
||||
"squizlabs/php_codesniffer": "^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "OpenAPIServer\\": "lib/" }
|
||||
"psr-4": { "OpenAPIServer\\": [
|
||||
"lib/",
|
||||
"src/"
|
||||
]}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "OpenAPIServer\\": "test/" }
|
||||
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Abstract Api Controller
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPIServer
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the openapi generator program.
|
||||
* https://github.com/openapitools/openapi-generator
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
namespace OpenAPIServer;
|
||||
|
||||
/**
|
||||
* ApiServer Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPIServer
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
abstract class AbstractApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* FakeApi
|
||||
* AbstractFakeApi
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -26,10 +26,8 @@
|
||||
*/
|
||||
namespace OpenAPIServer\Api;
|
||||
|
||||
use OpenAPIServer\AbstractApiController;
|
||||
|
||||
/**
|
||||
* FakeApi Class Doc Comment
|
||||
* AbstractFakeApi Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -38,9 +36,25 @@ use OpenAPIServer\AbstractApiController;
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
class FakeApi extends AbstractApiController
|
||||
abstract class AbstractFakeApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PUT testCodeInjectEndRnNR
|
||||
* Summary: To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
@ -49,11 +63,15 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testCodeInjectEndRnNR($request, $response, $args)
|
||||
{
|
||||
$testCodeInjectEndRnNR = $request->getParsedBodyParam('test code inject */ ' " =end -- \r\n \n \r');
|
||||
$response->write('How about implementing testCodeInjectEndRnNR as a PUT method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testCodeInjectEndRnNR as a PUT method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
}
|
@ -26,7 +26,6 @@
|
||||
*/
|
||||
namespace OpenAPIServer;
|
||||
|
||||
use OpenAPIServer\Api\FakeApi;
|
||||
use Slim\App;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use InvalidArgumentException;
|
||||
@ -38,7 +37,7 @@ use Tuupola\Middleware\HttpBasicAuthentication;
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPIServer\Api
|
||||
* @package OpenAPIServer
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
@ -50,6 +49,21 @@ class SlimRouter
|
||||
*/
|
||||
private $slimApp;
|
||||
|
||||
/** @var array[] list of all api operations */
|
||||
private $operations = [
|
||||
[
|
||||
'httpMethod' => 'PUT',
|
||||
'basePathWithoutHost' => '/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r',
|
||||
'path' => '/fake',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'testCodeInjectEndRnNR',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
@ -58,7 +72,7 @@ class SlimRouter
|
||||
*/
|
||||
public function __construct($container = [])
|
||||
{
|
||||
$app = new App($container);
|
||||
$this->slimApp = new App($container);
|
||||
|
||||
$basicAuth = new HttpBasicAuthentication([
|
||||
"secure" => false,
|
||||
@ -69,12 +83,53 @@ class SlimRouter
|
||||
}
|
||||
]);
|
||||
|
||||
$app->PUT(
|
||||
'/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r/fake',
|
||||
FakeApi::class . ':testCodeInjectEndRnNR'
|
||||
);
|
||||
foreach ($this->operations as $operation) {
|
||||
$callback = function ($request, $response, $arguments) use ($operation) {
|
||||
$message = "How about extending {$operation['classname']} by {$operation['apiPackage']}\\{$operation['userClassname']} class implementing {$operation['operationId']} as a {$operation['httpMethod']} method?";
|
||||
throw new \Exception($message);
|
||||
return $response->withStatus(501)->write($message);
|
||||
};
|
||||
$middlewares = [];
|
||||
|
||||
$this->slimApp = $app;
|
||||
if (class_exists("\\{$operation['apiPackage']}\\{$operation['userClassname']}")) {
|
||||
$callback = "\\{$operation['apiPackage']}\\{$operation['userClassname']}:{$operation['operationId']}";
|
||||
}
|
||||
|
||||
|
||||
foreach ($operation['authMethods'] as $authMethod) {
|
||||
if ($authMethod['type'] === 'http') {
|
||||
$middlewares[] = $basicAuth;
|
||||
}
|
||||
}
|
||||
|
||||
$this->addRoute(
|
||||
[$operation['httpMethod']],
|
||||
"{$operation['basePathWithoutHost']}{$operation['path']}",
|
||||
$callback,
|
||||
$middlewares
|
||||
)->setName($operation['operationId']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add route with multiple methods
|
||||
*
|
||||
* @param string[] $methods Numeric array of HTTP method names
|
||||
* @param string $pattern The route URI pattern
|
||||
* @param callable|string $callable The route callback routine
|
||||
* @param array|null $middlewares List of middlewares
|
||||
*
|
||||
* @return Slim\Interfaces\RouteInterface
|
||||
*
|
||||
* @throws InvalidArgumentException if the route pattern isn't a string
|
||||
*/
|
||||
public function addRoute($methods, $pattern, $callable, $middlewares = [])
|
||||
{
|
||||
$route = $this->slimApp->map($methods, $pattern, $callable);
|
||||
foreach ($middlewares as $middleware) {
|
||||
$route->add($middleware);
|
||||
}
|
||||
return $route;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,8 +20,8 @@
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./lib//Api</directory>
|
||||
<directory suffix=".php">./lib//Model</directory>
|
||||
<directory suffix=".php">./lib/Api</directory>
|
||||
<directory suffix=".php">./lib/Model</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
@ -36,7 +36,7 @@ use OpenAPIServer\Api\FakeApi;
|
||||
* @package OpenAPIServer\Api
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPIServer\Model\FakeApi
|
||||
* @coversDefaultClass \OpenAPIServer\Api\FakeApi
|
||||
*/
|
||||
class FakeApiTest extends TestCase
|
||||
{
|
||||
|
@ -44,48 +44,77 @@ Command | Tool | Target
|
||||
`$ composer run phpcs` | PHP CodeSniffer | All files
|
||||
`$ composer run phplint` | phplint | All files
|
||||
|
||||
## Show errors
|
||||
|
||||
Change line in `./index.php`:
|
||||
```diff
|
||||
--- $router = new SlimRouter();
|
||||
+++ $router = new SlimRouter(['settings' => ['displayErrorDetails' => true]]);
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
> Important! Do not modify abstract API controllers directly! Instead extend them by implementation classes like:
|
||||
|
||||
```php
|
||||
// src/Api/PetApi.php
|
||||
|
||||
namespace OpenAPIServer\Api;
|
||||
|
||||
use OpenAPIServer\Api\AbstractPetApi;
|
||||
|
||||
class PetApi extends AbstractPetApi
|
||||
{
|
||||
|
||||
public function addPet($request, $response, $args)
|
||||
{
|
||||
// your implementation of addPet method here
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Place all your implementation classes in `./src` folder accordingly.
|
||||
For instance, when abstract class located at `./lib/Api/AbstractPetApi.php` you need to create implementation class at `./src/Api/PetApi.php`.
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeApi* | **call123TestSpecialTags** | **PATCH** /another-fake/dummy | To test special tags
|
||||
*FakeApi* | **fakeOuterBooleanSerialize** | **POST** /fake/outer/boolean |
|
||||
*FakeApi* | **fakeOuterCompositeSerialize** | **POST** /fake/outer/composite |
|
||||
*FakeApi* | **fakeOuterNumberSerialize** | **POST** /fake/outer/number |
|
||||
*FakeApi* | **fakeOuterStringSerialize** | **POST** /fake/outer/string |
|
||||
*FakeApi* | **testBodyWithFileSchema** | **PUT** /fake/body-with-file-schema |
|
||||
*FakeApi* | **testBodyWithQueryParams** | **PUT** /fake/body-with-query-params |
|
||||
*FakeApi* | **testClientModel** | **PATCH** /fake | To test \"client\" model
|
||||
*FakeApi* | **testEndpointParameters** | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*FakeApi* | **testEnumParameters** | **GET** /fake | To test enum parameters
|
||||
*FakeApi* | **testGroupParameters** | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
*FakeApi* | **testInlineAdditionalProperties** | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
*FakeApi* | **testJsonFormData** | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*FakeClassnameTags123Api* | **testClassname** | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
*PetApi* | **addPet** | **POST** /pet | Add a new pet to the store
|
||||
*PetApi* | **findPetsByStatus** | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PetApi* | **findPetsByTags** | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PetApi* | **updatePet** | **PUT** /pet | Update an existing pet
|
||||
*PetApi* | **deletePet** | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PetApi* | **getPetById** | **GET** /pet/{petId} | Find pet by ID
|
||||
*PetApi* | **updatePetWithForm** | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PetApi* | **uploadFile** | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*PetApi* | **uploadFileWithRequiredFile** | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
*StoreApi* | **getInventory** | **GET** /store/inventory | Returns pet inventories by status
|
||||
*StoreApi* | **placeOrder** | **POST** /store/order | Place an order for a pet
|
||||
*StoreApi* | **deleteOrder** | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
*StoreApi* | **getOrderById** | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
*UserApi* | **createUser** | **POST** /user | Create user
|
||||
*UserApi* | **createUsersWithArrayInput** | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*UserApi* | **createUsersWithListInput** | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*UserApi* | **loginUser** | **GET** /user/login | Logs user into the system
|
||||
*UserApi* | **logoutUser** | **GET** /user/logout | Logs out current logged in user session
|
||||
*UserApi* | **deleteUser** | **DELETE** /user/{username} | Delete user
|
||||
*UserApi* | **getUserByName** | **GET** /user/{username} | Get user by user name
|
||||
*UserApi* | **updateUser** | **PUT** /user/{username} | Updated user
|
||||
*AbstractAnotherFakeApi* | **call123TestSpecialTags** | **PATCH** /another-fake/dummy | To test special tags
|
||||
*AbstractFakeApi* | **fakeOuterBooleanSerialize** | **POST** /fake/outer/boolean |
|
||||
*AbstractFakeApi* | **fakeOuterCompositeSerialize** | **POST** /fake/outer/composite |
|
||||
*AbstractFakeApi* | **fakeOuterNumberSerialize** | **POST** /fake/outer/number |
|
||||
*AbstractFakeApi* | **fakeOuterStringSerialize** | **POST** /fake/outer/string |
|
||||
*AbstractFakeApi* | **testBodyWithFileSchema** | **PUT** /fake/body-with-file-schema |
|
||||
*AbstractFakeApi* | **testBodyWithQueryParams** | **PUT** /fake/body-with-query-params |
|
||||
*AbstractFakeApi* | **testClientModel** | **PATCH** /fake | To test \"client\" model
|
||||
*AbstractFakeApi* | **testEndpointParameters** | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*AbstractFakeApi* | **testEnumParameters** | **GET** /fake | To test enum parameters
|
||||
*AbstractFakeApi* | **testGroupParameters** | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
*AbstractFakeApi* | **testInlineAdditionalProperties** | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
*AbstractFakeApi* | **testJsonFormData** | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*AbstractFakeClassnameTags123Api* | **testClassname** | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
*AbstractPetApi* | **addPet** | **POST** /pet | Add a new pet to the store
|
||||
*AbstractPetApi* | **findPetsByStatus** | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*AbstractPetApi* | **findPetsByTags** | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*AbstractPetApi* | **updatePet** | **PUT** /pet | Update an existing pet
|
||||
*AbstractPetApi* | **deletePet** | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*AbstractPetApi* | **getPetById** | **GET** /pet/{petId} | Find pet by ID
|
||||
*AbstractPetApi* | **updatePetWithForm** | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*AbstractPetApi* | **uploadFile** | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*AbstractPetApi* | **uploadFileWithRequiredFile** | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
*AbstractStoreApi* | **getInventory** | **GET** /store/inventory | Returns pet inventories by status
|
||||
*AbstractStoreApi* | **placeOrder** | **POST** /store/order | Place an order for a pet
|
||||
*AbstractStoreApi* | **deleteOrder** | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
*AbstractStoreApi* | **getOrderById** | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
*AbstractUserApi* | **createUser** | **POST** /user | Create user
|
||||
*AbstractUserApi* | **createUsersWithArrayInput** | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*AbstractUserApi* | **createUsersWithListInput** | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*AbstractUserApi* | **loginUser** | **GET** /user/login | Logs user into the system
|
||||
*AbstractUserApi* | **logoutUser** | **GET** /user/logout | Logs out current logged in user session
|
||||
*AbstractUserApi* | **deleteUser** | **DELETE** /user/{username} | Delete user
|
||||
*AbstractUserApi* | **getUserByName** | **GET** /user/{username} | Get user by user name
|
||||
*AbstractUserApi* | **updateUser** | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
## Models
|
||||
|
@ -11,7 +11,10 @@
|
||||
"squizlabs/php_codesniffer": "^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "OpenAPIServer\\": "lib/" }
|
||||
"psr-4": { "OpenAPIServer\\": [
|
||||
"lib/",
|
||||
"src/"
|
||||
]}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "OpenAPIServer\\": "test/" }
|
||||
|
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Abstract Api Controller
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPIServer
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the openapi generator program.
|
||||
* https://github.com/openapitools/openapi-generator
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
namespace OpenAPIServer;
|
||||
|
||||
/**
|
||||
* ApiServer Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPIServer
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
abstract class AbstractApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* AnotherFakeApi
|
||||
* AbstractAnotherFakeApi
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -25,10 +25,8 @@
|
||||
*/
|
||||
namespace OpenAPIServer\Api;
|
||||
|
||||
use OpenAPIServer\AbstractApiController;
|
||||
|
||||
/**
|
||||
* AnotherFakeApi Class Doc Comment
|
||||
* AbstractAnotherFakeApi Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -37,9 +35,25 @@ use OpenAPIServer\AbstractApiController;
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
class AnotherFakeApi extends AbstractApiController
|
||||
abstract class AbstractAnotherFakeApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PATCH call123TestSpecialTags
|
||||
* Summary: To test special tags
|
||||
@ -49,11 +63,15 @@ class AnotherFakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function call123TestSpecialTags($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing call123TestSpecialTags as a PATCH method ?');
|
||||
return $response;
|
||||
$message = "How about implementing call123TestSpecialTags as a PATCH method in OpenAPIServer\Api\AnotherFakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* FakeApi
|
||||
* AbstractFakeApi
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -25,10 +25,8 @@
|
||||
*/
|
||||
namespace OpenAPIServer\Api;
|
||||
|
||||
use OpenAPIServer\AbstractApiController;
|
||||
|
||||
/**
|
||||
* FakeApi Class Doc Comment
|
||||
* AbstractFakeApi Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -37,9 +35,25 @@ use OpenAPIServer\AbstractApiController;
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
class FakeApi extends AbstractApiController
|
||||
abstract class AbstractFakeApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST fakeOuterBooleanSerialize
|
||||
* Notes: Test serialization of outer boolean types
|
||||
@ -48,12 +62,16 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function fakeOuterBooleanSerialize($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing fakeOuterBooleanSerialize as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing fakeOuterBooleanSerialize as a POST method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,12 +82,16 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function fakeOuterCompositeSerialize($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing fakeOuterCompositeSerialize as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing fakeOuterCompositeSerialize as a POST method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,12 +102,16 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function fakeOuterNumberSerialize($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing fakeOuterNumberSerialize as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing fakeOuterNumberSerialize as a POST method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,12 +122,16 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function fakeOuterStringSerialize($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing fakeOuterStringSerialize as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing fakeOuterStringSerialize as a POST method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,12 +141,16 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testBodyWithFileSchema($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing testBodyWithFileSchema as a PUT method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testBodyWithFileSchema as a PUT method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,14 +159,18 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testBodyWithQueryParams($request, $response, $args)
|
||||
{
|
||||
$queryParams = $request->getQueryParams();
|
||||
$query = $request->getQueryParam('query');
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing testBodyWithQueryParams as a PUT method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testBodyWithQueryParams as a PUT method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,12 +182,16 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testClientModel($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing testClientModel as a PATCH method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testClientModel as a PATCH method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,6 +202,8 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testEndpointParameters($request, $response, $args)
|
||||
{
|
||||
@ -177,8 +221,10 @@ class FakeApi extends AbstractApiController
|
||||
$dateTime = $request->getParsedBodyParam('dateTime');
|
||||
$password = $request->getParsedBodyParam('password');
|
||||
$callback = $request->getParsedBodyParam('callback');
|
||||
$response->write('How about implementing testEndpointParameters as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testEndpointParameters as a POST method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,6 +235,8 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testEnumParameters($request, $response, $args)
|
||||
{
|
||||
@ -202,8 +250,10 @@ class FakeApi extends AbstractApiController
|
||||
$enumQueryDouble = $request->getQueryParam('enum_query_double');
|
||||
$enumFormStringArray = $request->getParsedBodyParam('enum_form_string_array');
|
||||
$enumFormString = $request->getParsedBodyParam('enum_form_string');
|
||||
$response->write('How about implementing testEnumParameters as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testEnumParameters as a GET method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,6 +264,8 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testGroupParameters($request, $response, $args)
|
||||
{
|
||||
@ -225,8 +277,10 @@ class FakeApi extends AbstractApiController
|
||||
$requiredInt64Group = $request->getQueryParam('required_int64_group');
|
||||
$stringGroup = $request->getQueryParam('string_group');
|
||||
$int64Group = $request->getQueryParam('int64_group');
|
||||
$response->write('How about implementing testGroupParameters as a DELETE method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testGroupParameters as a DELETE method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,12 +290,16 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testInlineAdditionalProperties($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing testInlineAdditionalProperties as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testInlineAdditionalProperties as a POST method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,12 +309,16 @@ class FakeApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testJsonFormData($request, $response, $args)
|
||||
{
|
||||
$param = $request->getParsedBodyParam('param');
|
||||
$param2 = $request->getParsedBodyParam('param2');
|
||||
$response->write('How about implementing testJsonFormData as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testJsonFormData as a GET method in OpenAPIServer\Api\FakeApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* FakeClassnameTags123Api
|
||||
* AbstractFakeClassnameTags123Api
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -25,10 +25,8 @@
|
||||
*/
|
||||
namespace OpenAPIServer\Api;
|
||||
|
||||
use OpenAPIServer\AbstractApiController;
|
||||
|
||||
/**
|
||||
* FakeClassnameTags123Api Class Doc Comment
|
||||
* AbstractFakeClassnameTags123Api Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -37,9 +35,25 @@ use OpenAPIServer\AbstractApiController;
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
class FakeClassnameTags123Api extends AbstractApiController
|
||||
abstract class AbstractFakeClassnameTags123Api
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PATCH testClassname
|
||||
* Summary: To test class name in snake case
|
||||
@ -49,11 +63,15 @@ class FakeClassnameTags123Api extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function testClassname($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing testClassname as a PATCH method ?');
|
||||
return $response;
|
||||
$message = "How about implementing testClassname as a PATCH method in OpenAPIServer\Api\FakeClassnameTags123Api class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* PetApi
|
||||
* AbstractPetApi
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -25,10 +25,8 @@
|
||||
*/
|
||||
namespace OpenAPIServer\Api;
|
||||
|
||||
use OpenAPIServer\AbstractApiController;
|
||||
|
||||
/**
|
||||
* PetApi Class Doc Comment
|
||||
* AbstractPetApi Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -37,9 +35,25 @@ use OpenAPIServer\AbstractApiController;
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
class PetApi extends AbstractApiController
|
||||
abstract class AbstractPetApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST addPet
|
||||
* Summary: Add a new pet to the store
|
||||
@ -47,12 +61,16 @@ class PetApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function addPet($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing addPet as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing addPet as a POST method in OpenAPIServer\Api\PetApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,14 +80,18 @@ class PetApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function deletePet($request, $response, $args)
|
||||
{
|
||||
$headers = $request->getHeaders();
|
||||
$apiKey = $request->hasHeader('api_key') ? $headers['api_key'] : null;
|
||||
$petId = $args['petId'];
|
||||
$response->write('How about implementing deletePet as a DELETE method ?');
|
||||
return $response;
|
||||
$message = "How about implementing deletePet as a DELETE method in OpenAPIServer\Api\PetApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,13 +103,17 @@ class PetApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function findPetsByStatus($request, $response, $args)
|
||||
{
|
||||
$queryParams = $request->getQueryParams();
|
||||
$status = $request->getQueryParam('status');
|
||||
$response->write('How about implementing findPetsByStatus as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing findPetsByStatus as a GET method in OpenAPIServer\Api\PetApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,13 +125,17 @@ class PetApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function findPetsByTags($request, $response, $args)
|
||||
{
|
||||
$queryParams = $request->getQueryParams();
|
||||
$tags = $request->getQueryParam('tags');
|
||||
$response->write('How about implementing findPetsByTags as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing findPetsByTags as a GET method in OpenAPIServer\Api\PetApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,12 +147,16 @@ class PetApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function getPetById($request, $response, $args)
|
||||
{
|
||||
$petId = $args['petId'];
|
||||
$response->write('How about implementing getPetById as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing getPetById as a GET method in OpenAPIServer\Api\PetApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,12 +166,16 @@ class PetApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function updatePet($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing updatePet as a PUT method ?');
|
||||
return $response;
|
||||
$message = "How about implementing updatePet as a PUT method in OpenAPIServer\Api\PetApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,14 +185,18 @@ class PetApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function updatePetWithForm($request, $response, $args)
|
||||
{
|
||||
$petId = $args['petId'];
|
||||
$name = $request->getParsedBodyParam('name');
|
||||
$status = $request->getParsedBodyParam('status');
|
||||
$response->write('How about implementing updatePetWithForm as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing updatePetWithForm as a POST method in OpenAPIServer\Api\PetApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,14 +207,18 @@ class PetApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function uploadFile($request, $response, $args)
|
||||
{
|
||||
$petId = $args['petId'];
|
||||
$additionalMetadata = $request->getParsedBodyParam('additionalMetadata');
|
||||
$file = (key_exists('file', $request->getUploadedFiles())) ? $request->getUploadedFiles()['file'] : null;
|
||||
$response->write('How about implementing uploadFile as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing uploadFile as a POST method in OpenAPIServer\Api\PetApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,13 +229,17 @@ class PetApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function uploadFileWithRequiredFile($request, $response, $args)
|
||||
{
|
||||
$petId = $args['petId'];
|
||||
$additionalMetadata = $request->getParsedBodyParam('additionalMetadata');
|
||||
$requiredFile = (key_exists('requiredFile', $request->getUploadedFiles())) ? $request->getUploadedFiles()['requiredFile'] : null;
|
||||
$response->write('How about implementing uploadFileWithRequiredFile as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing uploadFileWithRequiredFile as a POST method in OpenAPIServer\Api\PetApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* StoreApi
|
||||
* AbstractStoreApi
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -25,10 +25,8 @@
|
||||
*/
|
||||
namespace OpenAPIServer\Api;
|
||||
|
||||
use OpenAPIServer\AbstractApiController;
|
||||
|
||||
/**
|
||||
* StoreApi Class Doc Comment
|
||||
* AbstractStoreApi Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -37,9 +35,25 @@ use OpenAPIServer\AbstractApiController;
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
class StoreApi extends AbstractApiController
|
||||
abstract class AbstractStoreApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DELETE deleteOrder
|
||||
* Summary: Delete purchase order by ID
|
||||
@ -48,12 +62,16 @@ class StoreApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function deleteOrder($request, $response, $args)
|
||||
{
|
||||
$orderId = $args['order_id'];
|
||||
$response->write('How about implementing deleteOrder as a DELETE method ?');
|
||||
return $response;
|
||||
$message = "How about implementing deleteOrder as a DELETE method in OpenAPIServer\Api\StoreApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,11 +83,15 @@ class StoreApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function getInventory($request, $response, $args)
|
||||
{
|
||||
$response->write('How about implementing getInventory as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing getInventory as a GET method in OpenAPIServer\Api\StoreApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,12 +103,16 @@ class StoreApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function getOrderById($request, $response, $args)
|
||||
{
|
||||
$orderId = $args['order_id'];
|
||||
$response->write('How about implementing getOrderById as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing getOrderById as a GET method in OpenAPIServer\Api\StoreApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,11 +123,15 @@ class StoreApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function placeOrder($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing placeOrder as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing placeOrder as a POST method in OpenAPIServer\Api\StoreApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* UserApi
|
||||
* AbstractUserApi
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -25,10 +25,8 @@
|
||||
*/
|
||||
namespace OpenAPIServer\Api;
|
||||
|
||||
use OpenAPIServer\AbstractApiController;
|
||||
|
||||
/**
|
||||
* UserApi Class Doc Comment
|
||||
* AbstractUserApi Class Doc Comment
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
@ -37,9 +35,25 @@ use OpenAPIServer\AbstractApiController;
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
class UserApi extends AbstractApiController
|
||||
abstract class AbstractUserApi
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Interop\Container\ContainerInterface Slim app container instance
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Route Controller constructor receives container
|
||||
*
|
||||
* @param \Interop\Container\ContainerInterface $container Slim app container instance
|
||||
*/
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST createUser
|
||||
* Summary: Create user
|
||||
@ -48,12 +62,16 @@ class UserApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function createUser($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing createUser as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing createUser as a POST method in OpenAPIServer\Api\UserApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,12 +81,16 @@ class UserApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function createUsersWithArrayInput($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing createUsersWithArrayInput as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing createUsersWithArrayInput as a POST method in OpenAPIServer\Api\UserApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,12 +100,16 @@ class UserApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function createUsersWithListInput($request, $response, $args)
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing createUsersWithListInput as a POST method ?');
|
||||
return $response;
|
||||
$message = "How about implementing createUsersWithListInput as a POST method in OpenAPIServer\Api\UserApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,12 +120,16 @@ class UserApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function deleteUser($request, $response, $args)
|
||||
{
|
||||
$username = $args['username'];
|
||||
$response->write('How about implementing deleteUser as a DELETE method ?');
|
||||
return $response;
|
||||
$message = "How about implementing deleteUser as a DELETE method in OpenAPIServer\Api\UserApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,12 +140,16 @@ class UserApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function getUserByName($request, $response, $args)
|
||||
{
|
||||
$username = $args['username'];
|
||||
$response->write('How about implementing getUserByName as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing getUserByName as a GET method in OpenAPIServer\Api\UserApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,14 +160,18 @@ class UserApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function loginUser($request, $response, $args)
|
||||
{
|
||||
$queryParams = $request->getQueryParams();
|
||||
$username = $request->getQueryParam('username');
|
||||
$password = $request->getQueryParam('password');
|
||||
$response->write('How about implementing loginUser as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing loginUser as a GET method in OpenAPIServer\Api\UserApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,11 +181,15 @@ class UserApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function logoutUser($request, $response, $args)
|
||||
{
|
||||
$response->write('How about implementing logoutUser as a GET method ?');
|
||||
return $response;
|
||||
$message = "How about implementing logoutUser as a GET method in OpenAPIServer\Api\UserApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,12 +200,16 @@ class UserApi extends AbstractApiController
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
* @param \Psr\Http\Message\ResponseInterface $response Response
|
||||
* @param array|null $args Path arguments
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function updateUser($request, $response, $args)
|
||||
{
|
||||
$username = $args['username'];
|
||||
$body = $request->getParsedBody();
|
||||
$response->write('How about implementing updateUser as a PUT method ?');
|
||||
return $response;
|
||||
$message = "How about implementing updateUser as a PUT method in OpenAPIServer\Api\UserApi class?";
|
||||
throw new \Exception($message);
|
||||
|
||||
return $response->write($message)->withStatus(501);
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* AnimalFarm
|
||||
*/
|
||||
namespace OpenAPIServer\Model;
|
||||
|
||||
/**
|
||||
* AnimalFarm
|
||||
*/
|
||||
class AnimalFarm
|
||||
{
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* StringBooleanMap
|
||||
*/
|
||||
namespace OpenAPIServer\Model;
|
||||
|
||||
/**
|
||||
* StringBooleanMap
|
||||
*/
|
||||
class StringBooleanMap
|
||||
{
|
||||
}
|
@ -25,12 +25,6 @@
|
||||
*/
|
||||
namespace OpenAPIServer;
|
||||
|
||||
use OpenAPIServer\Api\AnotherFakeApi;
|
||||
use OpenAPIServer\Api\FakeApi;
|
||||
use OpenAPIServer\Api\FakeClassnameTags123Api;
|
||||
use OpenAPIServer\Api\PetApi;
|
||||
use OpenAPIServer\Api\StoreApi;
|
||||
use OpenAPIServer\Api\UserApi;
|
||||
use Slim\App;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use InvalidArgumentException;
|
||||
@ -42,7 +36,7 @@ use Tuupola\Middleware\HttpBasicAuthentication;
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPIServer\Api
|
||||
* @package OpenAPIServer
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
@ -54,6 +48,399 @@ class SlimRouter
|
||||
*/
|
||||
private $slimApp;
|
||||
|
||||
/** @var array[] list of all api operations */
|
||||
private $operations = [
|
||||
[
|
||||
'httpMethod' => 'PATCH',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/another-fake/dummy',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractAnotherFakeApi',
|
||||
'userClassname' => 'AnotherFakeApi',
|
||||
'operationId' => 'call123TestSpecialTags',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake/outer/boolean',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'fakeOuterBooleanSerialize',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake/outer/composite',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'fakeOuterCompositeSerialize',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake/outer/number',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'fakeOuterNumberSerialize',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake/outer/string',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'fakeOuterStringSerialize',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'PUT',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake/body-with-file-schema',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'testBodyWithFileSchema',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'PUT',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake/body-with-query-params',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'testBodyWithQueryParams',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'PATCH',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'testClientModel',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'testEndpointParameters',
|
||||
'authMethods' => [
|
||||
[
|
||||
'type' => 'http',
|
||||
'isBasic' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'testEnumParameters',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'DELETE',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'testGroupParameters',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake/inline-additionalProperties',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'testInlineAdditionalProperties',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake/jsonFormData',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeApi',
|
||||
'userClassname' => 'FakeApi',
|
||||
'operationId' => 'testJsonFormData',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'PATCH',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake_classname_test',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractFakeClassnameTags123Api',
|
||||
'userClassname' => 'FakeClassnameTags123Api',
|
||||
'operationId' => 'testClassname',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/pet',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractPetApi',
|
||||
'userClassname' => 'PetApi',
|
||||
'operationId' => 'addPet',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/pet/findByStatus',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractPetApi',
|
||||
'userClassname' => 'PetApi',
|
||||
'operationId' => 'findPetsByStatus',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/pet/findByTags',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractPetApi',
|
||||
'userClassname' => 'PetApi',
|
||||
'operationId' => 'findPetsByTags',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'PUT',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/pet',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractPetApi',
|
||||
'userClassname' => 'PetApi',
|
||||
'operationId' => 'updatePet',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'DELETE',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/pet/{petId}',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractPetApi',
|
||||
'userClassname' => 'PetApi',
|
||||
'operationId' => 'deletePet',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/pet/{petId}',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractPetApi',
|
||||
'userClassname' => 'PetApi',
|
||||
'operationId' => 'getPetById',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/pet/{petId}',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractPetApi',
|
||||
'userClassname' => 'PetApi',
|
||||
'operationId' => 'updatePetWithForm',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/pet/{petId}/uploadImage',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractPetApi',
|
||||
'userClassname' => 'PetApi',
|
||||
'operationId' => 'uploadFile',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/fake/{petId}/uploadImageWithRequiredFile',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractPetApi',
|
||||
'userClassname' => 'PetApi',
|
||||
'operationId' => 'uploadFileWithRequiredFile',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/store/inventory',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractStoreApi',
|
||||
'userClassname' => 'StoreApi',
|
||||
'operationId' => 'getInventory',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/store/order',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractStoreApi',
|
||||
'userClassname' => 'StoreApi',
|
||||
'operationId' => 'placeOrder',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'DELETE',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/store/order/{order_id}',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractStoreApi',
|
||||
'userClassname' => 'StoreApi',
|
||||
'operationId' => 'deleteOrder',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/store/order/{order_id}',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractStoreApi',
|
||||
'userClassname' => 'StoreApi',
|
||||
'operationId' => 'getOrderById',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/user',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractUserApi',
|
||||
'userClassname' => 'UserApi',
|
||||
'operationId' => 'createUser',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/user/createWithArray',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractUserApi',
|
||||
'userClassname' => 'UserApi',
|
||||
'operationId' => 'createUsersWithArrayInput',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'POST',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/user/createWithList',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractUserApi',
|
||||
'userClassname' => 'UserApi',
|
||||
'operationId' => 'createUsersWithListInput',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/user/login',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractUserApi',
|
||||
'userClassname' => 'UserApi',
|
||||
'operationId' => 'loginUser',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/user/logout',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractUserApi',
|
||||
'userClassname' => 'UserApi',
|
||||
'operationId' => 'logoutUser',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'DELETE',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/user/{username}',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractUserApi',
|
||||
'userClassname' => 'UserApi',
|
||||
'operationId' => 'deleteUser',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'GET',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/user/{username}',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractUserApi',
|
||||
'userClassname' => 'UserApi',
|
||||
'operationId' => 'getUserByName',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
[
|
||||
'httpMethod' => 'PUT',
|
||||
'basePathWithoutHost' => '/v2',
|
||||
'path' => '/user/{username}',
|
||||
'apiPackage' => 'OpenAPIServer\Api',
|
||||
'classname' => 'AbstractUserApi',
|
||||
'userClassname' => 'UserApi',
|
||||
'operationId' => 'updateUser',
|
||||
'authMethods' => [
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
@ -62,7 +449,7 @@ class SlimRouter
|
||||
*/
|
||||
public function __construct($container = [])
|
||||
{
|
||||
$app = new App($container);
|
||||
$this->slimApp = new App($container);
|
||||
|
||||
$basicAuth = new HttpBasicAuthentication([
|
||||
"secure" => false,
|
||||
@ -73,150 +460,53 @@ class SlimRouter
|
||||
}
|
||||
]);
|
||||
|
||||
$app->PATCH(
|
||||
'/v2/another-fake/dummy',
|
||||
AnotherFakeApi::class . ':call123TestSpecialTags'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/outer/boolean',
|
||||
FakeApi::class . ':fakeOuterBooleanSerialize'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/outer/composite',
|
||||
FakeApi::class . ':fakeOuterCompositeSerialize'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/outer/number',
|
||||
FakeApi::class . ':fakeOuterNumberSerialize'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/outer/string',
|
||||
FakeApi::class . ':fakeOuterStringSerialize'
|
||||
);
|
||||
$app->PUT(
|
||||
'/v2/fake/body-with-file-schema',
|
||||
FakeApi::class . ':testBodyWithFileSchema'
|
||||
);
|
||||
$app->PUT(
|
||||
'/v2/fake/body-with-query-params',
|
||||
FakeApi::class . ':testBodyWithQueryParams'
|
||||
);
|
||||
$app->PATCH(
|
||||
'/v2/fake',
|
||||
FakeApi::class . ':testClientModel'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake',
|
||||
FakeApi::class . ':testEndpointParameters'
|
||||
)->add(
|
||||
$basicAuth
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/fake',
|
||||
FakeApi::class . ':testEnumParameters'
|
||||
);
|
||||
$app->DELETE(
|
||||
'/v2/fake',
|
||||
FakeApi::class . ':testGroupParameters'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/inline-additionalProperties',
|
||||
FakeApi::class . ':testInlineAdditionalProperties'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/fake/jsonFormData',
|
||||
FakeApi::class . ':testJsonFormData'
|
||||
);
|
||||
$app->PATCH(
|
||||
'/v2/fake_classname_test',
|
||||
FakeClassnameTags123Api::class . ':testClassname'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/pet',
|
||||
PetApi::class . ':addPet'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/pet/findByStatus',
|
||||
PetApi::class . ':findPetsByStatus'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/pet/findByTags',
|
||||
PetApi::class . ':findPetsByTags'
|
||||
);
|
||||
$app->PUT(
|
||||
'/v2/pet',
|
||||
PetApi::class . ':updatePet'
|
||||
);
|
||||
$app->DELETE(
|
||||
'/v2/pet/{petId}',
|
||||
PetApi::class . ':deletePet'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/pet/{petId}',
|
||||
PetApi::class . ':getPetById'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/pet/{petId}',
|
||||
PetApi::class . ':updatePetWithForm'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/pet/{petId}/uploadImage',
|
||||
PetApi::class . ':uploadFile'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/fake/{petId}/uploadImageWithRequiredFile',
|
||||
PetApi::class . ':uploadFileWithRequiredFile'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/store/inventory',
|
||||
StoreApi::class . ':getInventory'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/store/order',
|
||||
StoreApi::class . ':placeOrder'
|
||||
);
|
||||
$app->DELETE(
|
||||
'/v2/store/order/{order_id}',
|
||||
StoreApi::class . ':deleteOrder'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/store/order/{order_id}',
|
||||
StoreApi::class . ':getOrderById'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/user',
|
||||
UserApi::class . ':createUser'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/user/createWithArray',
|
||||
UserApi::class . ':createUsersWithArrayInput'
|
||||
);
|
||||
$app->POST(
|
||||
'/v2/user/createWithList',
|
||||
UserApi::class . ':createUsersWithListInput'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/user/login',
|
||||
UserApi::class . ':loginUser'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/user/logout',
|
||||
UserApi::class . ':logoutUser'
|
||||
);
|
||||
$app->DELETE(
|
||||
'/v2/user/{username}',
|
||||
UserApi::class . ':deleteUser'
|
||||
);
|
||||
$app->GET(
|
||||
'/v2/user/{username}',
|
||||
UserApi::class . ':getUserByName'
|
||||
);
|
||||
$app->PUT(
|
||||
'/v2/user/{username}',
|
||||
UserApi::class . ':updateUser'
|
||||
);
|
||||
foreach ($this->operations as $operation) {
|
||||
$callback = function ($request, $response, $arguments) use ($operation) {
|
||||
$message = "How about extending {$operation['classname']} by {$operation['apiPackage']}\\{$operation['userClassname']} class implementing {$operation['operationId']} as a {$operation['httpMethod']} method?";
|
||||
throw new \Exception($message);
|
||||
return $response->withStatus(501)->write($message);
|
||||
};
|
||||
$middlewares = [];
|
||||
|
||||
$this->slimApp = $app;
|
||||
if (class_exists("\\{$operation['apiPackage']}\\{$operation['userClassname']}")) {
|
||||
$callback = "\\{$operation['apiPackage']}\\{$operation['userClassname']}:{$operation['operationId']}";
|
||||
}
|
||||
|
||||
|
||||
foreach ($operation['authMethods'] as $authMethod) {
|
||||
if ($authMethod['type'] === 'http') {
|
||||
$middlewares[] = $basicAuth;
|
||||
}
|
||||
}
|
||||
|
||||
$this->addRoute(
|
||||
[$operation['httpMethod']],
|
||||
"{$operation['basePathWithoutHost']}{$operation['path']}",
|
||||
$callback,
|
||||
$middlewares
|
||||
)->setName($operation['operationId']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add route with multiple methods
|
||||
*
|
||||
* @param string[] $methods Numeric array of HTTP method names
|
||||
* @param string $pattern The route URI pattern
|
||||
* @param callable|string $callable The route callback routine
|
||||
* @param array|null $middlewares List of middlewares
|
||||
*
|
||||
* @return Slim\Interfaces\RouteInterface
|
||||
*
|
||||
* @throws InvalidArgumentException if the route pattern isn't a string
|
||||
*/
|
||||
public function addRoute($methods, $pattern, $callable, $middlewares = [])
|
||||
{
|
||||
$route = $this->slimApp->map($methods, $pattern, $callable);
|
||||
foreach ($middlewares as $middleware) {
|
||||
$route->add($middleware);
|
||||
}
|
||||
return $route;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ use OpenAPIServer\Api\AnotherFakeApi;
|
||||
* @package OpenAPIServer\Api
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPIServer\Model\AnotherFakeApi
|
||||
* @coversDefaultClass \OpenAPIServer\Api\AnotherFakeApi
|
||||
*/
|
||||
class AnotherFakeApiTest extends TestCase
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ use OpenAPIServer\Api\FakeApi;
|
||||
* @package OpenAPIServer\Api
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPIServer\Model\FakeApi
|
||||
* @coversDefaultClass \OpenAPIServer\Api\FakeApi
|
||||
*/
|
||||
class FakeApiTest extends TestCase
|
||||
{
|
||||
@ -158,6 +158,16 @@ class FakeApiTest extends TestCase
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for testGroupParameters
|
||||
*
|
||||
* Fake endpoint to test group parameters (optional).
|
||||
* @covers ::testGroupParameters
|
||||
*/
|
||||
public function testTestGroupParameters()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for testInlineAdditionalProperties
|
||||
*
|
||||
|
@ -35,7 +35,7 @@ use OpenAPIServer\Api\FakeClassnameTags123Api;
|
||||
* @package OpenAPIServer\Api
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPIServer\Model\FakeClassnameTags123Api
|
||||
* @coversDefaultClass \OpenAPIServer\Api\FakeClassnameTags123Api
|
||||
*/
|
||||
class FakeClassnameTags123ApiTest extends TestCase
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ use OpenAPIServer\Api\PetApi;
|
||||
* @package OpenAPIServer\Api
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPIServer\Model\PetApi
|
||||
* @coversDefaultClass \OpenAPIServer\Api\PetApi
|
||||
*/
|
||||
class PetApiTest extends TestCase
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ use OpenAPIServer\Api\StoreApi;
|
||||
* @package OpenAPIServer\Api
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPIServer\Model\StoreApi
|
||||
* @coversDefaultClass \OpenAPIServer\Api\StoreApi
|
||||
*/
|
||||
class StoreApiTest extends TestCase
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ use OpenAPIServer\Api\UserApi;
|
||||
* @package OpenAPIServer\Api
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPIServer\Model\UserApi
|
||||
* @coversDefaultClass \OpenAPIServer\Api\UserApi
|
||||
*/
|
||||
class UserApiTest extends TestCase
|
||||
{
|
||||
|
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* AnimalFarmTest
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPIServer\Model
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the openapi generator program.
|
||||
* https://github.com/openapitools/openapi-generator
|
||||
* Please update the test case below to test the model.
|
||||
*/
|
||||
namespace OpenAPIServer\Model;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OpenAPIServer\Model\AnimalFarm;
|
||||
|
||||
/**
|
||||
* AnimalFarmTest Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @description AnimalFarm
|
||||
* @package OpenAPIServer\Model
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPIServer\Model\AnimalFarm
|
||||
*/
|
||||
class AnimalFarmTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Setup before running any test cases
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup before running each test case
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up after running each test case
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up after running all test cases
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test "AnimalFarm"
|
||||
*/
|
||||
public function testAnimalFarm()
|
||||
{
|
||||
$testAnimalFarm = new AnimalFarm();
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* StringBooleanMapTest
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPIServer\Model
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by the openapi generator program.
|
||||
* https://github.com/openapitools/openapi-generator
|
||||
* Please update the test case below to test the model.
|
||||
*/
|
||||
namespace OpenAPIServer\Model;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OpenAPIServer\Model\StringBooleanMap;
|
||||
|
||||
/**
|
||||
* StringBooleanMapTest Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @description StringBooleanMap
|
||||
* @package OpenAPIServer\Model
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
* @coversDefaultClass \OpenAPIServer\Model\StringBooleanMap
|
||||
*/
|
||||
class StringBooleanMapTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Setup before running any test cases
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup before running each test case
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up after running each test case
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up after running all test cases
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test "StringBooleanMap"
|
||||
*/
|
||||
public function testStringBooleanMap()
|
||||
{
|
||||
$testStringBooleanMap = new StringBooleanMap();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user