feat(api): added schema for email unsubscribe token

v1.18.x
Julian Lam 4 years ago
parent 501a7b7774
commit 4fc1337762

@ -1,8 +1,51 @@
# TODO: Need GET route here as well
get:
tags:
- emails
summary: Unsubscribe user from email type (user variant)
parameters:
- name: token
in: path
required: true
schema:
type: string
example: testToken
responses:
"200":
description: ""
content:
application/json:
schema:
allOf:
- type: object
properties:
payload:
type: object
properties:
uid:
type: number
template:
type: string
description: The type of email template to unsubscribe from.
enum:
- digest
- notification
type:
type: string
description: Only used if `template` is `notification`, signifies the type of notification to unsubscribe from.
nullable: true
iat:
type: number
description: Reflection of the token's "issued at" claim
required:
- uid
- template
- $ref: ../../../components/schemas/CommonProps.yaml#/CommonProps
"500":
description: "Server-side error (likely token verification failure)"
post:
tags:
- emails
summary: Unsubscribe user from email type
summary: Unsubscribe user from email type (auto variant)
parameters:
- name: token
in: path

@ -7,6 +7,7 @@ const fs = require('fs');
const SwaggerParser = require('@apidevtools/swagger-parser');
const request = require('request-promise-native');
const nconf = require('nconf');
const jwt = require('jsonwebtoken');
const util = require('util');
const wait = util.promisify(setTimeout);
@ -34,7 +35,18 @@ describe('API', async () => {
const mocks = {
head: {},
get: {},
get: {
'/api/email/unsubscribe/{token}': [
{
in: 'path',
name: 'token',
example: (() => jwt.sign({
template: 'digest',
uid: 1,
}, nconf.get('secret')))(),
},
],
},
post: {},
put: {},
delete: {

Loading…
Cancel
Save