mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-09 20:22:47 +01:00
Work towards fixing openapi spec
This commit is contained in:
parent
1fd01fa000
commit
0f928e479c
File diff suppressed because it is too large
Load Diff
7599
assets/schemas.json
7599
assets/schemas.json
File diff suppressed because it is too large
Load Diff
@ -85,13 +85,15 @@ function apiRoutes() {
|
|||||||
.map((x) => ({ name: x }));
|
.map((x) => ({ name: x }));
|
||||||
|
|
||||||
specification.components = specification.components || {};
|
specification.components = specification.components || {};
|
||||||
specification.components.securitySchemes = {
|
specification.components.securitySchemes = [
|
||||||
bearer: {
|
{
|
||||||
type: "http",
|
bearer: {
|
||||||
scheme: "bearer",
|
type: "http",
|
||||||
description: "Bearer/Bot prefixes are not required.",
|
scheme: "bearer",
|
||||||
|
description: "Bearer/Bot prefixes are not required.",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
];
|
||||||
|
|
||||||
routes.forEach((route, pathAndMethod) => {
|
routes.forEach((route, pathAndMethod) => {
|
||||||
const [p, method] = pathAndMethod.split("|");
|
const [p, method] = pathAndMethod.split("|");
|
||||||
@ -109,7 +111,7 @@ function apiRoutes() {
|
|||||||
return x.test(path);
|
return x.test(path);
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
obj.security = [{ bearer: true }];
|
obj.security = [{ bearer: [] }];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route.body) {
|
if (route.body) {
|
||||||
|
@ -91,9 +91,9 @@ function main() {
|
|||||||
if (!part) continue;
|
if (!part) continue;
|
||||||
|
|
||||||
// this is a hack. want some want to check if its a @column, instead
|
// this is a hack. want some want to check if its a @column, instead
|
||||||
if (part.properties)
|
if (part.properties) {
|
||||||
Object.keys(part.properties)
|
for (let key in part.properties) {
|
||||||
.filter((key) =>
|
if (
|
||||||
[
|
[
|
||||||
// BaseClass methods
|
// BaseClass methods
|
||||||
"toJSON",
|
"toJSON",
|
||||||
@ -104,9 +104,31 @@ function main() {
|
|||||||
"recover",
|
"recover",
|
||||||
"reload",
|
"reload",
|
||||||
"assign",
|
"assign",
|
||||||
].includes(key),
|
].includes(key)
|
||||||
)
|
) {
|
||||||
.forEach((key) => delete part.properties[key]);
|
delete part.properties[key];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (part.properties[key].anyOf) {
|
||||||
|
const nullIndex = part.properties[key].anyOf.findIndex(
|
||||||
|
(x) => x.type == "null",
|
||||||
|
);
|
||||||
|
if (nullIndex != -1) {
|
||||||
|
part.properties[key].nullable = true;
|
||||||
|
part.properties[key].anyOf.splice(nullIndex, 1);
|
||||||
|
|
||||||
|
if (part.properties[key].anyOf.length == 1) {
|
||||||
|
Object.assign(
|
||||||
|
part.properties[key],
|
||||||
|
part.properties[key].anyOf[0],
|
||||||
|
);
|
||||||
|
delete part.properties[key].anyOf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
definitions = { ...definitions, [name]: { ...part } };
|
definitions = { ...definitions, [name]: { ...part } };
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,6 @@ import { route, RouteOptions } from "@fosscord/api";
|
|||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
export interface GatewayBotResponse {
|
|
||||||
url: string;
|
|
||||||
shards: number;
|
|
||||||
session_start_limit: {
|
|
||||||
total: number;
|
|
||||||
remaining: number;
|
|
||||||
reset_after: number;
|
|
||||||
max_concurrency: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: RouteOptions = {
|
const options: RouteOptions = {
|
||||||
test: {
|
test: {
|
||||||
response: {
|
response: {
|
||||||
|
@ -22,10 +22,6 @@ import { route, RouteOptions } from "@fosscord/api";
|
|||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
export interface GatewayResponse {
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: RouteOptions = {
|
const options: RouteOptions = {
|
||||||
test: {
|
test: {
|
||||||
response: {
|
response: {
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
|
|
||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import {
|
import {
|
||||||
PublicConnectedAccount,
|
|
||||||
User,
|
User,
|
||||||
UserPublic,
|
|
||||||
Member,
|
Member,
|
||||||
UserProfileModifySchema,
|
UserProfileModifySchema,
|
||||||
handleFile,
|
handleFile,
|
||||||
@ -32,13 +30,6 @@ import { route } from "@fosscord/api";
|
|||||||
|
|
||||||
const router: Router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
export interface UserProfileResponse {
|
|
||||||
user: UserPublic;
|
|
||||||
connected_accounts: PublicConnectedAccount;
|
|
||||||
premium_guild_since?: Date;
|
|
||||||
premium_since?: Date;
|
|
||||||
}
|
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
"/",
|
"/",
|
||||||
route({ test: { response: { body: "UserProfileResponse" } } }),
|
route({ test: { response: { body: "UserProfileResponse" } } }),
|
||||||
|
@ -22,16 +22,6 @@ import { route } from "@fosscord/api";
|
|||||||
|
|
||||||
const router: Router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
export interface UserRelationsResponse {
|
|
||||||
object: {
|
|
||||||
id?: string;
|
|
||||||
username?: string;
|
|
||||||
avatar?: string;
|
|
||||||
discriminator?: string;
|
|
||||||
public_flags?: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
"/",
|
"/",
|
||||||
route({ test: { response: { body: "UserRelationsResponse" } } }),
|
route({ test: { response: { body: "UserRelationsResponse" } } }),
|
||||||
|
@ -111,7 +111,7 @@ export class User extends BaseClass {
|
|||||||
banner?: string; // hash of the user banner
|
banner?: string; // hash of the user banner
|
||||||
|
|
||||||
@Column({ nullable: true, type: "simple-array" })
|
@Column({ nullable: true, type: "simple-array" })
|
||||||
theme_colors?: number[]; // TODO: Separate `User` and `UserProfile` models
|
theme_colors?: [number, number]; // TODO: Separate `User` and `UserProfile` models
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
pronouns?: string;
|
pronouns?: string;
|
||||||
|
10
src/util/schemas/GatewayBotResponse.ts
Normal file
10
src/util/schemas/GatewayBotResponse.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export interface GatewayBotResponse {
|
||||||
|
url: string;
|
||||||
|
shards: number;
|
||||||
|
session_start_limit: {
|
||||||
|
total: number;
|
||||||
|
remaining: number;
|
||||||
|
reset_after: number;
|
||||||
|
max_concurrency: number;
|
||||||
|
};
|
||||||
|
}
|
3
src/util/schemas/GatewayResponse.ts
Normal file
3
src/util/schemas/GatewayResponse.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export interface GatewayResponse {
|
||||||
|
url: string;
|
||||||
|
}
|
8
src/util/schemas/UserProfileResponse.ts
Normal file
8
src/util/schemas/UserProfileResponse.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { PublicConnectedAccount, UserPublic } from "..";
|
||||||
|
|
||||||
|
export interface UserProfileResponse {
|
||||||
|
user: UserPublic;
|
||||||
|
connected_accounts: PublicConnectedAccount;
|
||||||
|
premium_guild_since?: Date;
|
||||||
|
premium_since?: Date;
|
||||||
|
}
|
9
src/util/schemas/UserRelationsResponse.ts
Normal file
9
src/util/schemas/UserRelationsResponse.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export interface UserRelationsResponse {
|
||||||
|
object: {
|
||||||
|
id?: string;
|
||||||
|
username?: string;
|
||||||
|
avatar?: string;
|
||||||
|
discriminator?: string;
|
||||||
|
public_flags?: number;
|
||||||
|
};
|
||||||
|
}
|
@ -76,3 +76,7 @@ export * from "./VoiceVideoSchema";
|
|||||||
export * from "./WebAuthnSchema";
|
export * from "./WebAuthnSchema";
|
||||||
export * from "./WebhookCreateSchema";
|
export * from "./WebhookCreateSchema";
|
||||||
export * from "./WidgetModifySchema";
|
export * from "./WidgetModifySchema";
|
||||||
|
export * from "./UserRelationsResponse";
|
||||||
|
export * from "./GatewayResponse";
|
||||||
|
export * from "./GatewayBotResponse";
|
||||||
|
export * from "./UserProfileResponse";
|
||||||
|
Loading…
Reference in New Issue
Block a user