0

I have this model done in loopback 4:

@property({
    type: 'string',
    id: true,
    default: () => uuid(),
  })

  id: string;

  @property({
    type: 'string',
    required: true,
  })
  name: string;

As you see, the id is generated by default. But in the loopback/explorer

image explorer

The id appears. I want to hide it, if is going to be auto generated, It could produce a confusion to the developers that want to use this API. Anybody knows how to put a property in a model, and hide it from the /explorer ?

Thanks.

Manish Balodia
  • 1,863
  • 2
  • 23
  • 37
Jota
  • 81
  • 7

2 Answers2

2

Just exclude the id from the request body schema

@requestBody({
      content: {
        'application/json': {
          schema: getModelSchemaRef(Model, {exclude: ['id']}),
        },
      },
    }

Hope this helps Thanks

Yash Rahurikar
  • 186
  • 1
  • 10
0

You can try this way:-

@model({
  settings: {hidden: ['password']}
})
class User extends Entity {
  // ...
  @property({
    type: 'string',
    required: true
  })
  password: string;
}
Manish Balodia
  • 1,863
  • 2
  • 23
  • 37