- Working on test server

This commit is contained in:
Ferdi Koomen 2020-09-24 16:22:33 +02:00
parent d85d968421
commit 4834c4f8af
18 changed files with 153 additions and 11 deletions

View File

@ -1,7 +1,12 @@
import { Module } from '@nestjs/common';
import { DefaultsController } from './controllers/DefaultsController';
import { ParametersController } from './controllers/ParametersController';
import { ResponseController } from './controllers/ResponseController';
import { SimpleController } from './controllers/SimpleController';
@Module({
controllers: [],
controllers: [SimpleController, ParametersController, DefaultsController, ResponseController],
})
export class AppModule {
//

View File

@ -0,0 +1,20 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ApiResponse, ApiTags } from '@nestjs/swagger';
import { ModelWithString } from '../models/ModelWithString';
/* eslint-disable @typescript-eslint/no-unused-vars */
@ApiTags('defaults')
@Controller('defaults')
export class DefaultsController {
@Get('monkey')
@ApiResponse({
status: 200,
type: ModelWithString,
})
monkey(@Param('id') id: string): ModelWithString {
return {
prop: 'Hello World!',
};
}
}

View File

@ -0,0 +1,20 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ApiResponse, ApiTags } from '@nestjs/swagger';
import { ModelWithString } from '../models/ModelWithString';
/* eslint-disable @typescript-eslint/no-unused-vars */
@ApiTags('parameters')
@Controller('parameters')
export class ParametersController {
@Get('monkey')
@ApiResponse({
status: 200,
type: ModelWithString,
})
monkey(@Param('id') id: string): ModelWithString {
return {
prop: 'Hello World!',
};
}
}

View File

@ -0,0 +1,20 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ApiResponse, ApiTags } from '@nestjs/swagger';
import { ModelWithString } from '../models/ModelWithString';
/* eslint-disable @typescript-eslint/no-unused-vars */
@ApiTags('response')
@Controller('response')
export class ResponseController {
@Get('monkey')
@ApiResponse({
status: 200,
type: ModelWithString,
})
monkey(@Param('id') id: string): ModelWithString {
return {
prop: 'Hello World!',
};
}
}

View File

@ -0,0 +1,20 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ApiResponse, ApiTags } from '@nestjs/swagger';
import { ModelWithString } from '../models/ModelWithString';
/* eslint-disable @typescript-eslint/no-unused-vars */
@ApiTags('simple')
@Controller('simple')
export class SimpleController {
@Get('monkey')
@ApiResponse({
status: 200,
type: ModelWithString,
})
monkey(@Param('id') id: string): ModelWithString {
return {
prop: 'Hello World!',
};
}
}

View File

@ -1,15 +1,12 @@
import {NestFactory} from '@nestjs/core';
import {DocumentBuilder, SwaggerModule} from '@nestjs/swagger';
import {AppModule} from './AppModule';
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './AppModule';
async function bootstrap(): Promise<void> {
const app = await NestFactory.create(AppModule);
const options = new DocumentBuilder()
.setTitle('OpenAPI')
.setDescription('The OpenAPI description')
.setVersion('1.0')
.build();
const options = new DocumentBuilder().setTitle('OpenAPI').setDescription('The OpenAPI description').setVersion('1.0').build();
const document = SwaggerModule.createDocument(app, options);

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelThatExtends {
@ApiProperty()
prop?: number;
}

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelThatExtendsExtends {
@ApiProperty()
prop?: number;
}

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelWithArray {
@ApiProperty()
prop?: number;
}

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelWithBoolean {
@ApiProperty()
prop?: number;
}

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelWithDictionary {
@ApiProperty()
prop?: number;
}

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelWithInteger {
@ApiProperty()
prop?: number;
}

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelWithPattern {
@ApiProperty()
prop?: number;
}

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelWithProperties {
@ApiProperty()
prop?: number;
}

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelWithReference {
@ApiProperty()
prop?: number;
}

View File

@ -0,0 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
export class ModelWithString {
@ApiProperty()
prop?: string;
}

View File

@ -24,7 +24,7 @@
},
"include": [
"./src/main.ts"
"./src/**/*.ts"
],
"exclude": [

View File

@ -26,7 +26,7 @@
],
"include": [
"./src/index.ts"
"./src/**/*.ts"
],
"exclude": [