Paste TypeORM entity classes and get the JSON shape those entities produce when you return them from an API, filled with placeholder values. It is meant for NestJS or Express projects that send entities straight back in responses and need Swagger examples or request/response samples to agree on with the frontend.
Values come from the TypeScript type on each property, not from @Column options. A column declared @Column({ type: "decimal" }) with price: number therefore comes out as the number 0.
TypeORM box. Include related entities and enums so nested objects can be filled in.Result box updates as you type. An entity that no other entity references becomes the top-level JSON object; if there are several unrelated entities, each appears under its class name.enum Genre { Novel = "novel", Essay = "essay" }
@Entity()
export class Author {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
}
@Entity()
export class Book {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column({ type: "enum", enum: Genre })
genre: Genre;
@Column({ type: "decimal", nullable: true })
price: number | null;
@ManyToOne(() => Author)
author: Author;
@Exclude()
@Column()
internalCode: string;
}{
"id": "",
"genre": "novel",
"price": 0,
"author": {
"id": 0,
"name": ""
}
}Book references Author, so Book is the root and author is nested inside it. internalCode is dropped because of @Exclude(), and price, typed number | null, follows the first non-null type and becomes 0. The uuid primary key is typed string, so it is an empty string.
@ManyToOne and @OneToOne relations become nested objects; Post[] from @OneToMany or @ManyToMany becomes a one-element array.Promise<Post[]>) and the ESM Relation<User> wrapper are unwrapped to the inner type.@Exclude(), static fields, methods and getters are left out.Date properties (from @CreateDateColumn and similar) become ISO strings like 1970-01-01T00:00:00.000Z.Record<string, number>, are shown as {"key": 0}.null or an empty array so nesting stays finite.Controllers that return entities directly still need an example payload for @ApiResponse. Paste the entity file and replace the placeholder values in the result with realistic ones.
When you query with relations: ["author"], the frontend wants to know how deep the response nests. The output makes it obvious which relation fields are objects and which are arrays.
Use the output as the skeleton of a request body for supertest POST calls. Delete generated fields like id and the timestamps, then fill in the rest.
@Column options such as nullable, default or length are not read; the value comes from the property type or a literal initializer (status = "draft"). If a column can be null, change that value to null yourself.@Entity classes that don't reference each other are all converted, keyed by class name ({ "Book": {...}, "Author": {...} }). Entities that do reference each other still produce one nested root.null.@Expose, serialization groups and @Transform used with ClassSerializerInterceptor are not applied.@PrimaryGeneratedColumn("uuid") an empty string?Only the property type decides the value. id: string gives ""; the "uuid" argument in the decorator is not read. For documentation, swap in a UUID-shaped value afterwards.
It matches JSON.stringify of a fully loaded entity. Relations you did not load with relations are simply missing from the real response, so treat relation fields in the output as the loaded case.
The PostgreSQL and MySQL drivers return decimal values as strings to avoid precision loss. Declare the property as price: string in the entity and the output, like your real data, will be a string.