Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Aug 19, 2024
1 parent 823a814 commit 498a410
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/Generator/Server/TypeScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function generateHeader(File $file, array $imports): string
$controller = 'import { Controller, Get, Post, Put, Patch, Delete, HttpCode, Param, Query, Headers, Body } from \'@nestjs/common\'' . "\n";

foreach ($imports as $className) {
$controller.= 'import {' . $className . '} from "' . $basePath . '/' . $className . '";' . "\n";
$controller.= 'import { ' . $className . ' } from "' . $basePath . '/' . $className . '";' . "\n";
}

$controller.= "\n";
Expand Down Expand Up @@ -130,6 +130,7 @@ protected function generateMethod(string $operationName, OperationInterface $ope
$method.= ' @HttpCode(' . $operation->getReturn()->getCode() . ')' . "\n";
$method.= ' ' . $operationName . '(' . implode(', ', $arguments) . '): ' . $returnType . ' {' . "\n";
$method.= ' // @TODO implement method' . "\n";
$method.= ' return {};' . "\n";
$method.= ' }' . "\n";
$method.= "\n";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,49 @@
*/

import { Controller, Get, Post, Put, Patch, Delete, HttpCode, Param, Query, Headers, Body } from '@nestjs/common'
import {Entry} from "../dto/Entry";
import {EntryCollection} from "../dto/EntryCollection";
import {EntryCreate} from "../dto/EntryCreate";
import {EntryMessage} from "../dto/EntryMessage";
import {EntryUpdate} from "../dto/EntryUpdate";
import {EntryDelete} from "../dto/EntryDelete";
import {EntryPatch} from "../dto/EntryPatch";
import { Entry } from "../dto/Entry";
import { EntryCollection } from "../dto/EntryCollection";
import { EntryCreate } from "../dto/EntryCreate";
import { EntryMessage } from "../dto/EntryMessage";
import { EntryUpdate } from "../dto/EntryUpdate";
import { EntryDelete } from "../dto/EntryDelete";
import { EntryPatch } from "../dto/EntryPatch";

@Controller()
export class AppController {
@Get('/foo/:name/:type')
@HttpCode(200)
get(@Param('name') name: string, @Param('type') type: string, @Query('startIndex') startIndex: number, @Query('float') float: number, @Query('boolean') boolean: boolean, @Query('date') date: string, @Query('datetime') datetime: string, @Query('args') args: Entry): EntryCollection {
// @TODO implement method
return {};
}

@Post('/foo/:name/:type')
@HttpCode(201)
create(@Param('name') name: string, @Param('type') type: string, @Body() payload: EntryCreate): EntryMessage {
// @TODO implement method
return {};
}

@Put('/foo/:name/:type')
@HttpCode(200)
update(@Param('name') name: string, @Param('type') type: string, @Body() payload: Record<string, EntryUpdate>): Record<string, EntryMessage> {
// @TODO implement method
return {};
}

@Delete('/foo/:name/:type')
@HttpCode(204)
delete(@Param('name') name: string, @Param('type') type: string, @Body() payload: EntryDelete): EntryMessage {
// @TODO implement method
return {};
}

@Patch('/foo/:name/:type')
@HttpCode(200)
patch(@Param('name') name: string, @Param('type') type: string, @Body() payload: Array<EntryPatch>): Array<EntryMessage> {
// @TODO implement method
return {};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
*/

import { Controller, Get, Post, Put, Patch, Delete, HttpCode, Param, Query, Headers, Body } from '@nestjs/common'
import {EntryCollection} from "../dto/EntryCollection";
import {EntryCreate} from "../dto/EntryCreate";
import {EntryMessage} from "../dto/EntryMessage";
import { EntryCollection } from "../dto/EntryCollection";
import { EntryCreate } from "../dto/EntryCreate";
import { EntryMessage } from "../dto/EntryMessage";

@Controller()
export class BarController {
@Get('/bar/:foo')
@HttpCode(200)
find(@Param('foo') foo: string): EntryCollection {
// @TODO implement method
return {};
}

@Post('/bar/:foo')
@HttpCode(201)
put(@Body() payload: EntryCreate): EntryMessage {
// @TODO implement method
return {};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
*/

import { Controller, Get, Post, Put, Patch, Delete, HttpCode, Param, Query, Headers, Body } from '@nestjs/common'
import {EntryCollection} from "../../dto/EntryCollection";
import {EntryCreate} from "../../dto/EntryCreate";
import {EntryMessage} from "../../dto/EntryMessage";
import { EntryCollection } from "../../dto/EntryCollection";
import { EntryCreate } from "../../dto/EntryCreate";
import { EntryMessage } from "../../dto/EntryMessage";

@Controller()
export class BarController {
@Get('/foo')
@HttpCode(200)
get(): EntryCollection {
// @TODO implement method
return {};
}

@Post('/foo')
@HttpCode(201)
create(@Body() payload: EntryCreate): EntryMessage {
// @TODO implement method
return {};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
*/

import { Controller, Get, Post, Put, Patch, Delete, HttpCode, Param, Query, Headers, Body } from '@nestjs/common'
import {EntryCollection} from "../../dto/EntryCollection";
import {EntryCreate} from "../../dto/EntryCreate";
import {EntryMessage} from "../../dto/EntryMessage";
import { EntryCollection } from "../../dto/EntryCollection";
import { EntryCreate } from "../../dto/EntryCreate";
import { EntryMessage } from "../../dto/EntryMessage";

@Controller()
export class BazController {
@Get('/bar/$year<[0-9]+>')
@HttpCode(200)
get(@Param('year') year: string): EntryCollection {
// @TODO implement method
return {};
}

@Post('/bar/$year<[0-9]+>')
@HttpCode(201)
create(@Body() payload: EntryCreate): EntryMessage {
// @TODO implement method
return {};
}

}

0 comments on commit 498a410

Please sign in to comment.