You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When path has more than one path params - mocks server returns Not found message.
If the /drivers/{driverId} is removed, leaving only one parameter the example is returned.
To Reproduce
Create openapi file with following path /cars/{carId}/drivers/{driverId} with some examples and attempt to access the resource.
Expected behavior
To return selected route variant example
Logs
Displaying logs. Press any key to display main menu again
12:38:14:20 [debug][server] Request received | GET => /api/cars/1/drivers/2 | Assigned id: 062546c7-568a-47f1-a2fe-76fab906a545
12:38:14:20 [debug][server] Sending Not found response | GET => /api/cars/1/drivers/2 | 062546c7-568a-47f1-a2fe-76fab906a545
12:38:14:20 [error][server] Sending Error 'Not Found' | 062546c7-568a-47f1-a2fe-76fab906a545
** Operating system, Node.js an npm versions, or browser version (please complete the following information):**
The problem is caused by the regular expression at charge of converting OpenAPI paths into Express paths. After reproducing the issue with your data and enabling the debug log mode, I've seen that a path like the one you described is converted into /cars/:carId}/drivers/{driverId, because the regular expression replaces all the content from the start of the first parameter to the end of the last one as if it was a single parameter.
So, replacing the regular expression /{(\S*)}/gim by /{(\S*?)}/gim in the replaceTemplateInPath method of the plugin fixes the bug.
I'll try to publish a new version with the fix ASAP.
Describe the bug
When path has more than one path params - mocks server returns
Not found
message.If the /drivers/{driverId} is removed, leaving only one parameter the example is returned.
To Reproduce
Create openapi file with following path /cars/{carId}/drivers/{driverId} with some examples and attempt to access the resource.
Expected behavior
To return selected route variant example
Logs
** Operating system, Node.js an npm versions, or browser version (please complete the following information):**
Additional context
Pseudo spec:
The text was updated successfully, but these errors were encountered: