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 @@ -35,6 +35,7 @@ namespace {{invokerPackage}};

use Slim\Factory\AppFactory;
use Slim\Interfaces\RouteInterface;
use Slim\Exception\HttpNotImplementedException;
use Psr\Container\ContainerInterface;
use InvalidArgumentException;
use Dyorg\TokenAuthentication;
Expand Down Expand Up @@ -143,7 +144,8 @@ class SlimRouter
*
* @param ContainerInterface|array $settings Either a ContainerInterface or an associative array of app settings
*
* @throws Exception When implementation class doesn't exists
* @throws HttpNotImplementedException When implementation class doesn't exists
* @throws Exception when not supported authorization schema type provided
*/
public function __construct($settings = [])
{
Expand All @@ -160,15 +162,15 @@ class SlimRouter
$authPackage = '{{authPackage}}';
$basicAuthenticator = function (ServerRequestInterface &$request, TokenSearch $tokenSearch) use ($authPackage) {
$message = "How about extending {{abstractNamePrefix}}Authenticator{{abstractNameSuffix}} class by {$authPackage}\BasicAuthenticator?";
throw new Exception($message);
throw new HttpNotImplementedException($request, $message);
};
$apiKeyAuthenticator = function (ServerRequestInterface &$request, TokenSearch $tokenSearch) use ($authPackage) {
$message = "How about extending {{abstractNamePrefix}}Authenticator{{abstractNameSuffix}} class by {$authPackage}\ApiKeyAuthenticator?";
throw new Exception($message);
throw new HttpNotImplementedException($request, $message);
};
$oAuthAuthenticator = function (ServerRequestInterface &$request, TokenSearch $tokenSearch) use ($authPackage) {
$message = "How about extending {{abstractNamePrefix}}Authenticator{{abstractNameSuffix}} class by {$authPackage}\OAuthAuthenticator?";
throw new Exception($message);
throw new HttpNotImplementedException($request, $message);
};
{{/hasAuthMethods}}

Expand All @@ -183,9 +185,7 @@ class SlimRouter
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);
$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
};
$middlewares = [new JsonBodyParserMiddleware()];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace {{apiPackage}};
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Exception;
use Slim\Exception\HttpNotImplementedException;

