Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,9 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist"));
supportingFiles.add(new SupportingFile("phpcs.xml.mustache", "", "phpcs.xml.dist"));

// Slim 4 doesn't parse JSON body anymore we need to add suggested middleware
// ref: https://www.slimframework.com/docs/v4/objects/request.html#the-request-body
supportingFiles.add(new SupportingFile("htaccess_deny_all", "config", ".htaccess"));
supportingFiles.add(new SupportingFile("config_example.mustache", "config" + File.separator + "dev", "example.inc.php"));
supportingFiles.add(new SupportingFile("config_example.mustache", "config" + File.separator + "prod", "example.inc.php"));
supportingFiles.add(new SupportingFile("json_body_parser_middleware.mustache", toSrcPath(invokerPackage + "\\Middleware", srcBasePath), "JsonBodyParserMiddleware.php"));
supportingFiles.add(new SupportingFile("base_model.mustache", toSrcPath(invokerPackage, srcBasePath), "BaseModel.php"));
supportingFiles.add(new SupportingFile("base_model_test.mustache", toSrcPath(invokerPackage, testBasePath), "BaseModelTest.php"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use InvalidArgumentException;
use Dyorg\TokenAuthentication;
use Dyorg\TokenAuthentication\TokenSearch;
use Psr\Http\Message\ServerRequestInterface;
use {{invokerPackage}}\Middleware\JsonBodyParserMiddleware;
use OpenAPIServer\Mock\OpenApiDataMocker;
use OpenAPIServer\Mock\OpenApiDataMockerRouteMiddleware;
{{#isSlimPsr7}}
Expand Down Expand Up @@ -185,7 +184,7 @@ class SlimRouter
$message = "How about extending {$operation['classname']} by {$operation['apiPackage']}\\{$operation['userClassname']} class implementing {$operation['operationId']} as a {$operation['httpMethod']} method?";
throw new HttpNotImplementedException($request, $message);
};
$middlewares = [new JsonBodyParserMiddleware()];
$middlewares = [];

if (class_exists("\\{$operation['apiPackage']}\\{$operation['userClassname']}")) {
$callback = "\\{$operation['apiPackage']}\\{$operation['userClassname']}:{$operation['operationId']}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ if (is_array($prodConfig = @include(__DIR__ . '/../config/prod/config.inc.php'))
$router = new SlimRouter($config);
$app = $router->getSlimApp();

// Parse json, form data and xml
$app->addBodyParsingMiddleware();

/**
* The routing middleware should be added before the ErrorMiddleware
* Otherwise exceptions thrown from it will not be handled
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion samples/server/petstore/php-slim4/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ lib/Api/AbstractStoreApi.php
lib/Api/AbstractUserApi.php
lib/Auth/AbstractAuthenticator.php
lib/BaseModel.php
lib/Middleware/JsonBodyParserMiddleware.php
lib/Model/ApiResponse.php
lib/Model/Category.php
lib/Model/Order.php
Expand Down
3 changes: 1 addition & 2 deletions samples/server/petstore/php-slim4/lib/SlimRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use Dyorg\TokenAuthentication;
use Dyorg\TokenAuthentication\TokenSearch;
use Psr\Http\Message\ServerRequestInterface;
use OpenAPIServer\Middleware\JsonBodyParserMiddleware;
use OpenAPIServer\Mock\OpenApiDataMocker;
use OpenAPIServer\Mock\OpenApiDataMockerRouteMiddleware;
use Slim\Psr7\Factory\ResponseFactory;
Expand Down Expand Up @@ -890,7 +889,7 @@ public function __construct($settings = [])
$message = "How about extending {$operation['classname']} by {$operation['apiPackage']}\\{$operation['userClassname']} class implementing {$operation['operationId']} as a {$operation['httpMethod']} method?";
throw new HttpNotImplementedException($request, $message);
};
$middlewares = [new JsonBodyParserMiddleware()];
$middlewares = [];

if (class_exists("\\{$operation['apiPackage']}\\{$operation['userClassname']}")) {
$callback = "\\{$operation['apiPackage']}\\{$operation['userClassname']}:{$operation['operationId']}";
Expand Down
3 changes: 3 additions & 0 deletions samples/server/petstore/php-slim4/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
$router = new SlimRouter($config);
$app = $router->getSlimApp();

// Parse json, form data and xml
$app->addBodyParsingMiddleware();

/**
* The routing middleware should be added before the ErrorMiddleware
* Otherwise exceptions thrown from it will not be handled
Expand Down