Skip to content

Commit 9ea3c75

Browse files
authored
hlapi html and mentions hints (#22610)
1 parent 79de7a5 commit 9ea3c75

File tree

8 files changed

+42
-14
lines changed

8 files changed

+42
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ The present file will list all changes made to the project; according to the
99

1010
### Changed
1111
- High-Level API performance improvements for both REST and GraphQL requests (3.3-10x performance uplift on average)
12+
- Some `string` properties in High-Level API schemas have been updated use the `html` format to indicate the context should be treated as HTML/Rich text.
13+
- Some `string` properties in High-Level API schemas have been updated to include an `x-supports-mentions` to indicate that user mentions are supported.
1214

1315
### Deprecated
1416

src/Glpi/Api/HL/Controller/ITILController.php

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ public static function getRawKnownSchemas(): array
188188
'readOnly' => true,
189189
],
190190
'name' => ['type' => Doc\Schema::TYPE_STRING],
191-
'content' => ['type' => Doc\Schema::TYPE_STRING],
191+
'content' => [
192+
'type' => Doc\Schema::TYPE_STRING,
193+
'format' => Doc\Schema::FORMAT_STRING_HTML,
194+
'x-supports-mentions' => true,
195+
],
192196
'user_recipient' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_recipient', full_schema: 'User') + ['x-version-introduced' => '2.1.0'],
193197
'user_editor' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_lastupdater', full_schema: 'User') + ['x-version-introduced' => '2.1.0'],
194198
'is_deleted' => ['type' => Doc\Schema::TYPE_BOOLEAN],
@@ -605,7 +609,11 @@ public static function getRawKnownSchemas(): array
605609
'format' => Doc\Schema::PATTERN_UUIDV4,
606610
'readOnly' => true,
607611
],
608-
'content' => ['type' => Doc\Schema::TYPE_STRING],
612+
'content' => [
613+
'type' => Doc\Schema::TYPE_STRING,
614+
'format' => Doc\Schema::FORMAT_STRING_HTML,
615+
'x-supports-mentions' => true,
616+
],
609617
'is_private' => ['type' => Doc\Schema::TYPE_BOOLEAN],
610618
'user' => self::getDropdownTypeSchema(class: User::class, full_schema: 'User'),
611619
'user_editor' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_editor', full_schema: 'User'),
@@ -773,7 +781,11 @@ public static function getRawKnownSchemas(): array
773781
],
774782
'itemtype' => ['type' => Doc\Schema::TYPE_STRING,],
775783
'items_id' => ['type' => Doc\Schema::TYPE_INTEGER, 'format' => Doc\Schema::FORMAT_INTEGER_INT64],
776-
'content' => ['type' => Doc\Schema::TYPE_STRING],
784+
'content' => [
785+
'type' => Doc\Schema::TYPE_STRING,
786+
'format' => Doc\Schema::FORMAT_STRING_HTML,
787+
'x-supports-mentions' => true,
788+
],
777789
'is_private' => ['type' => Doc\Schema::TYPE_BOOLEAN],
778790
'user' => self::getDropdownTypeSchema(class: User::class, full_schema: 'User'),
779791
'user_editor' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_editor', full_schema: 'User'),
@@ -818,7 +830,11 @@ public static function getRawKnownSchemas(): array
818830
],
819831
'itemtype' => ['type' => Doc\Schema::TYPE_STRING],
820832
'items_id' => ['type' => Doc\Schema::TYPE_INTEGER, 'format' => Doc\Schema::FORMAT_INTEGER_INT64],
821-
'content' => ['type' => Doc\Schema::TYPE_STRING],
833+
'content' => [
834+
'type' => Doc\Schema::TYPE_STRING,
835+
'format' => Doc\Schema::FORMAT_STRING_HTML,
836+
'x-supports-mentions' => true,
837+
],
822838
'user' => self::getDropdownTypeSchema(class: User::class, full_schema: 'User'),
823839
'user_editor' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_editor', full_schema: 'User'),
824840
'approver' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_approval', full_schema: 'User') + ['x-version-introduced' => '2.1.0'],
@@ -895,10 +911,17 @@ public static function getRawKnownSchemas(): array
895911
'x-field' => 'items_id_target',
896912
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
897913
],
898-
'submission_comment' => ['type' => Doc\Schema::TYPE_STRING, 'x-field' => 'comment_submission'],
914+
'submission_comment' => [
915+
'type' => Doc\Schema::TYPE_STRING,
916+
'format' => Doc\Schema::FORMAT_STRING_HTML,
917+
'x-field' => 'comment_submission',
918+
'x-supports-mentions' => true,
919+
],
899920
'approval_comment' => [
900921
'type' => Doc\Schema::TYPE_STRING,
922+
'format' => Doc\Schema::FORMAT_STRING_HTML,
901923
'x-field' => 'comment_validation',
924+
'x-supports-mentions' => true,
902925
],
903926
'status' => [
904927
'type' => Doc\Schema::TYPE_INTEGER,
@@ -1045,7 +1068,7 @@ public static function getRawKnownSchemas(): array
10451068
'readOnly' => true,
10461069
],
10471070
'name' => ['type' => Doc\Schema::TYPE_STRING],
1048-
'text' => ['type' => Doc\Schema::TYPE_STRING],
1071+
'text' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_HTML],
10491072
'comment' => ['type' => Doc\Schema::TYPE_STRING],
10501073
'duration' => ['type' => Doc\Schema::TYPE_INTEGER],
10511074
'before_time' => ['type' => Doc\Schema::TYPE_INTEGER],
@@ -1106,7 +1129,7 @@ public static function getRawKnownSchemas(): array
11061129
'readOnly' => true,
11071130
],
11081131
'name' => ['type' => Doc\Schema::TYPE_STRING],
1109-
'text' => ['type' => Doc\Schema::TYPE_STRING],
1132+
'text' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_HTML],
11101133
'template' => self::getDropdownTypeSchema(class: PlanningExternalEventTemplate::class, full_schema: 'ExternalEventTemplate'),
11111134
'category' => self::getDropdownTypeSchema(class: PlanningEventCategory::class, full_schema: 'EventCategory'),
11121135
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),

src/Glpi/Api/HL/Controller/ProjectController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected static function getRawKnownSchemas(): array
116116
],
117117
'name' => ['type' => Doc\Schema::TYPE_STRING],
118118
'comment' => ['type' => Doc\Schema::TYPE_STRING],
119-
'content' => ['type' => Doc\Schema::TYPE_STRING],
119+
'content' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_HTML],
120120
'code' => ['type' => Doc\Schema::TYPE_STRING],
121121
'priority' => [
122122
'type' => Doc\Schema::TYPE_INTEGER,
@@ -234,7 +234,7 @@ protected static function getRawKnownSchemas(): array
234234
],
235235
'name' => ['type' => Doc\Schema::TYPE_STRING],
236236
'comment' => ['type' => Doc\Schema::TYPE_STRING],
237-
'content' => ['type' => Doc\Schema::TYPE_STRING],
237+
'content' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_HTML],
238238
'project' => self::getDropdownTypeSchema(class: Project::class, full_schema: 'Project'),
239239
'parent_task' => self::getDropdownTypeSchema(class: ProjectTask::class, full_schema: 'ProjectTask'),
240240
],

src/Glpi/Api/HL/Controller/ToolController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function getRawKnownSchemas(): array
7474
'readOnly' => true,
7575
],
7676
'name' => ['type' => Doc\Schema::TYPE_STRING],
77-
'text' => ['type' => Doc\Schema::TYPE_STRING],
77+
'text' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_HTML],
7878
'date' => [
7979
'type' => Doc\Schema::TYPE_STRING,
8080
'format' => Doc\Schema::FORMAT_STRING_DATE_TIME,
@@ -172,7 +172,7 @@ public static function getRawKnownSchemas(): array
172172
'format' => Doc\Schema::FORMAT_INTEGER_INT64,
173173
'description' => 'The ID of the reservable item',
174174
],
175-
'comment' => ['type' => Doc\Schema::TYPE_STRING],
175+
'comment' => ['type' => Doc\Schema::TYPE_STRING, 'format' => Doc\Schema::FORMAT_STRING_HTML],
176176
'entity' => self::getDropdownTypeSchema(class: Entity::class, full_schema: 'Entity'),
177177
'is_recursive' => ['type' => Doc\Schema::TYPE_BOOLEAN],
178178
'is_active' => [

src/Glpi/Api/HL/Doc/Schema.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class Schema implements ArrayAccess
6767
public const FORMAT_NUMBER_FLOAT = 'float';
6868
public const FORMAT_BOOLEAN_BOOLEAN = 'boolean';
6969

70+
// Not defined directly in OpenAPI schema but exist within the format registry (https://spec.openapis.org/registry/format/)
71+
public const FORMAT_STRING_HTML = 'html';
72+
7073
public const PATTERN_UUIDV4 = '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i';
7174
public const PATTERN_COLOR_HEX = '/^#([A-Fa-f0-9]{6})$/';
7275

src/Glpi/Api/HL/OpenAPIGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function __construct(Router $router, string $api_version)
9797

9898
private function getPublicVendorExtensions(): array
9999
{
100-
return ['writeOnly', 'readOnly', 'x-full-schema', 'x-introduced', 'x-deprecated', 'x-removed', 'x-itemtype'];
100+
return ['x-full-schema', 'x-introduced', 'x-deprecated', 'x-removed', 'x-itemtype', 'x-supports-mentions'];
101101
}
102102

103103
private function cleanVendorExtensions(array $schema, ?string $parent_key = null, ?array $parent_schema = null): array

tests/fixtures/hlapi/snapshots/v2_0_0.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/fixtures/hlapi/snapshots/v2_1_0.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)