Skip to content

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

Open

Description

@WoodyWoodsta

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 (generator-loopback@3.0.0)
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)

Activity

  1. idushes commented on Apr 9, 2017

    @idushes

    +1

  2. bajtos commented on Jun 7, 2017

    @bajtos
    Member

    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.

  3. self-assigned this
    on Jun 7, 2017
  4. WoodyWoodsta commented on Jun 8, 2017

    @WoodyWoodsta
    Author

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

  5. karanssj4 commented on Sep 28, 2017

    @karanssj4

    @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

  6. bajtos commented on Oct 5, 2017

    @bajtos
    Member

    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).

  7. removed their assignment
    on Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions