I would like to define two components: one for a single student and one for an array of students. But I want to follow the DRY principle. So I tried this:
components:
schemas:
student:
type: object
properties:
StudentID:
type: integer
example: 3
StudentName:
type: string
example: David
StudentRemarks:
type: string
example: High Grade Student
students:
type: array
items:
$ref: '#/components/schemas/student/properties'
But it does not seem to work. Swaggers editor renders it this way:
If I repeat myself:
components:
schemas:
student:
type: object
properties:
StudentID:
type: integer
example: 3
StudentName:
type: string
example: David
StudentRemarks:
type: string
example: High Grade Student
students:
type: array
items:
properties:
StudentID:
type: integer
example: 3
StudentName:
type: string
example: David
StudentRemarks:
type: string
example: High Grade Student
It looks this way:
When I try to define a named anchor, I get the following error:
Structural error at components.schemas.student should NOT have additional properties additionalProperty: $id
How to reference another component correctly?

