mirror of
https://github.com/swissmakers/swiss-datashare.git
synced 2026-04-11 10:27:01 +02:00
docs(backend): add swagger documentation
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { PickType } from "@nestjs/mapped-types";
|
||||
import { PickType } from "@nestjs/swagger";
|
||||
import { UserDTO } from "src/user/dto/user.dto";
|
||||
|
||||
export class AuthRegisterDTO extends PickType(UserDTO, [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PickType } from "@nestjs/mapped-types";
|
||||
import { PickType } from "@nestjs/swagger";
|
||||
import { IsEmail, IsOptional, IsString } from "class-validator";
|
||||
import { UserDTO } from "src/user/dto/user.dto";
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
import { PickType } from "@nestjs/mapped-types";
|
||||
import { IsEmail, IsOptional, IsString } from "class-validator";
|
||||
import { UserDTO } from "src/user/dto/user.dto";
|
||||
|
||||
export class AuthSignInTotpDTO extends PickType(UserDTO, [
|
||||
"password",
|
||||
] as const) {
|
||||
@IsEmail()
|
||||
@IsOptional()
|
||||
email: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
username: string;
|
||||
import { IsString } from "class-validator";
|
||||
import { AuthSignInDTO } from "./authSignIn.dto";
|
||||
|
||||
export class AuthSignInTotpDTO extends AuthSignInDTO {
|
||||
@IsString()
|
||||
totp: string;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PickType } from "@nestjs/mapped-types";
|
||||
import { PickType } from "@nestjs/swagger";
|
||||
import { UserDTO } from "src/user/dto/user.dto";
|
||||
|
||||
export class EnableTotpDTO extends PickType(UserDTO, ["password"] as const) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PickType } from "@nestjs/mapped-types";
|
||||
import { PickType } from "@nestjs/swagger";
|
||||
import { IsString } from "class-validator";
|
||||
import { UserDTO } from "src/user/dto/user.dto";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PickType } from "@nestjs/mapped-types";
|
||||
import { PickType } from "@nestjs/swagger";
|
||||
import { IsString } from "class-validator";
|
||||
import { UserDTO } from "src/user/dto/user.dto";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ClassSerializerInterceptor, ValidationPipe } from "@nestjs/common";
|
||||
import { NestFactory, Reflector } from "@nestjs/core";
|
||||
import { NestExpressApplication } from "@nestjs/platform-express";
|
||||
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
||||
import * as bodyParser from "body-parser";
|
||||
import * as cookieParser from "cookie-parser";
|
||||
import * as fs from "fs";
|
||||
@@ -18,6 +19,17 @@ async function bootstrap() {
|
||||
await fs.promises.mkdir("./data/uploads/_temp", { recursive: true });
|
||||
|
||||
app.setGlobalPrefix("api");
|
||||
|
||||
// Setup Swagger in development mode
|
||||
if (process.env.NODE_ENV == "development") {
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle("Pingvin Share API")
|
||||
.setVersion("1.0")
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup("api/swagger", app, document);
|
||||
}
|
||||
|
||||
await app.listen(8080);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OmitType } from "@nestjs/mapped-types";
|
||||
import { OmitType } from "@nestjs/swagger";
|
||||
import { Expose, plainToClass, Type } from "class-transformer";
|
||||
import { MyShareDTO } from "src/share/dto/myShare.dto";
|
||||
import { ReverseShareDTO } from "./reverseShare.dto";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PickType } from "@nestjs/mapped-types";
|
||||
import { PickType } from "@nestjs/swagger";
|
||||
import { UserDTO } from "./user.dto";
|
||||
|
||||
export class PublicUserDTO extends PickType(UserDTO, ["username"] as const) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OmitType, PartialType } from "@nestjs/mapped-types";
|
||||
import { OmitType, PartialType } from "@nestjs/swagger";
|
||||
import { UserDTO } from "./user.dto";
|
||||
|
||||
export class UpdateOwnUserDTO extends PartialType(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PartialType } from "@nestjs/mapped-types";
|
||||
import { PartialType } from "@nestjs/swagger";
|
||||
import { CreateUserDTO } from "./createUser.dto";
|
||||
|
||||
export class UpdateUserDto extends PartialType(CreateUserDTO) {}
|
||||
|
||||
Reference in New Issue
Block a user