Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New remote method generator removing matching named methods in other models #20

Open
1 of 2 tasks
WoodyWoodsta opened this issue Mar 15, 2017 · 5 comments
Open
1 of 2 tasks

Comments

@WoodyWoodsta
Copy link

WoodyWoodsta commented Mar 15, 2017

Bug or feature request

  • Bug
  • Feature request

Repro steps of bug

  • Create a skeleton Loopback app.
  • Create two models using the generator.
  • Create a remote method in one of the models.
  • Create a remote method with the same name as the previous, but in the second model.
  • Observe that the first remote method created is removed

Expected result

AFAIK, remote methods with the same name but in different models (ie. resulting in different URL paths) are valid.

Actual result (if bug)

Looback remote method generator is removing a remote method from any model upon generating a second one with the same name.

Additional information (Node.js version, LoopBack version, etc)

Loopback: 2.0.0 ([email protected])
Node: v6.10.0

Update

This appears to also occur when performing any cli operation in a project with two remote methods with the same name (manually generated)

@idushes
Copy link

idushes commented Apr 9, 2017

+1

@bajtos bajtos added the bug label Jun 7, 2017
@bajtos
Copy link
Member

bajtos commented Jun 7, 2017

Nice catch. I suspect this is a bug in loopback-workspace and the way how it creates unique id for remote methods. See

@WoodyWoodsta @idushes would you like to contribute the fix yourself? I am happy to help you along the way, just mention my GH handle in the pull request description.

@WoodyWoodsta
Copy link
Author

@bajtos If I manage to find time for it, I will certainly have a look.

@karanssj4
Copy link

@bajtos from what i can make out in model-method.json, id refers to the name of the method hence it can't be repeated
If we keep the id unique and introduce a new property, say 'name' then we wont need unique names, but i think that would introduce the name field in model definition json too due to this https://github.com/strongloop/loopback-workspace/blob/d9431392d4fcbf355a7e8f3765c201df41398e7a/common/models/model-definition.json#L97-L105
can we have a middleware that rewrites the method key in model definition file as the 'name' field or can we somehow mention in the model definition here https://github.com/strongloop/loopback-workspace/blob/d9431392d4fcbf355a7e8f3765c201df41398e7a/common/models/model-definition.json#L97-L105 that embed it against using the key 'name' and not 'id'

otherwise there might be some breaking changes and same method names in different models work fine in the projects currently

@bajtos
Copy link
Member

bajtos commented Oct 5, 2017

Hello, I am afraid I don't have enough time to look into this in details. The value used for the id property is usually composed from multiple parts, I'd expect that a remote-method id should be something like {facet}.{model}.{method}, e.g. common.User.findById. A name property should already exist on all workspace models, IIRC it's inherited from WorkspaceEntity or Definition base model.

I don't think a middleware based approach would work, we have many places that's invoking the JavaScript API directly, loopback-cli being a prime example (via generator-loopback).

@bajtos bajtos removed their assignment Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants