According to docs, in NestJS it is possible to generate schemas like this:
export class NodeId {
@ApiProperty({
minimum: 40,
maximum: 40,
readOnly: true,
})
id: string;
}
export class Position {
@ApiProperty({ readOnly: true, example: 0 })
x: number;
@ApiProperty({ readOnly: true, example: 0 })
y: number;
}
export class Node {
@ApiProperty()
nodeId: NodeId;
@ApiProperty()
position: Position;
}
In yaml NodeId schema looks like this:
NodeId:
type: object
properties:
id:
type: string
minimum: 40
maximum: 40
readOnly: true
required:
- id
Though, my ultimate goal is being able to produce simple schema for entities like Ids, which has to have a specific structure and could be reusable:
This can be achieved in swagger itself (by editing yaml file manually) like this:
NodeId:
type: string
minimum: 40
maximum: 40
readOnly: true
I'm seeking for the same in NestJS. Sadly, there was no such example in NestJS docs. I'm wondering whether it is possible to generate this kind of schema by swagger module means.