javascript - How can I hide the 'id' attribute in Loopback explorer? -
is possible hide id attribute in method in swagger-ui generated explorer in strongloop loopback? don want user create new resource , send id attribute. know if user send id can ignored want hide in explorer.
in order hide 'id' attribute, you need declare field hidden.
in your_model.json file:
{ "name": "your_model", . . . "properties": { // custom properties }, "hidden": ["id"], // attribute specifies attributes need hidden . . . }
be aware when property declared hidden:
- it's not exposed user
- although hidden, if user sends provides value property, the property won't ignored default, , handled provided values. hence, need ignored manually.
for instance, if have 'user' model follows:
{ "name": "user", . . . "properties": { "id": "string", "name": "string", "password": "string", }, "hidden": ["id", "password"], . . }
/api/user
request provide list of users only 'name' attribute
but, /api/user
post body:
{ "user" : "user", "password": "pass", "id" : "user_provided_id" }
the user provided in body saved values in it.
Comments
Post a Comment