diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-15 05:21:47 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-15 05:21:47 +0800 |
commit | 2f2582a0da3095d61a99ef09744dc0995677558e (patch) | |
tree | 54989565919038c42d495dafb7426d4148605e84 /packages/sra-api/src/responses.ts | |
parent | 8169155a6547fb0283cd0f5362aad3c0b173b00b (diff) | |
parent | fadd292ecf367e42154856509d0ea0c20b23f2f1 (diff) | |
download | dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.gz dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.bz2 dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.lz dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.xz dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.tar.zst dexon-sol-tools-2f2582a0da3095d61a99ef09744dc0995677558e.zip |
Merge development
Diffstat (limited to 'packages/sra-api/src/responses.ts')
-rw-r--r-- | packages/sra-api/src/responses.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/sra-api/src/responses.ts b/packages/sra-api/src/responses.ts new file mode 100644 index 000000000..cd7352058 --- /dev/null +++ b/packages/sra-api/src/responses.ts @@ -0,0 +1,24 @@ +import { ResponsesObject } from '@loopback/openapi-v3-types'; + +import { errorResponses } from './errors'; +import { headers } from './headers'; + +export const generateResponses = (schemaName?: string, example?: any, description: string = 'OK'): ResponsesObject => { + const responses = { + '200': { + headers, + description, + content: {}, + }, + ...errorResponses, + }; + if (schemaName) { + responses['200'].content = { + 'application/json': { + schema: { $ref: `#/components/schemas/${schemaName}` }, + example, + }, + }; + } + return responses; +}; |