# IgnoreProperty Decorator

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.

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 {
  @IgnoreProperty()
  _id: string;

  @Property()
  firstName: string;

  @Property()
  lastName: string;

  @IgnoreProperty()
  password: string;
}
1
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

The expected json object:

{
 "firstName": "John",
 "lastName": "Doe"
}
1
2
3
4

:::