Release 2.35 (#5470)

* open up API for plugins by removing internal
* use constants in entity column definition
* simplified entity management API
* bump packages
* allow installing assets and run database migrations independently
* bump to apidoc-bundle 5
* do not duplicate http method in API operationId
* new security entries in Open API definition
* changed API UI provider for Swagger to Stoplight, improved endpoint titles, hide internal endpoints
* deactivate swagger json endpoint
This commit is contained in:
Kevin Papst
2025-05-24 14:28:39 +02:00
committed by GitHub
parent 6e26a37c4d
commit 1e0fbf0b73
63 changed files with 518 additions and 529 deletions

View File

@@ -26,11 +26,21 @@ class ApiDocControllerTest extends AbstractControllerBaseTestCase
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/doc');
self::assertStringContainsString('<title>Kimai', $client->getResponse()->getContent());
$result = $client->getCrawler()->filter('script#swagger-data');
$swaggerJson = json_decode($result->text(), true);
$content = $client->getResponse()->getContent();
self::assertIsString($content);
self::assertStringContainsString('<title>Kimai', $content);
self::assertStringContainsString('docs.apiDescriptionDocument', $content);
self::assertStringContainsString('const config = {"basePath":"/api/doc","router":"memory","logo":"/touch-icon-192x192.png","hideInternal":true};', $content);
$results = preg_match('/docs\.apiDescriptionDocument\ \=\ (.*)\.spec;/', $content, $matches);
self::assertNotFalse($results);
$swaggerJson = json_decode($matches[1], true);
self::assertIsArray($swaggerJson);
self::assertArrayHasKey('spec', $swaggerJson);
$json = $swaggerJson['spec'];
self::assertArrayHasKey('paths', $json);
$tags = [];
foreach ($swaggerJson['spec']['paths'] as $path) {
foreach ($json['paths'] as $path) {
foreach ($path as $method) {
foreach ($method['tags'] as $tag) {
$tags[$tag] = $tag;
@@ -45,13 +55,6 @@ class ApiDocControllerTest extends AbstractControllerBaseTestCase
sort($expectedKeys);
self::assertEquals($expectedKeys, $actual, \sprintf('Expected %s sections in API docs, but found %s.', \count($actual), \count($expectedKeys)));
}
public function testGetJsonDocs(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/doc.json');
$json = json_decode($client->getResponse()->getContent(), true);
$paths = [
'/api/actions/timesheet/{id}/{view}/{locale}',
@@ -108,7 +111,7 @@ class ApiDocControllerTest extends AbstractControllerBaseTestCase
self::assertEquals('3.0.0', $json['openapi']);
self::assertArrayHasKey('info', $json);
self::assertStringStartsWith('Kimai', $json['info']['title']);
self::assertEquals('1.0', $json['info']['version']);
self::assertEquals('1.1', $json['info']['version']);
self::assertArrayHasKey('paths', $json);
self::assertEquals($paths, array_keys($json['paths']));
@@ -119,10 +122,6 @@ class ApiDocControllerTest extends AbstractControllerBaseTestCase
self::assertArrayHasKey('components', $json);
self::assertArrayHasKey('schemas', $json['components']);
self::assertArrayHasKey('securitySchemes', $json['components']);
$result = json_decode($client->getResponse()->getContent(), true);
self::assertIsArray($result);
self::assertNotEmpty($result);
}
protected function createUrl(string $url): string