API operations don't accessible for two levels of embedded models
I have three models Guide, Translation and Step and they conform one single collection of documents like these:
{
"guideName": "How to ...",
"translations": [
{
"language": "en",
"steps": [
{
"description": "Open a bottle of ..."
}
]
}
]
}
I have three levels in my model but when I open the Loopback API explorer I find that the "Step" embedded model is not accessible by the API, I only have operations for "Guide" and "Translation" like these:
- POST /guides Create a new instance of the model and persist it into the data source.
- POST /guides/{id}/translations Creates a new instance in translations of this model.
But I don't have a method to post a step like this:
- POST /guides/{id}/translations/{translationId}/steps Creates a new instance in steps of this model.
Why are not these operations exposed by default? How can I expose this kind of methods for embedded objects of embedded objects?
I believe we do not support second level API operations yet. @raymondfeng Please confirm.
You'll have to explicitly call Guide.nestRemoting() to allow that.
Thank you very much. It's worked.
I have added a boot script with the sentence:
Guide.nestRemoting('translations');
and now the endpoints for the Step model are accesible from guides/{guideId}/translations/{translationId}/steps, although the endpoints are enabled these aren't visible in the StrongLoop API Explorer, is there any option to turn on them in the explorer?
Did you set the public property on the model? See https://docs.strongloop.com/display/public/LB/Exposing+models+over+REST;jsessionid=DE93CB65560351A7D9555A2BE5F080A5
If I set the public property of "translation" model the result is that the translations endpoint is showed like a new collection in the explorer not like a embedded collection inside "guides".
@onnoll Are you still running into issues? Can I close this?
Actually I'm closing this as resolved since the original problem has been answered. Please open a new issue if you are still running into problems.