-
Notifications
You must be signed in to change notification settings - Fork 13.5k
chore: convert endpoints do openApi #39553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
7d566b8
5cd61bd
41187a5
242fc8b
aaba15e
4a86f07
8aba6e4
f1cbf46
b10deb9
aed58f5
164cd49
8e0b79e
31fe74b
15f0be8
2f15c41
0e35955
900cb96
573e8e7
555bf93
9c6695b
4c4e71f
d874a1a
df2168e
a82df15
b9186b3
2b21847
1a03d12
5c90cd8
5465a65
b395812
a7f20f0
ca17e18
2336ba3
c3eb913
932aa61
85d0087
007dd57
40ff9cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,28 @@ | ||
| import type { IWorkspaceInfo } from '@rocket.chat/core-typings'; | ||
| import { ajv } from '@rocket.chat/rest-typings'; | ||
|
|
||
| import { API } from '../api'; | ||
| import { getServerInfo } from '../lib/getServerInfo'; | ||
|
|
||
| API.default.addRoute( | ||
| const infoResponseSchema = ajv.compile<IWorkspaceInfo>({ | ||
| type: 'object', | ||
| properties: { | ||
| version: { type: 'string' }, | ||
| success: { type: 'boolean', enum: [true] }, | ||
| }, | ||
| required: ['success'], | ||
| additionalProperties: true, | ||
| }); | ||
|
|
||
| API.default.get( | ||
| 'info', | ||
| { authRequired: false }, | ||
| { | ||
| async get() { | ||
| return API.v1.success(await getServerInfo(this.userId)); | ||
| authRequired: false, | ||
| response: { | ||
| 200: infoResponseSchema, | ||
| }, | ||
| }, | ||
| async function action() { | ||
| return API.v1.success(await getServerInfo(this.userId)); | ||
| }, | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { schemas } from '@rocket.chat/core-typings'; | ||
| import type { Route } from '@rocket.chat/http-router'; | ||
| import { isOpenAPIJSONEndpoint } from '@rocket.chat/rest-typings'; | ||
| import { ajv, isOpenAPIJSONEndpoint } from '@rocket.chat/rest-typings'; | ||
| import express from 'express'; | ||
| import { WebApp } from 'meteor/webapp'; | ||
| import swaggerUi from 'swagger-ui-express'; | ||
|
|
@@ -72,16 +72,35 @@ const makeOpenAPIResponse = (paths: Record<string, Record<string, Route>>) => ({ | |
| paths, | ||
| }); | ||
|
|
||
| API.default.addRoute( | ||
| const openApiResponseSchema = ajv.compile<Record<string, unknown>>({ | ||
| type: 'object', | ||
| properties: { | ||
| openapi: { type: 'string' }, | ||
| info: { type: 'object' }, | ||
| servers: { type: 'array' }, | ||
| components: { type: 'object' }, | ||
| paths: { type: 'object' }, | ||
| schemas: { type: 'object' }, | ||
| success: { type: 'boolean', enum: [true] }, | ||
| }, | ||
| required: ['openapi', 'info', 'paths', 'success'], | ||
| additionalProperties: false, | ||
| }); | ||
|
|
||
| API.default.get( | ||
| 'docs/json', | ||
| { authRequired: false, validateParams: isOpenAPIJSONEndpoint }, | ||
| { | ||
| get() { | ||
| const { withUndocumented = false } = this.queryParams; | ||
|
|
||
| return API.default.success(makeOpenAPIResponse(getTypedRoutes(API.api.typedRoutes, { withUndocumented }))); | ||
| authRequired: false, | ||
| query: isOpenAPIJSONEndpoint, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see |
||
| response: { | ||
| 200: openApiResponseSchema, | ||
| }, | ||
| }, | ||
| function action() { | ||
| const { withUndocumented = false } = this.queryParams; | ||
|
|
||
| return API.default.success(makeOpenAPIResponse(getTypedRoutes(API.api.typedRoutes, { withUndocumented }))); | ||
| }, | ||
| ); | ||
|
|
||
| app.use( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -640,7 +640,7 @@ API.v1.addRoute( | |
| const lm = room.lm ? room.lm : room._updatedAt; | ||
|
|
||
| if (subscription?.open) { | ||
| unreads = await Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, subscription.ls, lm); | ||
| unreads = await Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, subscription.ls ?? new Date(0), lm); | ||
| unreadsFrom = subscription.ls || subscription.ts; | ||
| userMentions = subscription.userMentions; | ||
| joined = true; | ||
|
Comment on lines
642
to
646
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check how groups.ts handles the same scenario
rg -n "countVisibleByRoomIdBetweenTimestampsInclusive" apps/meteor/app/api/server/v1/groups.ts -B2 -A2Repository: RocketChat/Rocket.Chat Length of output: 350 Replace The fallback value Suggested change-unreads = await Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, subscription.ls ?? new Date(0), lm);
+unreads = await Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, subscription.ls ?? subscription.ts, lm);Line 644 already uses 🤖 Prompt for AI Agents |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.