Skip to content

Commit 4834c4f

Browse files
committed
- Working on test server
1 parent d85d968 commit 4834c4f

18 files changed

+153
-11
lines changed

test/server/src/AppModule.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { Module } from '@nestjs/common';
22

3+
import { DefaultsController } from './controllers/DefaultsController';
4+
import { ParametersController } from './controllers/ParametersController';
5+
import { ResponseController } from './controllers/ResponseController';
6+
import { SimpleController } from './controllers/SimpleController';
7+
38
@Module({
4-
controllers: [],
9+
controllers: [SimpleController, ParametersController, DefaultsController, ResponseController],
510
})
611
export class AppModule {
712
//
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Controller, Get, Param } from '@nestjs/common';
2+
import { ApiResponse, ApiTags } from '@nestjs/swagger';
3+
4+
import { ModelWithString } from '../models/ModelWithString';
5+
6+
/* eslint-disable @typescript-eslint/no-unused-vars */
7+
@ApiTags('defaults')
8+
@Controller('defaults')
9+
export class DefaultsController {
10+
@Get('monkey')
11+
@ApiResponse({
12+
status: 200,
13+
type: ModelWithString,
14+
})
15+
monkey(@Param('id') id: string): ModelWithString {
16+
return {
17+
prop: 'Hello World!',
18+
};
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Controller, Get, Param } from '@nestjs/common';
2+
import { ApiResponse, ApiTags } from '@nestjs/swagger';
3+
4+
import { ModelWithString } from '../models/ModelWithString';
5+
6+
/* eslint-disable @typescript-eslint/no-unused-vars */
7+
@ApiTags('parameters')
8+
@Controller('parameters')
9+
export class ParametersController {
10+
@Get('monkey')
11+
@ApiResponse({
12+
status: 200,
13+
type: ModelWithString,
14+
})
15+
monkey(@Param('id') id: string): ModelWithString {
16+
return {
17+
prop: 'Hello World!',
18+
};
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Controller, Get, Param } from '@nestjs/common';
2+
import { ApiResponse, ApiTags } from '@nestjs/swagger';
3+
4+
import { ModelWithString } from '../models/ModelWithString';
5+
6+
/* eslint-disable @typescript-eslint/no-unused-vars */
7+
@ApiTags('response')
8+
@Controller('response')
9+
export class ResponseController {
10+
@Get('monkey')
11+
@ApiResponse({
12+
status: 200,
13+
type: ModelWithString,
14+
})
15+
monkey(@Param('id') id: string): ModelWithString {
16+
return {
17+
prop: 'Hello World!',
18+
};
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Controller, Get, Param } from '@nestjs/common';
2+
import { ApiResponse, ApiTags } from '@nestjs/swagger';
3+
4+
import { ModelWithString } from '../models/ModelWithString';
5+
6+
/* eslint-disable @typescript-eslint/no-unused-vars */
7+
@ApiTags('simple')
8+
@Controller('simple')
9+
export class SimpleController {
10+
@Get('monkey')
11+
@ApiResponse({
12+
status: 200,
13+
type: ModelWithString,
14+
})
15+
monkey(@Param('id') id: string): ModelWithString {
16+
return {
17+
prop: 'Hello World!',
18+
};
19+
}
20+
}

test/server/src/main.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import {NestFactory} from '@nestjs/core';
2-
import {DocumentBuilder, SwaggerModule} from '@nestjs/swagger';
3-
import {AppModule} from './AppModule';
1+
import { NestFactory } from '@nestjs/core';
2+
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
3+
4+
import { AppModule } from './AppModule';
45

56
async function bootstrap(): Promise<void> {
67
const app = await NestFactory.create(AppModule);
78

8-
const options = new DocumentBuilder()
9-
.setTitle('OpenAPI')
10-
.setDescription('The OpenAPI description')
11-
.setVersion('1.0')
12-
.build();
9+
const options = new DocumentBuilder().setTitle('OpenAPI').setDescription('The OpenAPI description').setVersion('1.0').build();
1310

1411
const document = SwaggerModule.createDocument(app, options);
1512

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
3+
export class ModelThatExtends {
4+
@ApiProperty()
5+
prop?: number;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
3+
export class ModelThatExtendsExtends {
4+
@ApiProperty()
5+
prop?: number;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
3+
export class ModelWithArray {
4+
@ApiProperty()
5+
prop?: number;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
3+
export class ModelWithBoolean {
4+
@ApiProperty()
5+
prop?: number;
6+
}

0 commit comments

Comments
 (0)