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:

  1. it's not exposed user
  2. 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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -