Open techsavvyash opened 4 months ago
@Savio629 the decorators don't seem to have types on them, this won't generate the swagger documentation properly on it's own, without types these decorators don't add much value.
Yeah actual working on it as well. Forgot to leave a comment.
Regarding the types, I'll have to retrieve it from the methods itself right?
@ApiOperation({ summary: 'Create an item' })
@ApiBody({ type: CreateBook1Dto, description: 'Item data' })
@ApiResponse({ status: 201, description: 'Item created', type: Book1 })
@Post()
async create(@Body() book1Dto: CreateBook1Dto): Promise<Book1> {
return this.book1Service.create(book1Dto);
}
Right now I'm generating the swagger decorators from a basic template
yes you would have to get them from the function parameter and return types. Make sure to handle the cases:
/user/:id
Description
Write a parser to read through the controller definitions, look for
@Query()
and@Body()
decorators in function signature and generate corresponding swagger decorators like@ApiQuery()
,@ApiResponse()
and@ApiRequest()
.This should be a CLI command, something like
stencil add swagger
.Ref: #2