Skip to content

Commit 4e3e435

Browse files
committed
Add UpdateMemeOrderDto interface and related API endpoint
- Introduced UpdateMemeOrderDto interface to define the structure for updating meme orders. - Added a new PUT endpoint in RandomMeme for updating meme orders, including request and response specifications in Swagger. - Updated getControllersFromSwagger function to include tags from API methods, excluding those containing "hub".
1 parent 6f4a329 commit 4e3e435

File tree

7 files changed

+216
-5
lines changed

7 files changed

+216
-5
lines changed

api/swagger_api.json

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,6 +3112,118 @@
31123112
}
31133113
}
31143114
},
3115+
"put": {
3116+
"tags": [
3117+
"RandomMeme"
3118+
],
3119+
"parameters": [
3120+
{
3121+
"name": "id",
3122+
"in": "path",
3123+
"required": true,
3124+
"schema": {
3125+
"type": "string",
3126+
"format": "uuid"
3127+
}
3128+
}
3129+
],
3130+
"requestBody": {
3131+
"content": {
3132+
"application/json": {
3133+
"schema": {
3134+
"allOf": [
3135+
{
3136+
"$ref": "#/components/schemas/UpdateMemeOrderDto"
3137+
}
3138+
]
3139+
}
3140+
},
3141+
"text/json": {
3142+
"schema": {
3143+
"allOf": [
3144+
{
3145+
"$ref": "#/components/schemas/UpdateMemeOrderDto"
3146+
}
3147+
]
3148+
}
3149+
},
3150+
"application/*+json": {
3151+
"schema": {
3152+
"allOf": [
3153+
{
3154+
"$ref": "#/components/schemas/UpdateMemeOrderDto"
3155+
}
3156+
]
3157+
}
3158+
}
3159+
}
3160+
},
3161+
"responses": {
3162+
"200": {
3163+
"description": "OK",
3164+
"content": {
3165+
"text/plain": {
3166+
"schema": {
3167+
"$ref": "#/components/schemas/MemeOrderDto"
3168+
}
3169+
},
3170+
"application/json": {
3171+
"schema": {
3172+
"$ref": "#/components/schemas/MemeOrderDto"
3173+
}
3174+
},
3175+
"text/json": {
3176+
"schema": {
3177+
"$ref": "#/components/schemas/MemeOrderDto"
3178+
}
3179+
}
3180+
}
3181+
},
3182+
"400": {
3183+
"description": "Bad Request",
3184+
"content": {
3185+
"text/plain": {
3186+
"schema": {
3187+
"$ref": "#/components/schemas/ProblemDetails"
3188+
}
3189+
},
3190+
"application/json": {
3191+
"schema": {
3192+
"$ref": "#/components/schemas/ProblemDetails"
3193+
}
3194+
},
3195+
"text/json": {
3196+
"schema": {
3197+
"$ref": "#/components/schemas/ProblemDetails"
3198+
}
3199+
}
3200+
}
3201+
},
3202+
"404": {
3203+
"description": "Not Found",
3204+
"content": {
3205+
"text/plain": {
3206+
"schema": {
3207+
"$ref": "#/components/schemas/ProblemDetails"
3208+
}
3209+
},
3210+
"application/json": {
3211+
"schema": {
3212+
"$ref": "#/components/schemas/ProblemDetails"
3213+
}
3214+
},
3215+
"text/json": {
3216+
"schema": {
3217+
"$ref": "#/components/schemas/ProblemDetails"
3218+
}
3219+
}
3220+
}
3221+
},
3222+
"500": {
3223+
"description": "Internal Server Error"
3224+
}
3225+
}
3226+
},
31153227
"delete": {
31163228
"tags": [
31173229
"RandomMeme"
@@ -5815,6 +5927,31 @@
58155927
},
58165928
"additionalProperties": false
58175929
},
5930+
"UpdateMemeOrderDto": {
5931+
"required": [
5932+
"filePath",
5933+
"order"
5934+
],
5935+
"type": "object",
5936+
"properties": {
5937+
"filePath": {
5938+
"minLength": 1,
5939+
"type": "string"
5940+
},
5941+
"memeTypeId": {
5942+
"type": "integer",
5943+
"format": "int32",
5944+
"nullable": true
5945+
},
5946+
"order": {
5947+
"maximum": 2147483647,
5948+
"minimum": 1,
5949+
"type": "integer",
5950+
"format": "int32"
5951+
}
5952+
},
5953+
"additionalProperties": false
5954+
},
58185955
"UpdateMemeTypeDto": {
58195956
"required": [
58205957
"folderPath",

build-api.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ function getControllersFromSwagger(swaggerSource) {
88
const controllers = new Set();
99

1010
Object.keys(swaggerSource.paths).forEach(path => {
11-
const match = path.match(/^\/api\/([^\\/]+)/);
12-
if (match) {
13-
controllers.add(match[1]);
14-
}
11+
const pathData = swaggerSource.paths[path];
12+
13+
// Проверяем все методы в пути
14+
Object.values(pathData).forEach(methodData => {
15+
if (methodData.tags && Array.isArray(methodData.tags)) {
16+
methodData.tags.forEach(tag => {
17+
if (tag && !tag.toLowerCase().includes("hub")) {
18+
// Добавляем тег как контроллер, если это не хаб
19+
controllers.add(tag);
20+
}
21+
});
22+
}
23+
});
1524
});
1625

1726
return Array.from(controllers);

src/shared/api/data-contracts/data-contracts.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,19 @@ export enum UpdateMediaItemRequestStatusEnum {
687687
Postponed = "Postponed",
688688
}
689689

690+
export interface UpdateMemeOrderDto {
691+
/** @minLength 1 */
692+
filePath: string;
693+
/** @format int32 */
694+
memeTypeId?: number;
695+
/**
696+
* @format int32
697+
* @min 1
698+
* @max 2147483647
699+
*/
700+
order: number;
701+
}
702+
690703
export interface UpdateMemeTypeDto {
691704
/** @minLength 1 */
692705
folderPath: string;

src/shared/api/http-clients/RandomMeme.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
MemeOrderDto,
1717
MemeTypeDto,
1818
ProblemDetails,
19+
UpdateMemeOrderDto,
1920
UpdateMemeTypeDto,
2021
} from "./data-contracts";
2122
import { ContentType, HttpClient, RequestParams } from "./http-client";
@@ -190,6 +191,30 @@ export class RandomMeme<
190191
format: "json",
191192
...params,
192193
});
194+
/**
195+
* No description
196+
*
197+
* @tags RandomMeme
198+
* @name RandomMemeOrdersUpdate
199+
* @request PUT:/api/RandomMeme/orders/{id}
200+
* @response `200` `MemeOrderDto` OK
201+
* @response `400` `ProblemDetails` Bad Request
202+
* @response `404` `ProblemDetails` Not Found
203+
* @response `500` `void` Internal Server Error
204+
*/
205+
randomMemeOrdersUpdate = (
206+
id: string,
207+
data: UpdateMemeOrderDto,
208+
params: RequestParams = {},
209+
) =>
210+
this.request<MemeOrderDto, ProblemDetails | void>({
211+
path: `/api/RandomMeme/orders/${id}`,
212+
method: "PUT",
213+
body: data,
214+
type: ContentType.Json,
215+
format: "json",
216+
...params,
217+
});
193218
/**
194219
* No description
195220
*

src/shared/api/http-clients/data-contracts.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,19 @@ export interface UpdateMediaItemRequest {
545545
isNext?: boolean;
546546
}
547547

548+
export interface UpdateMemeOrderDto {
549+
/** @minLength 1 */
550+
filePath: string;
551+
/** @format int32 */
552+
memeTypeId?: number;
553+
/**
554+
* @format int32
555+
* @min 1
556+
* @max 2147483647
557+
*/
558+
order: number;
559+
}
560+
548561
export interface UpdateMemeTypeDto {
549562
/**
550563
* @minLength 1

src/shared/api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Автоматически сгенерированный индексный файл
2-
32
// Импорты утилит конфигурации
43
export * from "./api-config";
54

@@ -18,9 +17,11 @@ export { FramedataChanges } from "./http-clients/FramedataChanges";
1817
export { Honkai } from "./http-clients/Honkai";
1918
export { KeyboardHook } from "./http-clients/KeyboardHook";
2019
export { MediaInfoApi } from "./http-clients/MediaInfoApi";
20+
export { PyroAlerts } from "./http-clients/PyroAlerts";
2121
export { RandomMeme } from "./http-clients/RandomMeme";
2222
export { RxdcodxViewers } from "./http-clients/RxdcodxViewers";
2323
export { ServiceManager } from "./http-clients/ServiceManager";
24+
export { Twitch } from "./http-clients/Twitch";
2425
export { TwitchRewards } from "./http-clients/TwitchRewards";
2526

2627
// Импорты SignalR клиентов

src/shared/api/types/types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,19 @@ export enum UpdateMediaItemRequestStatusEnum {
687687
Postponed = "Postponed",
688688
}
689689

690+
export interface UpdateMemeOrderDto {
691+
/** @minLength 1 */
692+
filePath: string;
693+
/** @format int32 */
694+
memeTypeId?: number;
695+
/**
696+
* @format int32
697+
* @min 1
698+
* @max 2147483647
699+
*/
700+
order: number;
701+
}
702+
690703
export interface UpdateMemeTypeDto {
691704
/** @minLength 1 */
692705
folderPath: string;

0 commit comments

Comments
 (0)