/**
* {{classname}} Class Doc Comment
Expand Down Expand Up @@ -84,7 +84,7 @@ abstract class {{classname}}
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function {{operationId}}(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
Expand Down Expand Up @@ -125,10 +125,7 @@ abstract class {{classname}}
$body = $request->getParsedBody();
{{/hasBodyParam}}
$message = "How about implementing {{nickname}} as a {{httpMethod}} method in {{apiPackage}}\{{userClassname}} class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}
{{/operation}}
{{/operations}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Exception;
use Slim\Exception\HttpNotImplementedException;

/**
* AbstractAnotherFakeApi Class Doc Comment
Expand Down Expand Up @@ -67,15 +67,12 @@ public function __construct(ContainerInterface $container = null)
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function call123TestSpecialTags(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$message = "How about implementing call123TestSpecialTags as a PATCH method in OpenAPIServer\Api\AnotherFakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}
}
100 changes: 29 additions & 71 deletions samples/server/petstore/php-slim4/lib/Api/AbstractFakeApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Exception;
use Slim\Exception\HttpNotImplementedException;

/**
* AbstractFakeApi Class Doc Comment
Expand Down Expand Up @@ -66,16 +66,13 @@ public function __construct(ContainerInterface $container = null)
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function createXmlItem(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$message = "How about implementing createXmlItem as a POST method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -88,16 +85,13 @@ public function createXmlItem(ServerRequestInterface $request, ResponseInterface
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function fakeOuterBooleanSerialize(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$message = "How about implementing fakeOuterBooleanSerialize as a POST method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -110,16 +104,13 @@ public function fakeOuterBooleanSerialize(ServerRequestInterface $request, Respo
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function fakeOuterCompositeSerialize(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$message = "How about implementing fakeOuterCompositeSerialize as a POST method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -132,16 +123,13 @@ public function fakeOuterCompositeSerialize(ServerRequestInterface $request, Res
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function fakeOuterNumberSerialize(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$message = "How about implementing fakeOuterNumberSerialize as a POST method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -154,16 +142,13 @@ public function fakeOuterNumberSerialize(ServerRequestInterface $request, Respon
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function fakeOuterStringSerialize(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$message = "How about implementing fakeOuterStringSerialize as a POST method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -175,16 +160,13 @@ public function fakeOuterStringSerialize(ServerRequestInterface $request, Respon
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function testBodyWithFileSchema(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$message = "How about implementing testBodyWithFileSchema as a PUT method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -195,18 +177,15 @@ public function testBodyWithFileSchema(ServerRequestInterface $request, Response
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function testBodyWithQueryParams(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$queryParams = $request->getQueryParams();
$query = (key_exists('query', $queryParams)) ? $queryParams['query'] : null;
$body = $request->getParsedBody();
$message = "How about implementing testBodyWithQueryParams as a PUT method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -220,16 +199,13 @@ public function testBodyWithQueryParams(ServerRequestInterface $request, Respons
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function testClientModel(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$message = "How about implementing testClientModel as a PATCH method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -242,7 +218,7 @@ public function testClientModel(ServerRequestInterface $request, ResponseInterfa
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function testEndpointParameters(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
Expand All @@ -262,10 +238,7 @@ public function testEndpointParameters(ServerRequestInterface $request, Response
$password = (isset($body['password'])) ? $body['password'] : null;
$callback = (isset($body['callback'])) ? $body['callback'] : null;
$message = "How about implementing testEndpointParameters as a POST method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -278,7 +251,7 @@ public function testEndpointParameters(ServerRequestInterface $request, Response
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function testEnumParameters(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
Expand All @@ -294,10 +267,7 @@ public function testEnumParameters(ServerRequestInterface $request, ResponseInte
$enumFormStringArray = (isset($body['enum_form_string_array'])) ? $body['enum_form_string_array'] : null;
$enumFormString = (isset($body['enum_form_string'])) ? $body['enum_form_string'] : null;
$message = "How about implementing testEnumParameters as a GET method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -310,7 +280,7 @@ public function testEnumParameters(ServerRequestInterface $request, ResponseInte
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function testGroupParameters(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
Expand All @@ -323,10 +293,7 @@ public function testGroupParameters(ServerRequestInterface $request, ResponseInt
$stringGroup = (key_exists('string_group', $queryParams)) ? $queryParams['string_group'] : null;
$int64Group = (key_exists('int64_group', $queryParams)) ? $queryParams['int64_group'] : null;
$message = "How about implementing testGroupParameters as a DELETE method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -338,16 +305,13 @@ public function testGroupParameters(ServerRequestInterface $request, ResponseInt
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function testInlineAdditionalProperties(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$message = "How about implementing testInlineAdditionalProperties as a POST method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -359,18 +323,15 @@ public function testInlineAdditionalProperties(ServerRequestInterface $request,
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function testJsonFormData(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
$body = $request->getParsedBody();
$param = (isset($body['param'])) ? $body['param'] : null;
$param2 = (isset($body['param2'])) ? $body['param2'] : null;
$message = "How about implementing testJsonFormData as a GET method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}

/**
Expand All @@ -382,7 +343,7 @@ public function testJsonFormData(ServerRequestInterface $request, ResponseInterf
* @param array|null $args Path arguments
*
* @return ResponseInterface
* @throws Exception to force implementation class to override this method
* @throws HttpNotImplementedException to force implementation class to override this method
*/
public function testQueryParameterCollectionFormat(ServerRequestInterface $request, ResponseInterface $response, array $args)
{
Expand All @@ -393,9 +354,6 @@ public function testQueryParameterCollectionFormat(ServerRequestInterface $reque
$url = (key_exists('url', $queryParams)) ? $queryParams['url'] : null;
$context = (key_exists('context', $queryParams)) ? $queryParams['context'] : null;
$message = "How about implementing testQueryParameterCollectionFormat as a PUT method in OpenAPIServer\Api\FakeApi class?";
throw new Exception($message);

$response->getBody()->write($message);
return $response->withStatus(501);
throw new HttpNotImplementedException($request, $message);
}
}
Loading