I am connecting loopback4 to mongodb using loopback mongodb connector.
I created model with only two fields id and name,both required. Repository and controller are also created. But when I make a POST request it is giving 422 error This is my model
import { Entity, model, property } from '@loopback/repository';
@model({ settings: { strict: false } })
export class Ss extends Entity {
@property({
type: 'number',
id: true,
required: true,
})
id: number;
@property({
type: 'string',
required: true,
})
name: string;
[prop: string]: any;
constructor(data?: Partial<Ss>) {
super(data);
}
}
export interface SsRelations {
// describe navigational properties here
}
export type SsWithRelations = Ss & SsRelations;
But while making POST request initially it was only showing name and not id. If I add only name obviously it was giving id not specified error. After adding id for POST request it is giving 422 error of validation failed