REST API to manage your XOA
Installation of the npm package:
npm install --save @xen-orchestra/rest-api
The REST API is based on the TSOA
framework and therefore we use decorators a lot to define the behavior of a route or a group of routes. To keep things easily visible, it is best to always use the decorators in the same order.
@Routes('foo')
@Security('*')
@Response(401)
@Tags('foo')
@provide(Foo)
class Foo extends Controller {}
@Routes('foo')
...
class Foo extends Controller {
/**
* any jsdoc anotations
* @example id 1234
*/
@Example(['foo', 'bar'])
@Get('{id}')
@Security('*')
@SuccessResponse(202)
@Response(404)
getFoo(@Path() id: string) {
return this.getFoo(id)
}
}
In order not to pollute important decorators, all example structures should be in a separate file. src/open-api/examples/<resource>.example.mts
Contributions are very welcomed, either on the documentation or on the code.
You may:
- report any issue you've encountered;
- fork and create a pull request.