-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
Mock does not work when URL contains slashes #1363
Comments
Welcome to the Microcks community! 💖 Thanks and congrats 🎉 for opening your first issue here! Be sure to follow the issue template or please update it accordingly. 📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact. If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌" Hope you have a great time there! 🌟 ~~~~~~~~~ 🌟 📢 If you like Microcks, please ⭐ star ⭐ our repo to support it! 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact. |
Hello @Marckman, I think reasoning from an example can help in this situation 😉 Let's imagine the following basic OpenAPI definition of your openapi: 3.0.2
info:
title: MyService
version: 1.0
paths:
/resource:
get:
[...] From this OpenAPI definition, Microcks will generate mock endpoints like this: Now if your current service has this kind of URL: You have several options the:
I hope it clarifies the situation on how Microcks is actually producing endpoint URLs. |
Hi @lbroudoux, thanks a lot for the quick reply! The actual service URL is set in stone and we cannot change it, i.e. it is always the hostname (env dependent) followed by the service name, a fixed So if my spec is like this: info:
title: MyService
version: api/v1
paths:
/resource: I get the error I mentioned in the first post. However, I have noticed versions with formats like Now, if I set the version as part of the resource: info:
title: MyService
version: api
paths:
/v1/resource: This works really well but leads to a different problem: two major versions of the same API cannot live alongside each other (just like in the actual environments) because their "coordinates" (MyService/api) in Microcks are the same - in this case, I have noticed the previous artifact gets overwritten, forcing me to merge both specs before importing. Finally, if the resource path is like Hope this clarifies the issue a bit 🙂 Thanks again! |
Ok I see what you mean but I'm afraid we cannot do something at the Microcks level as introducing version in endpoints is mandatory to avoid collision and version is of-course URL-encoded to avoid side-effect. In your situation, I would recommend adding an extra proxy in front of your Microcks instance to rewrite the URL the way you want. You may then introduce an arbitrary version in your spec to have something like: info:
title: MyService
version: 1.0
paths:
/resource: This would produce endpoints like This could be a temporary situation until you realign your practices to some more standard ways like having |
Thanks @lbroudoux. |
Describe the bug
We are trying to mock some of our APIs via the artifact upload feature (in our case, an OpenAPI 3.x document).
I have noticed the context root in the mock URL is built by joining the document's
info/title
andinfo/version
with a slash. So, in order to keep this URL as similar as possible to our actual services' URLs, I have placed a fixedapi
part followed by a slash and the version as theinfo/version
field in the document, e.g.api/v1
.The actual service URL follows this format:
https://my.actual.env/myservice/api/v1/resource
Whereas the mock ends up with an URL like this:
https://microcks.foo/rest/myservice/api/v1/resource
However, when we send a request to the mock, it takes just
api
as the version and fails, instead of returning the expected response.Any help would be appreciated. Also, please correct me if this has been the wrong approach all along 😅 we just need to customize the context root in our mocks.
Expected behavior
Mock returns the expected response according to what is documented in the OpenAPI contract.
Actual behavior
Mock answers with a 404 error and a plain text body like the following:
The service myservice with version api does not exist!
How to Reproduce?
Add Direct API button
in the web app, or theartifact/upload
API operation.api/v1
. Make sure the document has enough examples for mock creation.Microcks version or git rev
1.10.0
Install method (
docker-compose
,helm chart
,operator
,docker-desktop extension
,...)helm chart
Additional information
No response
The text was updated successfully, but these errors were encountered: