All Downloads are FREE. Search and download functionalities are using the official Maven repository.

php-slim4-server.api.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
licenseInfo}}

/**
 * NOTE: This class is auto generated by the openapi generator program.
 * https://github.com/openapitools/openapi-generator
 * Do not edit the class manually.
 */
namespace {{apiPackage}};

use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Slim\Exception\HttpNotImplementedException;

/**
 * {{classname}} Class Doc Comment
 *
 * @package {{apiPackage}}
 * @author  OpenAPI Generator team
 * @link    https://github.com/openapitools/openapi-generator
 */
abstract class {{classname}}
{

    /**
     * @var ContainerInterface|null Slim app container instance
     */
    protected $container;

    /**
     * Route Controller constructor receives container
     *
     * @param ContainerInterface|null $container Slim app container instance
     */
    public function __construct(ContainerInterface $container = null)
    {
        $this->container = $container;
    }

    {{#operations}}
    {{#operation}}

    /**
     * {{httpMethod}} {{operationId}}
     {{#summary}}
     * Summary: {{.}}
     {{/summary}}
     {{#notes}}
     * Notes: {{.}}
     {{/notes}}
     {{#hasProduces}}
     * Output-Formats: [{{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}]
     {{/hasProduces}}
     *
     * @param ServerRequestInterface $request  Request
     * @param ResponseInterface      $response Response
     * @param array|null             $args     Path arguments
     *
     * @return ResponseInterface
     * @throws HttpNotImplementedException to force implementation class to override this method
    {{#isDeprecated}}
     * @deprecated
    {{/isDeprecated}}
     */
    public function {{operationId}}(ServerRequestInterface $request, ResponseInterface $response, array $args)
    {
        {{#hasHeaderParams}}
        $headers = $request->getHeaders();
        {{#headerParams}}
        ${{paramName}} = $request->hasHeader('{{baseName}}') ? $headers['{{baseName}}'] : null;
        {{/headerParams}}
        {{/hasHeaderParams}}
        {{#hasPathParams}}
        {{#pathParams}}
        ${{paramName}} = $args['{{baseName}}'];
        {{/pathParams}}
        {{/hasPathParams}}
        {{#hasQueryParams}}
        $queryParams = $request->getQueryParams();
        {{#queryParams}}
        ${{paramName}} = (key_exists('{{baseName}}', $queryParams)) ? $queryParams['{{baseName}}'] : null;
        {{/queryParams}}
        {{/hasQueryParams}}
        {{#hasFormParams}}
        $body = $request->getParsedBody();
        {{#formParams}}
        {{^isFile}}
        ${{paramName}} = (isset($body['{{baseName}}'])) ? $body['{{baseName}}'] : null;
        {{/isFile}}
        {{#isFile}}
        {{#isMultipart}}
        ${{paramName}} = (key_exists('{{baseName}}', $request->getUploadedFiles())) ? $request->getUploadedFiles()['{{baseName}}'] : null;
        {{/isMultipart}}
        {{^isMultipart}}
        ${{paramName}} = (isset($body['{{baseName}}'])) ? $body['{{baseName}}'] : null;
        {{/isMultipart}}
        {{/isFile}}
        {{/formParams}}
        {{/hasFormParams}}
        {{#hasBodyParam}}
        $body = $request->getParsedBody();
        {{/hasBodyParam}}
        $message = "How about implementing {{nickname}} as a {{httpMethod}} method in {{apiPackage}}\{{userClassname}} class?";
        throw new HttpNotImplementedException($request, $message);
    }
    {{/operation}}
    {{/operations}}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy