Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/short-starfishes-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/rest-typings": minor
---

Add OpenAPI support for the Rocket.Chat e2e.fetchMyKeys endpoints by migrating to a modern chained route definition syntax and utilizing shared AJV schemas for validation to enhance API documentation and ensure type safety through response validation.
39 changes: 25 additions & 14 deletions apps/meteor/app/api/server/v1/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,31 @@ const e2eEndpoints = API.v1
return API.v1.success();
},
)
.get(
'e2e.fetchMyKeys',
{
authRequired: true,
query: undefined,
response: {
400: validateBadRequestErrorResponse,
401: validateUnauthorizedErrorResponse,
200: ajv.compile<{ public_key?: string; private_key?: string }>({
type: 'object',
properties: {
public_key: { type: 'string' },
private_key: { type: 'string' },
success: { type: 'boolean', enum: [true] },
},
required: ['success'],
}),
},
},
async function action() {
const result = await Users.fetchKeysByUserId(this.userId);

return API.v1.success(result);
},
)
.get(
'e2e.getUsersOfRoomWithoutKey',
{
Expand Down Expand Up @@ -142,20 +167,6 @@ const e2eEndpoints = API.v1
},
);

API.v1.addRoute(
'e2e.fetchMyKeys',
{
authRequired: true,
},
{
async get() {
const result = await Users.fetchKeysByUserId(this.userId);

return API.v1.success(result);
},
},
);

/**
* @openapi
* /api/v1/e2e.setUserPublicAndPrivateKeys:
Expand Down
3 changes: 0 additions & 3 deletions packages/rest-typings/src/v1/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ export type E2eEndpoints = {
'/v1/e2e.rejectSuggestedGroupKey': {
POST: (params: E2eGetUsersOfRoomWithoutKeyProps) => void;
};
'/v1/e2e.fetchMyKeys': {
GET: () => { public_key: string; private_key: string };
};
'/v1/e2e.fetchUsersWaitingForGroupKey': {
GET: (params: E2EFetchUsersWaitingForGroupKeyProps) => {
usersWaitingForE2EKeys: Record<IRoom['_id'], { _id: IUser['_id']; public_key: string }[]>;
Expand Down
Loading