Fix pretty doc
This commit is contained in:
@@ -33,27 +33,27 @@ export class SwaggerController extends BaseHttpController {
|
||||
info: {
|
||||
title: "WorkAdventure Pusher",
|
||||
version: "1.0.0",
|
||||
description: "This is a documentation about the endpoints called by the pusher. \n You can find out more about WorkAdventure on [github](https://github.com/thecodingmachine/workadventure).",
|
||||
contact:
|
||||
{
|
||||
email: "hello@workadventu.re"
|
||||
}
|
||||
description:
|
||||
"This is a documentation about the endpoints called by the pusher. \n You can find out more about WorkAdventure on [github](https://github.com/thecodingmachine/workadventure).",
|
||||
contact: {
|
||||
email: "hello@workadventu.re",
|
||||
},
|
||||
},
|
||||
"host": "pusher." + ADMIN_URL.replace('//',''),
|
||||
"tags": [
|
||||
host: "pusher." + ADMIN_URL.replace("//", ""),
|
||||
tags: [
|
||||
{
|
||||
"name": "AdminAPI",
|
||||
"description": "Access to end points of the admin from the pusher"
|
||||
name: "AdminAPI",
|
||||
description: "Access to end points of the admin from the pusher",
|
||||
},
|
||||
],
|
||||
"securityDefinitions": {
|
||||
"Bearer": {
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
securityDefinitions: {
|
||||
Bearer: {
|
||||
type: "apiKey",
|
||||
name: "Authorization",
|
||||
in: "header",
|
||||
},
|
||||
},
|
||||
...SwaggerGenerator.definitions()
|
||||
...SwaggerGenerator.definitions(),
|
||||
},
|
||||
apis: ["./src/Services/*.ts"],
|
||||
};
|
||||
@@ -81,11 +81,14 @@ export class SwaggerController extends BaseHttpController {
|
||||
}
|
||||
|
||||
const urls = [
|
||||
{url: "/openapi/pusher", name: "Front -> Pusher"},
|
||||
{url: "/openapi/admin", name: "Pusher <- Admin"},
|
||||
{ url: "/openapi/pusher", name: "Front -> Pusher" },
|
||||
{ url: "/openapi/admin", name: "Pusher <- Admin" },
|
||||
];
|
||||
|
||||
const result = data.replace(/url: "https:\/\/petstore\.swagger\.io\/v2\/swagger.json"/g, `urls: ${JSON.stringify(urls)}, "urls.primaryName": "Pusher <- Admin"`);
|
||||
const result = data.replace(
|
||||
/url: "https:\/\/petstore\.swagger\.io\/v2\/swagger.json"/g,
|
||||
`urls: ${JSON.stringify(urls)}, "urls.primaryName": "Pusher <- Admin"`
|
||||
);
|
||||
response.send(result);
|
||||
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import {extendApi} from "@anatine/zod-openapi";
|
||||
import { extendApi } from "@anatine/zod-openapi";
|
||||
|
||||
export const isBanBannedAdminMessageInterface = z.object({
|
||||
type: z.enum(["ban", "banned"]),
|
||||
@@ -9,7 +9,7 @@ export const isBanBannedAdminMessageInterface = z.object({
|
||||
|
||||
export const isUserMessageAdminMessageInterface = z.object({
|
||||
event: z.enum(["user-message"]),
|
||||
message: extendApi(isBanBannedAdminMessageInterface, {$ref: "#/definitions/BanBannedAdminMessageInterface"}),
|
||||
message: extendApi(isBanBannedAdminMessageInterface, { $ref: "#/definitions/BanBannedAdminMessageInterface" }),
|
||||
world: z.string(),
|
||||
jwt: z.string(),
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ import qs from "qs";
|
||||
import { AdminInterface } from "./AdminInterface";
|
||||
import { AuthTokenData, jwtTokenManager } from "./JWTTokenManager";
|
||||
import { InvalidTokenError } from "../Controller/InvalidTokenError";
|
||||
import {extendApi} from "@anatine/zod-openapi";
|
||||
import { extendApi } from "@anatine/zod-openapi";
|
||||
|
||||
export interface AdminBannedData {
|
||||
is_banned: boolean;
|
||||
@@ -18,15 +18,30 @@ export interface AdminBannedData {
|
||||
|
||||
export const isFetchMemberDataByUuidResponse = z.object({
|
||||
// @ts-ignore
|
||||
email: extendApi(z.string(), {description: 'The email of the fetched user, it can be an email, an uuid or undefined.', example: "example@workadventu.re"}),
|
||||
userUuid: extendApi(z.string(), {description: 'The uuid of the fetched user, it can be an email, an uuid or undefined.', example: "998ce839-3dea-4698-8b41-ebbdf7688ad9"}),
|
||||
tags: extendApi(z.array(z.string()), {description: 'List of tags related to the user fetched.', example: ['editor']}),
|
||||
visitCardUrl: extendApi(z.nullable(z.string()), {description: 'URL of the visitCard of the user fetched.', example: 'https://mycompany.com/contact/me'}),
|
||||
textures: extendApi(z.array(isWokaDetail), {$ref: "#/definitions/WokaDetail"}),
|
||||
messages: extendApi(z.array(z.unknown()), {description: 'List of user\'s messages.'}),
|
||||
email: extendApi(z.string(), {
|
||||
description: "The email of the fetched user, it can be an email, an uuid or undefined.",
|
||||
example: "example@workadventu.re",
|
||||
}),
|
||||
userUuid: extendApi(z.string(), {
|
||||
description: "The uuid of the fetched user, it can be an email, an uuid or undefined.",
|
||||
example: "998ce839-3dea-4698-8b41-ebbdf7688ad9",
|
||||
}),
|
||||
tags: extendApi(z.array(z.string()), {
|
||||
description: "List of tags related to the user fetched.",
|
||||
example: ["editor"],
|
||||
}),
|
||||
visitCardUrl: extendApi(z.nullable(z.string()), {
|
||||
description: "URL of the visitCard of the user fetched.",
|
||||
example: "https://mycompany.com/contact/me",
|
||||
}),
|
||||
textures: extendApi(z.array(isWokaDetail), { $ref: "#/definitions/WokaDetail" }),
|
||||
messages: extendApi(z.array(z.unknown()), { description: "List of user's messages." }),
|
||||
|
||||
anonymous: extendApi(z.optional(z.boolean()), {description: 'Whether the user if logged as anonymous or not', example: false}),
|
||||
userRoomToken: extendApi(z.optional(z.string()), {description: '', example: ''}),
|
||||
anonymous: extendApi(z.optional(z.boolean()), {
|
||||
description: "Whether the user if logged as anonymous or not",
|
||||
example: false,
|
||||
}),
|
||||
userRoomToken: extendApi(z.optional(z.string()), { description: "", example: "" }),
|
||||
});
|
||||
|
||||
export type FetchMemberDataByUuidResponse = z.infer<typeof isFetchMemberDataByUuidResponse>;
|
||||
|
||||
@@ -1,40 +1,33 @@
|
||||
import {generateSchema} from "@anatine/zod-openapi";
|
||||
import {isAdminApiData} from "../Messages/JsonMessages/AdminApiData";
|
||||
import { generateSchema } from "@anatine/zod-openapi";
|
||||
import { isAdminApiData } from "../Messages/JsonMessages/AdminApiData";
|
||||
import {
|
||||
isErrorApiErrorData,
|
||||
isErrorApiRedirectData,
|
||||
isErrorApiRetryData,
|
||||
isErrorApiUnauthorizedData
|
||||
isErrorApiUnauthorizedData,
|
||||
} from "../Messages/JsonMessages/ErrorApiData";
|
||||
import {isMapDetailsData} from "../Messages/JsonMessages/MapDetailsData";
|
||||
import {isRegisterData} from "../Messages/JsonMessages/RegisterData";
|
||||
import {isRoomRedirect} from "../Messages/JsonMessages/RoomRedirect";
|
||||
import {isFetchMemberDataByUuidResponse} from "./AdminApi";
|
||||
import {
|
||||
isBanBannedAdminMessageInterface, isListenRoomsMessageInterface,
|
||||
isUserMessageAdminMessageInterface
|
||||
} from "../Model/Websocket/Admin/AdminMessages";
|
||||
import {isWokaDetail} from "../Messages/JsonMessages/PlayerTextures";
|
||||
import { isMapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||
import { isFetchMemberDataByUuidResponse } from "./AdminApi";
|
||||
import { isWokaDetail } from "../Messages/JsonMessages/PlayerTextures";
|
||||
|
||||
class SwaggerGenerator {
|
||||
definitions() {
|
||||
return {
|
||||
definitions:
|
||||
{
|
||||
AdminApiData: generateSchema(isAdminApiData),
|
||||
//BanBannedAdminMessageInterface: generateSchema(isBanBannedAdminMessageInterface),
|
||||
ErrorApiErrorData: generateSchema(isErrorApiErrorData),
|
||||
ErrorApiRedirectData: generateSchema(isErrorApiRedirectData),
|
||||
ErrorApiRetryData: generateSchema(isErrorApiRetryData),
|
||||
ErrorApiUnauthorizedData: generateSchema(isErrorApiUnauthorizedData),
|
||||
FetchMemberDataByUuidResponse: generateSchema(isFetchMemberDataByUuidResponse),
|
||||
//ListenRoomsMessageInterface: generateSchema(isListenRoomsMessageInterface),
|
||||
MapDetailsData: generateSchema(isMapDetailsData),
|
||||
//RegisterData: generateSchema(isRegisterData),
|
||||
//RoomRedirect: generateSchema(isRoomRedirect),
|
||||
//UserMessageAdminMessageInterface: generateSchema(isUserMessageAdminMessageInterface),
|
||||
WokaDetail: generateSchema(isWokaDetail),
|
||||
}
|
||||
definitions: {
|
||||
AdminApiData: generateSchema(isAdminApiData),
|
||||
//BanBannedAdminMessageInterface: generateSchema(isBanBannedAdminMessageInterface),
|
||||
ErrorApiErrorData: generateSchema(isErrorApiErrorData),
|
||||
ErrorApiRedirectData: generateSchema(isErrorApiRedirectData),
|
||||
ErrorApiRetryData: generateSchema(isErrorApiRetryData),
|
||||
ErrorApiUnauthorizedData: generateSchema(isErrorApiUnauthorizedData),
|
||||
FetchMemberDataByUuidResponse: generateSchema(isFetchMemberDataByUuidResponse),
|
||||
//ListenRoomsMessageInterface: generateSchema(isListenRoomsMessageInterface),
|
||||
MapDetailsData: generateSchema(isMapDetailsData),
|
||||
//RegisterData: generateSchema(isRegisterData),
|
||||
//RoomRedirect: generateSchema(isRoomRedirect),
|
||||
//UserMessageAdminMessageInterface: generateSchema(isUserMessageAdminMessageInterface),
|
||||
WokaDetail: generateSchema(isWokaDetail),
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user