show/hide models in api explorer

258 views
Skip to first unread message

Joey Benenati

unread,
Mar 21, 2018, 2:26:01 PM3/21/18
to LoopbackJS
This is regarding the loopback-component-explorer - Is there a way to have any control over which models and/or endpoints are shown in the API explorer? I've been looking through the source code and couldn't find anything.

Raymond Feng

unread,
Mar 21, 2018, 4:10:56 PM3/21/18
to loopb...@googlegroups.com
On Mar 21, 2018, at 11:26 AM, Joey Benenati <joey.b...@gmail.com> wrote:

This is regarding the loopback-component-explorer - Is there a way to have any control over which models and/or endpoints are shown in the API explorer? I've been looking through the source code and couldn't find anything.

--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/e30da0dd-42ef-4749-b7aa-25ae9d4b9345%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

1980.l...@gmail.com

unread,
Mar 27, 2018, 3:56:27 PM3/27/18
to LoopbackJS
I too am facing this issue.
Is this resolved. I tried the below but didn't succeeded.

I just began with loopback and created a very simple app with two models only: customer and club.
I created a hasAndBelongToMany relation between these models.

i see that i have got the below end point in the explorer:
POST /customers/{id}/clubs

But I don't want to expose the create method for club from within customer.

I tried to use the below methods inside customer.js as explained in the loopback documentation, but it still keeps showing the above end point (POST /customers/{id}/clubs) in explorer.

  1. Customer.disableRemoteMethod('__create__club',true);
  2. Customer.disableRemoteMethod('prototype.__create__club',true);
  3. Customer.disableRemoteMethodByName('__create__club');
  4. Customer.disableRemoteMethodByName('prototype.__create__club');

Is this a bug or am i doing something incorrectly here ? I would really appreciate any help or pointers.

customer.json --
{
"name": "customer",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"name": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {
"clubs": {
"type": "hasAndBelongsToMany",
"model": "club",
"foreignKey": "clubId",
"options": {
"nestRemoting": true,
"disableInclude": true
}
}
},
"acls": [],
"methods": {}
}


thanks in advance,
Vipul

Raymond Feng

unread,
Mar 27, 2018, 4:27:39 PM3/27/18
to loopb...@googlegroups.com
Did you try 'prototype.__create__clubs’?


On Mar 27, 2018, at 12:56 PM, 1980.l...@gmail.com wrote:

prototype.__create__club

Raymond Feng

unread,
Mar 27, 2018, 4:34:38 PM3/27/18
to loopb...@googlegroups.com
Do you want to try https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md?

On Mar 21, 2018, at 1:28 PM, Joey Benenati <joey.b...@gmail.com> wrote:

Hi Raymond,
I have looked at that, and use those methods to disable remote methods on my models. However, what I am trying to accomplish is not to disable models or methods on the api. I only want to HIDE certain models from the API EXPLORER for security purposes. Whereas  "disableRemoteMethodByName" and the remoting settings in model-config.json actually disable the methods from being used at all. 

Seems like this would need to be done component-explorer or loopback-swagger level? 

Thank you for the response!

Mark Johnson

unread,
Mar 27, 2018, 6:48:57 PM3/27/18
to LoopbackJS
If the reason is security, and given that the .json file seems to show an empty ACL list [], perhaps the resolution is to configure appropriate ACLs?
Reply all
Reply to author
Forward
0 new messages