mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 02:55:19 +00:00
[Slim] Add Basic authentication middleware (#606)
* [Slim] Add Basic Authentication Middleware User needs to add own implementation to verifyCredentials method in AuthBasic.php. * [Slim] Update README template I'm not sure about `middlewareSrcPath` variable. I'll fix it in following PRs if path is broken. Hope that notice in README catches attention and most of users will read it. * Revert "[Slim] Update README template" This reverts commit 204ee02fd853feb3cc19db5658348c7fee6ca3f5. * Revert "[Slim] Add Basic Authentication Middleware" This reverts commit 6a8e03079a70213797896e660b7e7fa1894da0a6. * [Slim] Add "tuupola/slim-basic-auth" package Package "tuupola/slim-basic-auth" 3.1.0 requires PHP 7, that's why I set it's version to ^3.0.0 in Composer. Minimum version will be 3.0.0-rc.1 which supports PHP 5.5. I've tested build with PHP 7, it would be nice to check build with PHP 5.5 someday. * [Slim] Update README template Not sure about forward slash in path to SlimRouter class. I will fix it in upcoming PRs if necessary. * [Slim] Refresh samples
This commit is contained in:
parent
f793ac25c7
commit
58e0946b1e
@ -7,4 +7,16 @@ is an example of building a PHP Slim server.
|
||||
|
||||
This example uses the [Slim Framework](http://www.slimframework.com/). To see how to make this your own, please take a look at the template here:
|
||||
|
||||
[TEMPLATES](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/slim/)
|
||||
[TEMPLATES](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/php-slim-server/)
|
||||
|
||||
{{#authMethods}}
|
||||
{{^hasMore}}
|
||||
## Authentication
|
||||
{{/hasMore}}
|
||||
{{/authMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
> Important! To make Basic Authentication work you need to implement `authenticator` function in [SlimRouter]({{srcBasePath}}/SlimRouter.php) class.
|
||||
> Documentation [tuupola/slim-basic-auth](https://github.com/tuupola/slim-basic-auth)
|
||||
{{/isBasic}}
|
||||
{{/authMethods}}
|
||||
|
@ -39,6 +39,7 @@ use {{apiPackage}}\{{classname}};
|
||||
use Slim\App;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Tuupola\Middleware\HttpBasicAuthentication;
|
||||
|
||||
/**
|
||||
* SlimRouter Class Doc Comment
|
||||
@ -66,10 +67,29 @@ class SlimRouter {
|
||||
public function __construct($container = []) {
|
||||
$app = new App($container);
|
||||
|
||||
$basicAuth = new HttpBasicAuthentication([
|
||||
"secure" => false,
|
||||
"authenticator" => function ($arguments) {
|
||||
$user = $arguments["user"];
|
||||
$password = $arguments["password"];
|
||||
return false;
|
||||
}
|
||||
]);
|
||||
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
$app->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', {{classname}}::class . ':{{operationId}}');
|
||||
$app->{{httpMethod}}(
|
||||
'{{{basePathWithoutHost}}}{{{path}}}', {{classname}}::class . ':{{operationId}}'
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
)->add(
|
||||
$basicAuth
|
||||
{{/isBasic}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
);
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
|
@ -2,7 +2,8 @@
|
||||
"minimum-stability": "RC",
|
||||
"require": {
|
||||
"php": ">=5.5",
|
||||
"slim/slim": "3.*"
|
||||
"slim/slim": "3.*",
|
||||
"tuupola/slim-basic-auth": "^3.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8"
|
||||
|
@ -1 +1 @@
|
||||
3.1.1-SNAPSHOT
|
||||
3.1.2-SNAPSHOT
|
@ -7,4 +7,6 @@ is an example of building a PHP Slim server.
|
||||
|
||||
This example uses the [Slim Framework](http://www.slimframework.com/). To see how to make this your own, please take a look at the template here:
|
||||
|
||||
[TEMPLATES](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/slim/)
|
||||
[TEMPLATES](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/php-slim-server/)
|
||||
|
||||
## Authentication
|
||||
|
@ -2,7 +2,8 @@
|
||||
"minimum-stability": "RC",
|
||||
"require": {
|
||||
"php": ">=5.5",
|
||||
"slim/slim": "3.*"
|
||||
"slim/slim": "3.*",
|
||||
"tuupola/slim-basic-auth": "^3.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8"
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* OpenAPI Petstore ' \" =end -- \\r\\n \\n \\r
|
||||
* @version 1.0.0 ' \" =end -- \\r\\n \\n \\r
|
||||
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* @version 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
@ -11,11 +11,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore ' \" =end -- \\r\\n \\n \\r
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
@ -11,11 +11,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore ' \" =end -- \\r\\n \\n \\r
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
|
||||
@ -42,7 +42,7 @@ class FakeApi extends AbstractApiController {
|
||||
|
||||
/**
|
||||
* PUT testCodeInjectEndRnNR
|
||||
* Summary: To test code injection ' \" =end -- \\r\\n \\n \\r
|
||||
* Summary: To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Notes:
|
||||
*
|
||||
* @param \Psr\Http\Message\ServerRequestInterface $request Request
|
||||
|
@ -9,7 +9,7 @@ namespace OpenAPIServer\Model;
|
||||
*/
|
||||
class ModelReturn {
|
||||
|
||||
/** @var int $return property description ' \" =end -- \\r\\n \\n \\r*/
|
||||
/** @var int $return property description *_/ ' \" =end -- \\r\\n \\n \\r*/
|
||||
private $return;
|
||||
|
||||
}
|
||||
|
@ -11,11 +11,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore ' \" =end -- \\r\\n \\n \\r
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
|
||||
@ -30,6 +30,7 @@ use OpenAPIServer\Api\FakeApi;
|
||||
use Slim\App;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Tuupola\Middleware\HttpBasicAuthentication;
|
||||
|
||||
/**
|
||||
* SlimRouter Class Doc Comment
|
||||
@ -57,7 +58,18 @@ class SlimRouter {
|
||||
public function __construct($container = []) {
|
||||
$app = new App($container);
|
||||
|
||||
$app->PUT('/ ' \" =end -- \\r\\n \\n \\r/v2 ' \" =end -- \\r\\n \\n \\r/fake', FakeApi::class . ':testCodeInjectEndRnNR');
|
||||
$basicAuth = new HttpBasicAuthentication([
|
||||
"secure" => false,
|
||||
"authenticator" => function ($arguments) {
|
||||
$user = $arguments["user"];
|
||||
$password = $arguments["password"];
|
||||
return false;
|
||||
}
|
||||
]);
|
||||
|
||||
$app->PUT(
|
||||
'/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r/fake', FakeApi::class . ':testCodeInjectEndRnNR'
|
||||
);
|
||||
|
||||
$this->slimApp = $app;
|
||||
}
|
||||
|
@ -11,16 +11,16 @@
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Apis">
|
||||
<directory>.\test\Api</directory>
|
||||
<directory>./test/Api</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Models">
|
||||
<directory>.\test\Model</directory>
|
||||
<directory>./test/Model</directory>
|
||||
</testsuite>
|
||||
</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>
|
@ -10,11 +10,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore ' \" =end -- \\r\\n \\n \\r
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
|
||||
@ -70,7 +70,7 @@ class FakeApiTest extends \PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* Test case for testCodeInjectEndRnNR
|
||||
*
|
||||
* To test code injection ' \" =end -- \\r\\n \\n \\r.
|
||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r.
|
||||
* @covers ::testCodeInjectEndRnNR
|
||||
*/
|
||||
public function testTestCodeInjectEndRnNR() {
|
||||
|
@ -10,11 +10,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore ' \" =end -- \\r\\n \\n \\r
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
|
||||
@ -31,7 +31,7 @@ use OpenAPIServer\Model\ModelReturn;
|
||||
* ModelReturnTest Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @description Model for testing reserved words ' \" =end -- \\r\\n \\n \\r
|
||||
* @description Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* @package OpenAPIServer\Model
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
|
@ -7,4 +7,8 @@ is an example of building a PHP Slim server.
|
||||
|
||||
This example uses the [Slim Framework](http://www.slimframework.com/). To see how to make this your own, please take a look at the template here:
|
||||
|
||||
[TEMPLATES](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/slim/)
|
||||
[TEMPLATES](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/php-slim-server/)
|
||||
|
||||
## Authentication
|
||||
> Important! To make Basic Authentication work you need to implement `authenticator` function in [SlimRouter](lib/SlimRouter.php) class.
|
||||
> Documentation [tuupola/slim-basic-auth](https://github.com/tuupola/slim-basic-auth)
|
||||
|
@ -2,7 +2,8 @@
|
||||
"minimum-stability": "RC",
|
||||
"require": {
|
||||
"php": ">=5.5",
|
||||
"slim/slim": "3.*"
|
||||
"slim/slim": "3.*",
|
||||
"tuupola/slim-basic-auth": "^3.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8"
|
||||
|
323
samples/server/petstore/php-slim/composer.lock
generated
323
samples/server/petstore/php-slim/composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "dd09324f4c42e91ef9a7865e277effe6",
|
||||
"content-hash": "7abeaa62669cac171aa0692df2e1943b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "container-interop/container-interop",
|
||||
@ -37,6 +37,58 @@
|
||||
"homepage": "https://github.com/container-interop/container-interop",
|
||||
"time": "2017-02-14T19:40:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "http-interop/http-factory",
|
||||
"version": "0.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/http-interop/http-factory.git",
|
||||
"reference": "c2587cc0a6f74987fefb5b8074acfd32c69a4b0f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/http-interop/http-factory/zipball/c2587cc0a6f74987fefb5b8074acfd32c69a4b0f",
|
||||
"reference": "c2587cc0a6f74987fefb5b8074acfd32c69a4b0f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Interop\\Http\\Factory\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP message factories",
|
||||
"keywords": [
|
||||
"factory",
|
||||
"http",
|
||||
"message",
|
||||
"psr",
|
||||
"psr-17",
|
||||
"psr-7",
|
||||
"request",
|
||||
"response"
|
||||
],
|
||||
"time": "2017-03-24T14:48:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/fast-route",
|
||||
"version": "v1.3.0",
|
||||
@ -232,6 +284,112 @@
|
||||
],
|
||||
"time": "2016-08-06T14:39:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-server-handler",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-server-handler.git",
|
||||
"reference": "439d92054dc06097f2406ec074a2627839955a02"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/439d92054dc06097f2406ec074a2627839955a02",
|
||||
"reference": "439d92054dc06097f2406ec074a2627839955a02",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Http\\Server\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP server-side request handler",
|
||||
"keywords": [
|
||||
"handler",
|
||||
"http",
|
||||
"http-interop",
|
||||
"psr",
|
||||
"psr-15",
|
||||
"psr-7",
|
||||
"request",
|
||||
"response",
|
||||
"server"
|
||||
],
|
||||
"time": "2018-01-22T17:04:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-server-middleware",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-server-middleware.git",
|
||||
"reference": "ea17eb1fb2c8df6db919cc578451a8013c6a0ae5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/ea17eb1fb2c8df6db919cc578451a8013c6a0ae5",
|
||||
"reference": "ea17eb1fb2c8df6db919cc578451a8013c6a0ae5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/http-server-handler": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Http\\Server\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP server-side middleware",
|
||||
"keywords": [
|
||||
"http",
|
||||
"http-interop",
|
||||
"middleware",
|
||||
"psr",
|
||||
"psr-15",
|
||||
"psr-7",
|
||||
"request",
|
||||
"response"
|
||||
],
|
||||
"time": "2018-01-22T17:08:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "slim/slim",
|
||||
"version": "3.10.0",
|
||||
@ -302,6 +460,167 @@
|
||||
"router"
|
||||
],
|
||||
"time": "2018-04-19T19:29:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tuupola/callable-handler",
|
||||
"version": "0.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tuupola/callable-handler.git",
|
||||
"reference": "5141efa1e974687a3fa53338811a988198f50662"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tuupola/callable-handler/zipball/5141efa1e974687a3fa53338811a988198f50662",
|
||||
"reference": "5141efa1e974687a3fa53338811a988198f50662",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.0",
|
||||
"psr/http-server-middleware": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"codedungeon/phpunit-result-printer": "^0.4.4",
|
||||
"overtrue/phplint": "^1.0",
|
||||
"phpunit/phpunit": "^6.5",
|
||||
"squizlabs/php_codesniffer": "^3.2",
|
||||
"tuupola/http-factory": "^0.3.0",
|
||||
"zendframework/zend-diactoros": "^1.6"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Tuupola\\Middleware\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mika Tuupola",
|
||||
"email": "tuupola@appelsiini.net",
|
||||
"homepage": "https://appelsiini.net/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Compatibility layer for PSR-7 double pass and PSR-15 middlewares.",
|
||||
"homepage": "https://github.com/tuupola/callable-handler",
|
||||
"keywords": [
|
||||
"middleware",
|
||||
"psr-15",
|
||||
"psr-7"
|
||||
],
|
||||
"time": "2018-01-23T04:07:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tuupola/http-factory",
|
||||
"version": "0.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tuupola/http-factory.git",
|
||||
"reference": "57b2e19ff3f4af0bbee4e31fd282689be351f1ad"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tuupola/http-factory/zipball/57b2e19ff3f4af0bbee4e31fd282689be351f1ad",
|
||||
"reference": "57b2e19ff3f4af0bbee4e31fd282689be351f1ad",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"http-interop/http-factory": "^0.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"http-interop/http-factory-tests": "^0.3.0",
|
||||
"overtrue/phplint": "^0.2.1",
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"squizlabs/php_codesniffer": "^3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Tuupola\\Http\\Factory\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mika Tuupola",
|
||||
"email": "tuupola@appelsiini.net",
|
||||
"homepage": "http://www.appelsiini.net/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Lightweight autodiscovering PSR-17 HTTP factories",
|
||||
"homepage": "https://github.com/tuupola/http-factory",
|
||||
"keywords": [
|
||||
"http",
|
||||
"psr-17",
|
||||
"psr-7"
|
||||
],
|
||||
"time": "2017-07-15T22:03:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tuupola/slim-basic-auth",
|
||||
"version": "3.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tuupola/slim-basic-auth.git",
|
||||
"reference": "b169fba3113059548e3a2ac4096b1b08616b070e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tuupola/slim-basic-auth/zipball/b169fba3113059548e3a2ac4096b1b08616b070e",
|
||||
"reference": "b169fba3113059548e3a2ac4096b1b08616b070e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"http-interop/http-factory": "^0.3.0",
|
||||
"php": "^7.1",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/http-server-middleware": "^1.0",
|
||||
"tuupola/callable-handler": "^0.3.0",
|
||||
"tuupola/http-factory": "^0.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"codedungeon/phpunit-result-printer": "^0.6.0",
|
||||
"equip/dispatch": "^2.0",
|
||||
"overtrue/phplint": "^0.2.4",
|
||||
"phpstan/phpstan": "^0.9.2",
|
||||
"phpunit/phpunit": "^7.0",
|
||||
"squizlabs/php_codesniffer": "^3.2",
|
||||
"zendframework/zend-diactoros": "^1.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Tuupola\\Middleware\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mika Tuupola",
|
||||
"email": "tuupola@appelsiini.net",
|
||||
"homepage": "https://appelsiini.net/"
|
||||
}
|
||||
],
|
||||
"description": "PSR-7 and PSR-15 HTTP Basic Authentication Middleware",
|
||||
"homepage": "https://appelsiini.net/projects/slim-basic-auth",
|
||||
"keywords": [
|
||||
"auth",
|
||||
"middleware",
|
||||
"psr-15",
|
||||
"psr-7"
|
||||
],
|
||||
"time": "2018-05-06T05:41:44+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
@ -1379,7 +1698,7 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v3.4.12",
|
||||
"version": "v3.4.13",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
|
@ -34,6 +34,7 @@ use OpenAPIServer\Api\UserApi;
|
||||
use Slim\App;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Tuupola\Middleware\HttpBasicAuthentication;
|
||||
|
||||
/**
|
||||
* SlimRouter Class Doc Comment
|
||||
@ -61,40 +62,119 @@ class SlimRouter {
|
||||
public function __construct($container = []) {
|
||||
$app = new App($container);
|
||||
|
||||
$app->PATCH('/v2/another-fake/dummy', AnotherFakeApi::class . ':testSpecialTags');
|
||||
$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');
|
||||
$app->GET('/v2/fake', FakeApi::class . ':testEnumParameters');
|
||||
$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');
|
||||
$basicAuth = new HttpBasicAuthentication([
|
||||
"secure" => false,
|
||||
"authenticator" => function ($arguments) {
|
||||
$user = $arguments["user"];
|
||||
$password = $arguments["password"];
|
||||
return false;
|
||||
}
|
||||
]);
|
||||
|
||||
$app->PATCH(
|
||||
'/v2/another-fake/dummy', AnotherFakeApi::class . ':testSpecialTags'
|
||||
);
|
||||
$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->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'
|
||||
);
|
||||
|
||||
$this->slimApp = $app;
|
||||
}
|
||||
|
@ -19,8 +19,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>
|
@ -139,7 +139,7 @@ class FakeApiTest extends \PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
* Test case for testEndpointParameters
|
||||
*
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 .
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트.
|
||||
* @covers ::testEndpointParameters
|
||||
*/
|
||||
public function testTestEndpointParameters() {
|
||||
|
Loading…
Reference in New Issue
Block a user