I'm reading from 2 json files, each of which contain an array of students/teachers.
let student = require('../data/student.json');
let teacher = require('../data/teacher.json');
When I call:
res.status(200).json({student: student}, {teacher: teacher});
Only the first(student, in this case) gets printed in the response. Teacher isn't printed.
In my yaml file, I have this for the format of the response message.
content:
application/json:
schema:
$ref: '#/components/schemas/StudentsAndTeachers'
This is StudentsAndTeachers:
StudentsAndTeachers:
type: object
properties:
student:
type: array
items:
$ref: '#/components/schemas/Person'
teacher:
type: array
items:
$ref: '#/components/schemas/Person'
required:
- student
- teacher
This is Person:
Person:
type: object
properties:
id:
type: string
name:
type: string
required:
- id
- name
Why is only the first property (student) being printed in the response?
this is the error I'm getting:
500
Error: Internal Server Error
Response body
{
"message": ".response should have required property 'teacher',
"errors": [
{
"path": ".response.teacher",
"message": "should have required property 'teacher'",
"errorCode": "required.openapi.validation"
},
],
"status": 500
}