|
|
@@ -31,21 +31,24 @@ app.use('/api', swaggerUi.serve, swaggerUi.setup(specs));
|
|
|
* content:
|
|
|
* application/json:
|
|
|
* schema:
|
|
|
- * type: array
|
|
|
- * items:
|
|
|
- * type: object
|
|
|
- * properties:
|
|
|
- * incomes:
|
|
|
- * type: array
|
|
|
- * items:
|
|
|
- * type: object
|
|
|
- * properties:
|
|
|
- * amount:
|
|
|
- * type: number
|
|
|
- * frequency:
|
|
|
- * type: number
|
|
|
- * advertisingCosts:
|
|
|
- * type: number
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * persons:
|
|
|
+ * type: array
|
|
|
+ * items:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * incomes:
|
|
|
+ * type: array
|
|
|
+ * items:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * amount:
|
|
|
+ * type: number
|
|
|
+ * frequency:
|
|
|
+ * type: number
|
|
|
+ * advertisingCosts:
|
|
|
+ * type: number
|
|
|
* responses:
|
|
|
* 200:
|
|
|
* description: Success
|
|
|
@@ -56,10 +59,33 @@ app.use('/api', swaggerUi.serve, swaggerUi.setup(specs));
|
|
|
* properties:
|
|
|
* wbsGranted:
|
|
|
* type: boolean
|
|
|
+ * requestBody:
|
|
|
+ * description: Example request body
|
|
|
+ * required: true
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * type: object
|
|
|
+ * example:
|
|
|
+ * persons:
|
|
|
+ * - incomes:
|
|
|
+ * - amount: 500
|
|
|
+ * frequency: 12
|
|
|
+ * advertisingCosts: 500
|
|
|
+ * - amount: 200
|
|
|
+ * frequency: 1
|
|
|
+ * advertisingCosts: 0
|
|
|
+ * - incomes:
|
|
|
+ * - amount: 1200
|
|
|
+ * frequency: 12
|
|
|
+ * advertisingCosts: 200
|
|
|
+ * - amount: 2000
|
|
|
+ * frequency: 1
|
|
|
+ * advertisingCosts: 0
|
|
|
*/
|
|
|
app.post('/calculate', (req, res) => {
|
|
|
let totalIncome = 0;
|
|
|
- const persons = req.body;
|
|
|
+ const persons = req.body.persons;
|
|
|
for (const person of persons) {
|
|
|
for (const income of person.incomes) {
|
|
|
let annualIncome = income.amount * income.frequency;
|