# Decorator Schema
Decorator validation swagger schema classDecorator inputModule | import { Schema } from "@tsed/schema" |
---|---|
Source | /packages/schema/src/decorators/common/schema.ts |
# Overview
function Schema(partialSchema: Partial<JsonSchemaObject> | JsonSchema): (...args: any[]) => any;
# Description
Write data formatted to JsonSchema.
# Example
@Schema({title: "test"})
class Model {
@Schema({formatMinimum: "1987-10-24"})
@Format("date")
birthDate: Date
}
1
2
3
4
5
6
2
3
4
5
6
Will produce:
{
"type": "object",
"title": "test",
"properties": {
"birthdate": {
"type": "string",
"format": "date",
"formatMinimum": "1987-10-24"
}
}
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Other topics
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Seq
- OIDC
- Stripe
- Controllers
- Providers
- Model
- JsonMapper
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Exceptions
- Hooks
- Response Filter
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing