API improvements (#5494)

* hide logo in docs UI
* always return a user in api base controller
* added example for duration fields
This commit is contained in:
Kevin Papst
2025-05-24 22:09:48 +02:00
committed by GitHub
parent 1e0fbf0b73
commit 7b158d57b5
5 changed files with 37 additions and 30 deletions

View File

@@ -33,6 +33,11 @@ final class DurationType extends AbstractType
'toggle' => false,
'max_hours' => 24,
'icon' => 'clock',
'documentation' => [
'type' => 'string',
'description' => 'Duration - supports various formats: https://www.kimai.org/documentation/duration-format.html',
'example' => '01:30',
]
]);
$resolver->setAllowedTypes('max_hours', 'int');
}

View File

@@ -70,11 +70,20 @@ final class UserType extends AbstractType
// includes the current user if it is a system-account, which is especially useful for forms pages,
// which have a user switcher and display the logged-in user by default
'include_current_user_if_system_account' => false,
'documentation' => [
]);
$resolver->setDefault('documentation', function (Options $options) {
$example = 0;
if ($options['user'] instanceof User) {
$example = $options['user']->getId();
}
return [
'type' => 'integer',
'description' => 'User ID',
],
]);
'example' => $example
];
});
$resolver->setDefault('choices', function (Options $options) {
$query = new UserFormTypeQuery();