src/Api/OpenAPI/Server/Controller/ProjectsController.php
<?php

/**
 * ProjectsController
 * PHP version 8.1.1.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://github.com/openapitools/openapi-generator
 */

/**
 * Catroweb API.
 *
 * API for the Catrobat Share Platform
 *
 * The version of the OpenAPI document: v1.6.0
 * Contact: webmaster@catrobat.org
 * 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 OpenAPI\Server\Controller;

use JMS\Serializer\Exception\RuntimeException as SerializerRuntimeException;
use OpenAPI\Server\Api\ProjectsApiInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * ProjectsController Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://github.com/openapitools/openapi-generator
 */
class ProjectsController extends Controller
{
  /**
   * Operation projectIdCatrobatGet.
   *
   * Download the .catrobat (=zip) file of a project
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectIdCatrobatGetAction(Request $request, $id)
  {
    // Figure out what data format to return to the client
    $produces = ['application/zip'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $id = $this->deserialize($id, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-]+$/');
    $response = $this->validate($id, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectIdCatrobatGet($id, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => '.catrobat file successfully downloaded',
        400 => 'Bad request (Invalid, or missing parameters)',
        404 => 'Not found',
        500 => 'We were not able to create a .catrobat file for this project. There is a high possibility that the project files are missing on the server.',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectIdDelete.
   *
   * Delete a project
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectIdDeleteAction(Request $request, $id)
  {
    // Handle authentication
    // Authentication 'BearerAuth' required
    // HTTP bearer authentication required
    $securityBearerAuth = $request->headers->get('authorization');

    // Read out all input parameter values into variables

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $id = $this->deserialize($id, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-]+$/');
    $response = $this->validate($id, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Set authentication method 'BearerAuth'
      $handler->setBearerAuth($securityBearerAuth);

      // Make the call to the business logic
      $responseCode = 204;
      $responseHeaders = [];

      $handler->projectIdDelete($id, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        204 => 'Project successfully deleted',
        400 => 'Bad request (Invalid, or missing parameters)',
        401 => 'Invalid JWT token | JWT token not found | JWT token expired',
        404 => 'Not found',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectIdGet.
   *
   * Get the information of a project
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectIdGetAction(Request $request, $id)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $id = $this->deserialize($id, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-]+$/');
    $response = $this->validate($id, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectIdGet($id, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        400 => 'Bad request (Invalid, or missing parameters)',
        404 => 'Not found',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectIdPut.
   *
   * Update details of a project
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectIdPutAction(Request $request, $id)
  {
    // Make sure that the client is providing something that we can consume
    $consumes = ['application/json'];
    if (!static::isContentTypeAllowed($request, $consumes)) {
      // We can't consume the content that the client is sending us
      return new Response('', 415);
    }

    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication
    // Authentication 'BearerAuth' required
    // HTTP bearer authentication required
    $securityBearerAuth = $request->headers->get('authorization');

    // Read out all input parameter values into variables
    $accept_language = $request->headers->get('Accept-Language', 'en');
    $update_project_request = $request->getContent();

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $id = $this->deserialize($id, 'string', 'string');
      $inputFormat = $request->getMimeType($request->getContentTypeFormat());
      $update_project_request = $this->deserialize($update_project_request, 'OpenAPI\Server\Model\UpdateProjectRequest', $inputFormat);
      $accept_language = $this->deserialize($accept_language, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-]+$/');
    $response = $this->validate($id, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('OpenAPI\Server\Model\UpdateProjectRequest');
    $asserts[] = new Assert\Valid();
    $response = $this->validate($update_project_request, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($accept_language, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Set authentication method 'BearerAuth'
      $handler->setBearerAuth($securityBearerAuth);

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectIdPut($id, $update_project_request, $accept_language, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        204 => 'Project successfully updated',
        401 => 'Invalid credentials',
        403 => 'Insufficient privileges, action not allowed.',
        404 => 'Not found',
        406 => 'Not acceptable - client must accept application/json as content type',
        422 => 'Unprocessable Entity. (Specific error messages will be translated to the locale)',
        500 => 'Server error',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectIdRecommendationsGet.
   *
   * Get recommended projects related to the specific project
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectIdRecommendationsGetAction(Request $request, $id)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables
    $category = $request->query->get('category');
    $max_version = $request->query->get('max_version', '');
    $limit = $request->query->get('limit', 20);
    $offset = $request->query->get('offset', 0);
    $attributes = $request->query->get('attributes', '');
    $flavor = $request->query->get('flavor', '');
    $accept_language = $request->headers->get('Accept-Language', 'en');

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $id = $this->deserialize($id, 'string', 'string');
      $category = $this->deserialize($category, 'string', 'string');
      $accept_language = $this->deserialize($accept_language, 'string', 'string');
      $max_version = $this->deserialize($max_version, 'string', 'string');
      $limit = $this->deserialize($limit, 'int', 'string');
      $offset = $this->deserialize($offset, 'int', 'string');
      $attributes = $this->deserialize($attributes, 'string', 'string');
      $flavor = $this->deserialize($flavor, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-]+$/');
    $response = $this->validate($id, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Choice(['similar', 'also_downloaded', 'more_from_user']);
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($category, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($accept_language, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($max_version, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($limit, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($offset, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-_]+(,[a-zA-Z0-9\-_]+)*$/');
    $response = $this->validate($attributes, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($flavor, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectIdRecommendationsGet($id, $category, $accept_language, $max_version, $limit, $offset, $attributes, $flavor, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        400 => 'Bad request (Invalid, or missing parameters)',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectIdReportPost.
   *
   * Report a project -- StatusCode: 501 - Not yet implemented
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectIdReportPostAction(Request $request, $id)
  {
    // Make sure that the client is providing something that we can consume
    $consumes = ['application/json'];
    if (!static::isContentTypeAllowed($request, $consumes)) {
      // We can't consume the content that the client is sending us
      return new Response('', 415);
    }

    // Handle authentication
    // Authentication 'BearerAuth' required
    // HTTP bearer authentication required
    $securityBearerAuth = $request->headers->get('authorization');

    // Read out all input parameter values into variables
    $project_report_request = $request->getContent();

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $id = $this->deserialize($id, 'string', 'string');
      $inputFormat = $request->getMimeType($request->getContentTypeFormat());
      $project_report_request = $this->deserialize($project_report_request, 'OpenAPI\Server\Model\ProjectReportRequest', $inputFormat);
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-]+$/');
    $response = $this->validate($id, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('OpenAPI\Server\Model\ProjectReportRequest');
    $asserts[] = new Assert\Valid();
    $response = $this->validate($project_report_request, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Set authentication method 'BearerAuth'
      $handler->setBearerAuth($securityBearerAuth);

      // Make the call to the business logic
      $responseCode = 204;
      $responseHeaders = [];

      $handler->projectIdReportPost($id, $project_report_request, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        204 => 'Project successfully reported',
        400 => 'Bad request (Invalid, or missing parameters)',
        401 => 'Invalid JWT token | JWT token not found | JWT token expired',
        404 => 'Not found',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectsCategoriesGet.
   *
   * Get default number of projects per category (Most downloaded etc.)
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectsCategoriesGetAction(Request $request)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables
    $max_version = $request->query->get('max_version', '');
    $flavor = $request->query->get('flavor', '');
    $accept_language = $request->headers->get('Accept-Language', 'en');

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $max_version = $this->deserialize($max_version, 'string', 'string');
      $flavor = $this->deserialize($flavor, 'string', 'string');
      $accept_language = $this->deserialize($accept_language, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($max_version, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($flavor, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($accept_language, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectsCategoriesGet($max_version, $flavor, $accept_language, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        400 => 'Bad request (Invalid, or missing parameters)',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectsExtensionsGet.
   *
   * Get all possible project extensions. Extensions are automatically added to projects based on their bricks.
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectsExtensionsGetAction(Request $request)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables
    $accept_language = $request->headers->get('Accept-Language', 'en');

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $accept_language = $this->deserialize($accept_language, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($accept_language, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectsExtensionsGet($accept_language, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectsFeaturedGet.
   *
   * Get the currently featured projects
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectsFeaturedGetAction(Request $request)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables
    $platform = $request->query->get('platform', '');
    $max_version = $request->query->get('max_version', '');
    $limit = $request->query->get('limit', 20);
    $offset = $request->query->get('offset', 0);
    $attributes = $request->query->get('attributes', '');
    $flavor = $request->query->get('flavor', '');

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $platform = $this->deserialize($platform, 'string', 'string');
      $max_version = $this->deserialize($max_version, 'string', 'string');
      $limit = $this->deserialize($limit, 'int', 'string');
      $offset = $this->deserialize($offset, 'int', 'string');
      $attributes = $this->deserialize($attributes, 'string', 'string');
      $flavor = $this->deserialize($flavor, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\Choice(['', 'android', 'ios']);
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($platform, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($max_version, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($limit, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($offset, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-_]+(,[a-zA-Z0-9\-_]+)*$/');
    $response = $this->validate($attributes, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($flavor, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectsFeaturedGet($platform, $max_version, $limit, $offset, $attributes, $flavor, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        400 => 'Bad request (Invalid, or missing parameters)',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectsGet.
   *
   * Get projects
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectsGetAction(Request $request)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables
    $category = $request->query->get('category');
    $max_version = $request->query->get('max_version', '');
    $limit = $request->query->get('limit', 20);
    $offset = $request->query->get('offset', 0);
    $attributes = $request->query->get('attributes', '');
    $flavor = $request->query->get('flavor', '');
    $accept_language = $request->headers->get('Accept-Language', 'en');

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $category = $this->deserialize($category, 'string', 'string');
      $accept_language = $this->deserialize($accept_language, 'string', 'string');
      $max_version = $this->deserialize($max_version, 'string', 'string');
      $limit = $this->deserialize($limit, 'int', 'string');
      $offset = $this->deserialize($offset, 'int', 'string');
      $attributes = $this->deserialize($attributes, 'string', 'string');
      $flavor = $this->deserialize($flavor, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Choice(['recent', 'random', 'most_viewed', 'most_downloaded', 'example', 'scratch', 'recommended', 'trending', 'popular']);
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($category, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($accept_language, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($max_version, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($limit, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($offset, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-_]+(,[a-zA-Z0-9\-_]+)*$/');
    $response = $this->validate($attributes, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($flavor, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectsGet($category, $accept_language, $max_version, $limit, $offset, $attributes, $flavor, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        400 => 'Bad request (Invalid, or missing parameters)',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectsPost.
   *
   * Upload a catrobat project
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectsPostAction(Request $request)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication
    // Authentication 'BearerAuth' required
    // HTTP bearer authentication required
    $securityBearerAuth = $request->headers->get('authorization');

    // Read out all input parameter values into variables
    $accept_language = $request->headers->get('Accept-Language', 'en');
    $checksum = $request->request->get('checksum');
    $file = $request->files->get('file');
    $flavor = $request->request->get('flavor', 'pocketcode');
    $private = $request->request->get('private', false);

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $checksum = $this->deserialize($checksum, 'string', 'string');
      $accept_language = $this->deserialize($accept_language, 'string', 'string');
      $flavor = $this->deserialize($flavor, 'string', 'string');
      $private = $this->deserialize($private, 'bool', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($checksum, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\File();
    $response = $this->validate($file, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($accept_language, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($flavor, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('bool');
    $response = $this->validate($private, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Set authentication method 'BearerAuth'
      $handler->setBearerAuth($securityBearerAuth);

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectsPost($checksum, $file, $accept_language, $flavor, $private, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        201 => 'Project successfully uploaded',
        400 => 'Bad request (Invalid, or missing parameters)',
        401 => 'Invalid JWT token | JWT token not found | JWT token expired',
        403 => 'Insufficient privileges, action not allowed.',
        406 => 'Not acceptable - client must accept application/json as content type',
        422 => 'Upload Error',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectsSearchGet.
   *
   * Search for projects associated with a keywords
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectsSearchGetAction(Request $request)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables
    $query = $request->query->get('query');
    $max_version = $request->query->get('max_version', '');
    $limit = $request->query->get('limit', 20);
    $offset = $request->query->get('offset', 0);
    $attributes = $request->query->get('attributes', '');
    $flavor = $request->query->get('flavor', '');

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $query = $this->deserialize($query, 'string', 'string');
      $max_version = $this->deserialize($max_version, 'string', 'string');
      $limit = $this->deserialize($limit, 'int', 'string');
      $offset = $this->deserialize($offset, 'int', 'string');
      $attributes = $this->deserialize($attributes, 'string', 'string');
      $flavor = $this->deserialize($flavor, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($query, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($max_version, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($limit, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($offset, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-_]+(,[a-zA-Z0-9\-_]+)*$/');
    $response = $this->validate($attributes, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($flavor, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectsSearchGet($query, $max_version, $limit, $offset, $attributes, $flavor, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        400 => 'Bad request (Invalid, or missing parameters)',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectsTagsGet.
   *
   * Get all possible project tags. Some Tags will only be availabe during events.
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectsTagsGetAction(Request $request)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables
    $accept_language = $request->headers->get('Accept-Language', 'en');

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $accept_language = $this->deserialize($accept_language, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($accept_language, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectsTagsGet($accept_language, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectsUserGet.
   *
   * Get the projects of the logged in user
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectsUserGetAction(Request $request)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication
    // Authentication 'BearerAuth' required
    // HTTP bearer authentication required
    $securityBearerAuth = $request->headers->get('authorization');

    // Read out all input parameter values into variables
    $max_version = $request->query->get('max_version', '');
    $limit = $request->query->get('limit', 20);
    $offset = $request->query->get('offset', 0);
    $attributes = $request->query->get('attributes', '');
    $flavor = $request->query->get('flavor', '');

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $max_version = $this->deserialize($max_version, 'string', 'string');
      $limit = $this->deserialize($limit, 'int', 'string');
      $offset = $this->deserialize($offset, 'int', 'string');
      $attributes = $this->deserialize($attributes, 'string', 'string');
      $flavor = $this->deserialize($flavor, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($max_version, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($limit, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($offset, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-_]+(,[a-zA-Z0-9\-_]+)*$/');
    $response = $this->validate($attributes, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($flavor, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Set authentication method 'BearerAuth'
      $handler->setBearerAuth($securityBearerAuth);

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectsUserGet($max_version, $limit, $offset, $attributes, $flavor, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        400 => 'Bad request (Invalid, or missing parameters)',
        401 => 'Invalid JWT token | JWT token not found | JWT token expired',
        403 => 'Insufficient privileges, action not allowed.',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Operation projectsUserIdGet.
   *
   * Get the public projects of a given user
   *
   * @param Request $request the Symfony request to handle
   *
   * @return Response the Symfony response
   */
  public function projectsUserIdGetAction(Request $request, $id)
  {
    // Figure out what data format to return to the client
    $produces = ['application/json'];
    // Figure out what the client accepts
    $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*';
    $responseFormat = $this->getOutputFormat($clientAccepts, $produces);
    if (null === $responseFormat) {
      return new Response('', 406);
    }

    // Handle authentication

    // Read out all input parameter values into variables
    $max_version = $request->query->get('max_version', '');
    $limit = $request->query->get('limit', 20);
    $offset = $request->query->get('offset', 0);
    $attributes = $request->query->get('attributes', '');
    $flavor = $request->query->get('flavor', '');

    // Use the default value if no value was provided

    // Deserialize the input values that needs it
    try {
      $id = $this->deserialize($id, 'string', 'string');
      $max_version = $this->deserialize($max_version, 'string', 'string');
      $limit = $this->deserialize($limit, 'int', 'string');
      $offset = $this->deserialize($offset, 'int', 'string');
      $attributes = $this->deserialize($attributes, 'string', 'string');
      $flavor = $this->deserialize($flavor, 'string', 'string');
    } catch (SerializerRuntimeException $exception) {
      return $this->createBadRequestResponse($exception->getMessage());
    }

    // Validate the input values
    $asserts = [];
    $asserts[] = new Assert\NotNull();
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-]+$/');
    $response = $this->validate($id, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($max_version, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($limit, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('int');
    $asserts[] = new Assert\GreaterThanOrEqual(0);
    $response = $this->validate($offset, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $asserts[] = new Assert\Regex('/^[a-zA-Z0-9\-_]+(,[a-zA-Z0-9\-_]+)*$/');
    $response = $this->validate($attributes, $asserts);
    if ($response instanceof Response) {
      return $response;
    }
    $asserts = [];
    $asserts[] = new Assert\Type('string');
    $response = $this->validate($flavor, $asserts);
    if ($response instanceof Response) {
      return $response;
    }

    try {
      $handler = $this->getApiHandler();

      // Make the call to the business logic
      $responseCode = 200;
      $responseHeaders = [];

      $result = $handler->projectsUserIdGet($id, $max_version, $limit, $offset, $attributes, $flavor, $responseCode, $responseHeaders);

      $message = match ($responseCode) {
        200 => 'OK',
        400 => 'Bad request (Invalid, or missing parameters)',
        404 => 'Not found',
        406 => 'Not acceptable - client must accept application/json as content type',
        default => '',
      };

      return new Response(
        null !== $result ? $this->serialize($result, $responseFormat) : '',
        $responseCode,
        array_merge(
          $responseHeaders,
          [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message,
          ]
        )
      );
    } catch (\Throwable $fallthrough) {
      return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
    }
  }

  /**
   * Returns the handler for this API controller.
   *
   * @return ProjectsApiInterface
   */
  public function getApiHandler()
  {
    return $this->apiServer->getApiHandler('projects');
  }
}
