# Schema Decorator validation swagger schema classDecorator input
Module | import { Schema } from "@tsed/common" |
---|---|
Source | /packages/common/src/jsonschema/decorators/schema.ts |
# Overview
function Schema(partialSchema: Partial<JsonSchema>): (...parameters: any[]) => any;
# Description
Write data formatted to JsonSchema.
WARNING
This decorator will be removed in v7. For v6 user, use from @tsed/schema instead of @tsed/common.
# 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
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing