summary refs log tree commit diff
path: root/api/scripts/generate_openapi_schema.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-18 01:49:36 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-18 01:49:36 +0200
commitf9a3eedebdeba452ffda225709399b951f3675a3 (patch)
tree5a4b9e983bbc105ac91736f819163d684a7e6709 /api/scripts/generate_openapi_schema.ts
parent:pencil: add default route description to all routes (diff)
downloadserver-f9a3eedebdeba452ffda225709399b951f3675a3.tar.xz
:sparkles: generate test responses
Diffstat (limited to 'api/scripts/generate_openapi_schema.ts')
-rw-r--r--api/scripts/generate_openapi_schema.ts41
1 files changed, 17 insertions, 24 deletions
diff --git a/api/scripts/generate_openapi_schema.ts b/api/scripts/generate_openapi_schema.ts

index 329aeaf4..c0995b6c 100644 --- a/api/scripts/generate_openapi_schema.ts +++ b/api/scripts/generate_openapi_schema.ts
@@ -48,34 +48,27 @@ function combineSchemas(opts: { program: TJS.Program; generator: TJS.JsonSchemaG return definitions; } +const ExcludedSchemas = [ + "DefaultSchema", + "Schema", + "EntitySchema", + "ServerResponse", + "Http2ServerResponse", + "global.Express.Response", + "Response", + "e.Response", + "request.Response", + "supertest.Response" +]; + function apiSchemas() { const program = TJS.getProgramFromFiles([path.join(__dirname, "..", "src", "schema", "index.ts")], compilerOptions); const generator = TJS.buildGenerator(program, settings); - const schemas = [ - "BanCreateSchema", - "DmChannelCreateSchema", - "ChannelModifySchema", - "ChannelGuildPositionUpdateSchema", - "ChannelGuildPositionUpdateSchema", - "EmojiCreateSchema", - "GuildCreateSchema", - "GuildUpdateSchema", - "GuildTemplateCreateSchema", - "GuildUpdateWelcomeScreenSchema", - "InviteCreateSchema", - "MemberCreateSchema", - "MemberNickChangeSchema", - "MemberChangeSchema", - "MessageCreateSchema", - "RoleModifySchema", - "TemplateCreateSchema", - "TemplateModifySchema", - "UserModifySchema", - "UserSettingsSchema", - "WidgetModifySchema", - "" - ]; + const schemas = generator + .getUserSymbols() + .filter((x) => x.endsWith("Response") && !ExcludedSchemas.includes(x)) + .concat(generator.getUserSymbols().filter((x) => x.endsWith("Schema") && !ExcludedSchemas.includes(x))); // @ts-ignore combineSchemas({ schemas, generator, program });