mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
OpenApiParser - Construction of path possibly incorrect #678
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rossknudsen on GitHub (Mar 16, 2025).
Originally assigned to: @StefH on GitHub.
Hi,
So I'm experimenting with the OpenApiParser to quickly generate a mock for our API. I'm not very familiar with this software, so it may be an issue with my understanding. The issue is that the patterns that are generated for the paths seem to be incorrect. We have a path like:
And the generated path match is this:
^//customers/example-value$. The problem is the presence of two forward slashes at the beginning of the route. I think the issue occurs in this line here:db158bcc7e/src/WireMock.Net.OpenApiParser/Mappers/OpenApiPathsMapper.cs (L106)The call to
MapBasePath(servers)produces"/"and the call toMapPathWithParameters(path, parameters)produces"/customers/example-value". I think I understand that we are trying to prefix our routes with any path segment(s) that are on the server base path. However, the logic doesn't seem to account for the absence of any path segments (as my servers do not have any paths or trailing slash).Maybe the combining of these strings needs to be more sophisticated to account for this scenario?
@StefH commented on GitHub (Mar 17, 2025):
You are correct.
I've updated to the code.
https://github.com/WireMock-Net/WireMock.Net/pull/1265