# IgnoreProperty Decorator jsonMapper schema deprecated
Module | import { IgnoreProperty } from "@tsed/common" |
---|---|
Source | /packages/common/src/jsonschema/decorators/ignoreProperty.ts |
# Overview
function IgnoreProperty(): Function;
# Description
Disable serialization for this property when the Converters service will render the JSON object.
WARNING
This decorator will be removed in v6 in favor of from @tsed/schema. For v5 user, use decorator from @tsed/common then in v6 switch to @tsed/schema.
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