mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Working on test server
This commit is contained in:
parent
d85d968421
commit
4834c4f8af
@ -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 {
|
||||
//
|
||||
|
||||
20
test/server/src/controllers/DefaultsController.ts
Normal file
20
test/server/src/controllers/DefaultsController.ts
Normal 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!',
|
||||
};
|
||||
}
|
||||
}
|
||||
20
test/server/src/controllers/ParametersController.ts
Normal file
20
test/server/src/controllers/ParametersController.ts
Normal 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!',
|
||||
};
|
||||
}
|
||||
}
|
||||
20
test/server/src/controllers/ResponseController.ts
Normal file
20
test/server/src/controllers/ResponseController.ts
Normal 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!',
|
||||
};
|
||||
}
|
||||
}
|
||||
20
test/server/src/controllers/SimpleController.ts
Normal file
20
test/server/src/controllers/SimpleController.ts
Normal 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!',
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
|
||||
|
||||
6
test/server/src/models/ModelThatExtends.ts
Normal file
6
test/server/src/models/ModelThatExtends.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelThatExtends {
|
||||
@ApiProperty()
|
||||
prop?: number;
|
||||
}
|
||||
6
test/server/src/models/ModelThatExtendsExtends.ts
Normal file
6
test/server/src/models/ModelThatExtendsExtends.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelThatExtendsExtends {
|
||||
@ApiProperty()
|
||||
prop?: number;
|
||||
}
|
||||
6
test/server/src/models/ModelWithArray.ts
Normal file
6
test/server/src/models/ModelWithArray.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelWithArray {
|
||||
@ApiProperty()
|
||||
prop?: number;
|
||||
}
|
||||
6
test/server/src/models/ModelWithBoolean.ts
Normal file
6
test/server/src/models/ModelWithBoolean.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelWithBoolean {
|
||||
@ApiProperty()
|
||||
prop?: number;
|
||||
}
|
||||
6
test/server/src/models/ModelWithDictionary.ts
Normal file
6
test/server/src/models/ModelWithDictionary.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelWithDictionary {
|
||||
@ApiProperty()
|
||||
prop?: number;
|
||||
}
|
||||
6
test/server/src/models/ModelWithInteger.ts
Normal file
6
test/server/src/models/ModelWithInteger.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelWithInteger {
|
||||
@ApiProperty()
|
||||
prop?: number;
|
||||
}
|
||||
6
test/server/src/models/ModelWithPattern.ts
Normal file
6
test/server/src/models/ModelWithPattern.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelWithPattern {
|
||||
@ApiProperty()
|
||||
prop?: number;
|
||||
}
|
||||
6
test/server/src/models/ModelWithProperties.ts
Normal file
6
test/server/src/models/ModelWithProperties.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelWithProperties {
|
||||
@ApiProperty()
|
||||
prop?: number;
|
||||
}
|
||||
6
test/server/src/models/ModelWithReference.ts
Normal file
6
test/server/src/models/ModelWithReference.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelWithReference {
|
||||
@ApiProperty()
|
||||
prop?: number;
|
||||
}
|
||||
6
test/server/src/models/ModelWithString.ts
Normal file
6
test/server/src/models/ModelWithString.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ModelWithString {
|
||||
@ApiProperty()
|
||||
prop?: string;
|
||||
}
|
||||
@ -24,7 +24,7 @@
|
||||
},
|
||||
|
||||
"include": [
|
||||
"./src/main.ts"
|
||||
"./src/**/*.ts"
|
||||
],
|
||||
|
||||
"exclude": [
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
],
|
||||
|
||||
"include": [
|
||||
"./src/index.ts"
|
||||
"./src/**/*.ts"
|
||||
],
|
||||
|
||||
"exclude": [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user