The new decorator function.
import { Controller, ControllerBase, DocumentationUpdater, GET, IDocumentationUpdaterContext, IHttpRequest, IHttpResponse } from '@egomobile/http-server'
@Controller()
export default class MyController extends ControllerBase {
@GET({
documentation: {
responses: {
'200': {
description: 'foo response data'
}
}
}
})
async index(request: IHttpRequest, response: IHttpResponse) {
response.write('foo!')
}
@DocumentationUpdater() // mark that method to update swagger documentations
// of a route
updateDocumentation({ documentation }: IDocumentationUpdaterContext) {
// keep sure, that any documentation object has a response
// with a 500 entry
if (!documentation.responses['500']) {
documentation.responses['500'] = {
description: 'An error occurred!'
}
}
}
}
Generated using TypeDoc
Add a method of a controller as a response serializer.