Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Commit 60aa9ae

Browse files
authored
Merge pull request #9 from Catrobat/develop
Release Merge commit
2 parents 3a53243 + b63d392 commit 60aa9ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+630
-205
lines changed

.openapi-generator/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2.3
1+
4.3.1

Api/ApiServer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* API for the Catrobat Share Platform
1818
*
19-
* The version of the OpenAPI document: v1.0.39
19+
* The version of the OpenAPI document: v1.0.40
2020
* Contact: webmaster@catrobat.org
2121
* Generated by: https://github.com/openapitools/openapi-generator.git
2222
*/

Api/AuthenticationApiInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* API for the Catrobat Share Platform
1717
*
18-
* The version of the OpenAPI document: v1.0.39
18+
* The version of the OpenAPI document: v1.0.40
1919
* Contact: webmaster@catrobat.org
2020
* Generated by: https://github.com/openapitools/openapi-generator.git
2121
*/

Api/MediaLibraryApiInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* API for the Catrobat Share Platform
1717
*
18-
* The version of the OpenAPI document: v1.0.39
18+
* The version of the OpenAPI document: v1.0.40
1919
* Contact: webmaster@catrobat.org
2020
* Generated by: https://github.com/openapitools/openapi-generator.git
2121
*/

Api/ProjectsApiInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* API for the Catrobat Share Platform
1717
*
18-
* The version of the OpenAPI document: v1.0.39
18+
* The version of the OpenAPI document: v1.0.40
1919
* Contact: webmaster@catrobat.org
2020
* Generated by: https://github.com/openapitools/openapi-generator.git
2121
*/

Api/UserApiInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* API for the Catrobat Share Platform
1717
*
18-
* The version of the OpenAPI document: v1.0.39
18+
* The version of the OpenAPI document: v1.0.40
1919
* Contact: webmaster@catrobat.org
2020
* Generated by: https://github.com/openapitools/openapi-generator.git
2121
*/

Api/UtilityApiInterface.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* UtilityApiInterface
4+
* PHP version 5.
5+
*
6+
* @category Class
7+
*
8+
* @author OpenAPI Generator team
9+
*
10+
* @see https://github.com/openapitools/openapi-generator
11+
*/
12+
13+
/**
14+
* Catroweb API.
15+
*
16+
* API for the Catrobat Share Platform
17+
*
18+
* The version of the OpenAPI document: v1.0.40
19+
* Contact: webmaster@catrobat.org
20+
* Generated by: https://github.com/openapitools/openapi-generator.git
21+
*/
22+
23+
/**
24+
* NOTE: This class is auto generated by the openapi generator program.
25+
* https://github.com/openapitools/openapi-generator
26+
* Do not edit the class manually.
27+
*/
28+
29+
namespace OpenAPI\Server\Api;
30+
31+
/**
32+
* UtilityApiInterface Interface Doc Comment.
33+
*
34+
* @category Interface
35+
*
36+
* @author OpenAPI Generator team
37+
*
38+
* @see https://github.com/openapitools/openapi-generator
39+
*/
40+
interface UtilityApiInterface
41+
{
42+
/**
43+
* Operation healthGet.
44+
*
45+
* Health Check
46+
*
47+
* @param int $responseCode The HTTP response code to return
48+
* @param array $responseHeaders Additional HTTP headers to return with the response ()
49+
*/
50+
public function healthGet(&$responseCode, array &$responseHeaders);
51+
}

Controller/AuthenticationController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* API for the Catrobat Share Platform
1818
*
19-
* The version of the OpenAPI document: v1.0.39
19+
* The version of the OpenAPI document: v1.0.40
2020
* Contact: webmaster@catrobat.org
2121
* Generated by: https://github.com/openapitools/openapi-generator.git
2222
*/
@@ -126,8 +126,7 @@ public function authenticationPostAction(Request $request)
126126
{
127127
// Make sure that the client is providing something that we can consume
128128
$consumes = ['application/json'];
129-
$inputFormat = $request->headers->has('Content-Type') ? $request->headers->get('Content-Type') : $consumes[0];
130-
if (!in_array($inputFormat, $consumes, true))
129+
if (!static::isContentTypeAllowed($request, $consumes))
131130
{
132131
// We can't consume the content that the client is sending us
133132
return new Response('', 415);
@@ -156,6 +155,7 @@ public function authenticationPostAction(Request $request)
156155
// Deserialize the input values that needs it
157156
try
158157
{
158+
$inputFormat = $request->getMimeType($request->getContentType());
159159
$login = $this->deserialize($login, 'OpenAPI\Server\Model\Login', $inputFormat);
160160
}
161161
catch (SerializerRuntimeException $exception)

Controller/Controller.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* API for the Catrobat Share Platform
1818
*
19-
* The version of the OpenAPI document: v1.0.39
19+
* The version of the OpenAPI document: v1.0.40
2020
* Contact: webmaster@catrobat.org
2121
* Generated by: https://github.com/openapitools/openapi-generator.git
2222
*/
@@ -32,6 +32,7 @@
3232
use OpenAPI\Server\Service\SerializerInterface;
3333
use OpenAPI\Server\Service\ValidatorInterface;
3434
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
35+
use Symfony\Component\HttpFoundation\Request;
3536
use Symfony\Component\HttpFoundation\Response;
3637
use Symfony\Component\HttpKernel\Exception\HttpException;
3738

@@ -97,6 +98,47 @@ public function createErrorResponse(HttpException $exception)
9798
return new Response(json_encode($json, 15, 512), $statusCode, $headers);
9899
}
99100

101+
/**
102+
* Checks whether Content-Type request header presented in supported formats.
103+
*
104+
* @param Request $request request instance
105+
* @param array $consumes array of supported content types
106+
*
107+
* @return bool returns true if Content-Type supported otherwise false
108+
*/
109+
public static function isContentTypeAllowed(Request $request, array $consumes = [])
110+
{
111+
if (!empty($consumes) && '*/*' !== $consumes[0])
112+
{
113+
$currentFormat = $request->getContentType();
114+
foreach ($consumes as $mimeType)
115+
{
116+
// canonize mime type
117+
if (is_string($mimeType) && false !== $pos = strpos($mimeType, ';'))
118+
{
119+
$mimeType = trim(substr($mimeType, 0, $pos));
120+
}
121+
122+
if (!$format = $request->getFormat($mimeType))
123+
{
124+
// add custom format to request
125+
$format = $mimeType;
126+
$request->setFormat($format, $format);
127+
$currentFormat = $request->getContentType();
128+
}
129+
130+
if ($format === $currentFormat)
131+
{
132+
return true;
133+
}
134+
}
135+
136+
return false;
137+
}
138+
139+
return true;
140+
}
141+
100142
/**
101143
* Serializes data to a given type format.
102144
*

Controller/MediaLibraryController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* API for the Catrobat Share Platform
1818
*
19-
* The version of the OpenAPI document: v1.0.39
19+
* The version of the OpenAPI document: v1.0.40
2020
* Contact: webmaster@catrobat.org
2121
* Generated by: https://github.com/openapitools/openapi-generator.git
2222
*/
@@ -117,6 +117,9 @@ public function mediaFileIdGetAction(Request $request, $id)
117117
case 400:
118118
$message = 'BAD Request - invalid or missing required parameters';
119119
break;
120+
case 404:
121+
$message = 'Not Found';
122+
break;
120123
case 406:
121124
$message = 'Not Acceptable - client must accept application/json as content type';
122125
break;

0 commit comments

Comments
 (0)