# Ignore Decorator jsonMapper schema alias
Module | import { Ignore } from "@tsed/common" |
---|---|
Source | /packages/common/src/jsonschema/decorators/ignoreProperty.ts |
# Overview
function Ignore(): Function;
# Description
Disable serialization for this property when the Converters service will render the JSON object.
TIP
This decorator is used by the Converters to serialize correctly your model.
WARNING
Swagger will not generate documentation for the ignored property.
class User {
@Ignore()
_id: string;
@Property()
firstName: string;
@Property()
lastName: string;
@Ignore()
password: string;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
The controller:
import {Post, Controller, BodyParams} from "@tsed/common";
import {Person} from "../models/Person";
@Controller("/")
export class UsersCtrl {
@Get("/")
get(): User {
const user = new User();
user._id = "12345";
user.firstName = "John";
user.lastName = "Doe";
user.password = "secretpassword";
return
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
The expected json object:
{
"firstName": "John",
"lastName": "Doe"
}
1
2
3
4
2
3
4
- 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