Skip to content

Commit 9fef5b2

Browse files
committed
update swagger definition & validators for tasks
1 parent 7c8c8c6 commit 9fef5b2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

middlewares/validators/tasks.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ const joi = require('joi')
22

33
const createTask = async (req, res, next) => {
44
const schema = joi.object().keys({
5+
title: joi.string().required(),
6+
purpose: joi.string().required(),
7+
featureUrl: joi.string().optional(),
58
type: joi.string().required(),
69
links: joi.array().items(joi.string()),
710
endsOn: joi.string(),
@@ -20,7 +23,8 @@ const createTask = async (req, res, next) => {
2023
gold: joi.number(),
2124
silver: joi.number(),
2225
bronze: joi.number()
23-
}).optional()
26+
}).optional(),
27+
isNoteworthy: joi.bool().optional()
2428
})
2529

2630
try {
@@ -34,6 +38,9 @@ const createTask = async (req, res, next) => {
3438

3539
const updateTask = async (req, res, next) => {
3640
const schema = joi.object().keys({
41+
title: joi.string().optional(),
42+
purpose: joi.string().optional(),
43+
featureUrl: joi.string().optional(),
3744
type: joi.string().optional(),
3845
links: joi.array().items(joi.string()),
3946
endsOn: joi.string().optional(),
@@ -52,7 +59,8 @@ const updateTask = async (req, res, next) => {
5259
gold: joi.number(),
5360
silver: joi.number(),
5461
bronze: joi.number()
55-
}).optional()
62+
}).optional(),
63+
isNoteworthy: joi.bool().optional()
5664
})
5765

5866
try {

utils/swaggerDefinition.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ const swaggerOptions = {
5656
tasks: {
5757
type: 'object',
5858
properties: {
59+
title: {
60+
type: 'string'
61+
},
62+
purpose: {
63+
type: 'string'
64+
},
65+
featureUrl: {
66+
type: 'string'
67+
},
5968
type: {
6069
type: 'string'
6170
},
@@ -125,6 +134,9 @@ const swaggerOptions = {
125134
type: 'number'
126135
}
127136
}
137+
},
138+
isNoteworthy: {
139+
type: 'boolean'
128140
}
129141
}
130142
},

0 commit comments

Comments
 (0)