Skip to content

Commit

Permalink
docs: add documentation to OpenApi decorator
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Molares <[email protected]>
  • Loading branch information
DerMolly authored and davidmehren committed Feb 20, 2022
1 parent cae55e0 commit 86ef8f3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/api/utils/openapi.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export type HttpStatusCodes =
| 409
| 500;

/**
* Defines what the open api route should document.
*
* This makes it possible to document
* - description
* - return object
* - if the return object is an array
* - the mimeType of the response
*/
export interface HttpStatusCodeWithExtraInformation {
code: HttpStatusCodes;
description?: string;
Expand All @@ -47,6 +56,17 @@ export interface HttpStatusCodeWithExtraInformation {
mimeType?: string;
}

/**
* This decorator is used to document what an api route returns.
*
* The decorator can be used on a controller method or on a whole controller class (if one wants to document that every method of the controller returns something).
*
* @param httpStatusCodesMaybeWithExtraInformation - list of parameters can either be just the {@link HttpStatusCodes} or a {@link HttpStatusCodeWithExtraInformation}.
* If only a {@link HttpStatusCodes} is provided a default description will be used.
*
* For non-200 successful responses the appropriate {@link HttpCode} decorator is set
* @constructor
*/
// eslint-disable-next-line @typescript-eslint/naming-convention,func-style
export const OpenApi = (
...httpStatusCodesMaybeWithExtraInformation: (
Expand Down

0 comments on commit 86ef8f3

Please sign in to comment.