Replies: 14 comments 11 replies
-
Hey @dario-frongillo, Prism non supporta nessun Scrivici ancora se hai bisogno di chiarimenti a riguardo. |
Beta Was this translation helpful? Give feedback.
-
Still this feature would be useful so that the mock server corresponds as much as possible to the production infrastructure. This could be done with a CLI option: Usage: prism -b /poll-maker/v1 |
Beta Was this translation helpful? Give feedback.
-
I agree with @mullerch here it's really handy to have this feature available @XVincentX are you open to a PR ? |
Beta Was this translation helpful? Give feedback.
-
As mentioned here — we are not going to support such feature. |
Beta Was this translation helpful? Give feedback.
-
@XVincentX ... the argument not to support this does not make sense to me. Basepath and server are both essential elements in the V2 and V3 specification. Not supporting it because "it is confusing to some others" does not make sense. It is very little implementation work to implement this and you can still keep the default behavior to ignore it, if you wish (although I do not understand why a client implementation would need to make an exception w.r.t basepath just because a mock server is not implementing it correctly). The only way to support a real mock server now (and having the right full URL paths is essential for that), is to front prism with a reverse proxy to do URL remapping. I am going to need to look for alternatives, as the goal of a mock server is to stay as close to the specifications as possible, not to make exceptions and chose to ignore essential elements. Clients, like SwaggerUI and others, all are implemented taking the basepath or server correctly into account. https://microcks.io looks very promising. |
Beta Was this translation helpful? Give feedback.
-
Hey @boeboe, I'd be interested in learning more about how the lack of I'm open to new ideas and — in case there's a convincing argument, we can reconsider. |
Beta Was this translation helpful? Give feedback.
-
@boeboe Conceptually, Prism starts where your API starts, and the preceding gumph to get to that point is irrelevant. Your API starts at Prism runs an alternative server on another equivilent server URL. You can swap out either server URL and they will "stay as close to the specifications as possible", and $SERVER_URL/hello will be the same. If you could explain the actual problem you're having I could perhaps help further, but so far I am not sure if there is a problem? |
Beta Was this translation helpful? Give feedback.
-
Here my setup. Dunno if it can help My OpenAPI has:
and an endpoint like
I call my application directly using I then start Prism with
If I call:
I get
If I start Prism using (please note
no warning is returned |
Beta Was this translation helpful? Give feedback.
-
Perhaps a different use case may help to explain the request to support such a feature request. Firstly, if this feature request is "optional" meaning that we are simply adding to existing behaviors, then we have not created a regression and documentation requested above can help to outline the usage of this additional feature. The use case that I am describing here is one focused on a large and complex series of services that have interdependencies and configured from external sources. So, for example, Service A starts and receives configuration information from another service found within the DEV environment. Some of these configs are pointing to endpoints in Service B which we will continue with the paths defined above 'localhost:8080/api/v3/cities/1'. Now we would like to use the Prizm mock server to emulate Service B without having to manipulate configurations for testing. We would suddenly have a host that is now only able to respond to: 'localhost:8080/cities/1' which now "breaks" the pathing to the endpoint and configurations are also incorrect based on the limitation placed on us by Prizm simply because we cannot inject that component into the path that Prizm will respond to. The behavior is a behavior of deploying a Java WAR file to an EE container such as Tomcat. The basePath of the application will match the name of the WAR file and all endpoints will be relative to this name. We are looking to perform A-B-C type testing with all other dependencies being mocked through Prizm as a simple plug-n-play solution. If we cannot get Prizm to respond on such path references then we will not be able to utilize this tool (which is amazing BTW). Is this use case making more sense as to the importance of the BasePath feature request and how important that can be for very complex infrastructures that cannot easily adapt to suddenly changing API endpoint references? Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hey @XVincentX I was wondering if stoplights stance has changed on this topic over time. I have one question followed by our use case. Why cant prism detect an OAS2 spec and construct the full path according to OAS2 semantics? We have a bunch of wiremocks I am replacing in our integration test environment. So far all have been OAS3 specs. I have replaced all but one which is a OAS2 api with a basePath in its spec. Therefore the existing wiremock includes the expected basePath in the mock URL. I cannot swap out the wiremock for a prism mock without changing the OAS2 spec and everything else in this service that assumes Im going to try and find a way around this because we love prism, but this is a pretty rough edge for folks dealing with legacy services, and means prism doesn't fully support OAS2 which is implied in the preamble of the README.md. Edit: maybe I put nginx in front of the prism mock to insert the basePath....not sure if that will work or not with out reading some docs. proxy_pass option looks promising. If this works out happy to add a docs update to socialize the work around. Edit Edit: nginx + proxy_pass works for me. Happy to submit a docs update if I get to put an asterisk next to OAS2 support for the next person who will need this. |
Beta Was this translation helpful? Give feedback.
-
So this needs to get revived. If anyone has a PR for adding the option The "use NGINX" response is bizarre, frankly. |
Beta Was this translation helpful? Give feedback.
-
We use |
Beta Was this translation helpful? Give feedback.
-
@gavenkoa - Using the NGINX workaround will get you rewritten URLs easier than those methods, but the point is adding a General note: The reason why I say the NGINX suggestion from (admittedly former) a project dev is bizarre, is that the supposed rationale (in the source code/readme) for not implementing By not using the option the user would get the urls without a base path prefix and would not trouble them at all. It'd be default behaviour, breaks nothing, etc. etc. Providing the option, however is good value to users who have to deal with this issue, and do not want or need another layer (nginx) to discuss/socialize in development docs etc. |
Beta Was this translation helpful? Give feedback.
-
+1 to the fact that this is baffling. From the FAQ, "a request to http://localhost:4010/hello would work, but http://localhost:4010/api/v1/hello will fail" So there is no way to make http://localhost:4010/api/v1/hello return without editing the "paths" section of the OpenApi spec (causes code generation issues elsewhere) or running a proxy (clunky and difficult to roll out across a non technical team)? This almost makes this project unusable, which is a shame for such a strong project otherwise. |
Beta Was this translation helpful? Give feedback.
-
User story.
Hi all,
in my yaml i ve specified
servers:
so if exist a path /hello i want that mock server respond to
https://localhost:3000/poll-maker/v1/hello
how can specify basepath poll-maker/v1 in mock server ?
Beta Was this translation helpful? Give feedback.
All reactions