gstroup / apimocker

node.js module to run a simple http server for mock service responses.
MIT License
280 stars 81 forks source link

switch param in path no longer working since 1.0.2 #91

Closed aburmeis closed 6 years ago

aburmeis commented 6 years ago

In my config I have a web service configured like:

    "v2/position/:lang/:id": {
      "verbs": ["get"],
      "mockFile": "v2/position.json",
      "switch": "id"
    }

This works perfectly with 1.0.1 even if the file v2/position.json is not existing. Since 1.0.2 I get the following messages:

No file found: v2/position.json attempting base file: v2/position.json
Returning mock: GET v2/position/:lang/:id : v2/position.json

instead of the working message from 1.0.1:

Returning mock: GET v2/position/:lang/:id : v2/id376217.position.json

It seems the refactoring to support new express api broke the path switch functionality.

gstroup commented 6 years ago

@twalker I think this might have been caused by your change. What do you think?

twalker commented 6 years ago

I've been able to reproduce the bug in v1.0.2. However when I revert my change in #90 by restoring decoding, I'm still able to reproduce the bug.

I don't yet know if it's related, but I've also been getting 404 responses for some of my configured routes since the 0.5.1 => v1.0.1 update. Some regression bugs seem to have been introduced by the express update. I'll be investigating those new failures, and keep this bug in mind.

twalker commented 6 years ago

@gstroup, I submitted PR #93 which fixes this bug. It also resolves the 404 responses I was receiving in my configured routes that were using route parameters.