-
Notifications
You must be signed in to change notification settings - Fork 13
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
Prefix missing from Swagger #820
Comments
Can you elaborate here? Are you saying if the OpenApi spec is missing a prefix you want Counterfact to add it? |
I haven't given this much thought. But as I understand it OpenAPI is relative to some basepath. In most cases this basepath is just the domain
But in some cases it could be relevant to a prefixed url
As I understand it openAPI will not mention this For Counterfact, the basepath is by defauly When I start up Counterfact I can add a prefix, using
This will ensure that I can more easily change from a production and mock api on a running client. However if I go into Swagger and try out I get 404 because swagger tries out the normal path. |
A recent PR updated CF to support the So now if your spec has a |
There's a better way. You can have Counterfact proxy to the production server. You can then switch between mocks and the proxy to production at runtime. The client code doesn't need a mechanism to switch back and forth at runtime. I have big plans to build on this feature. You'll be able to have some endpoints point to production while others are mocked. You'll be able to flip the switch at runtime through a GUI that also serves as an alternative to Postman or Swagger UI which is easier to use. I'm typing on my phone so I can't easily link to the docs, but please let me know if that makes sense and fits your use case. |
@IngoVals What do you think? Do you still have concerns or can we close this issue? |
What about the prefix attribute in Counterfact, if the plan is to support that still you could just try it out. Run counterfact, with a prefix, open up the swagger endpoint, and try to run an endpoint. Unless I'm missing something this will not work, which is probably not what we want. |
You're right! I forgot that before the OpenAPI doc is passed to Swagger, a URL is injected into the servers object. counterfact/src/server/openapi-middleware.ts Lines 19 to 22 in 291beab
That URL should include the prefix, which is stored as Note that the type of the |
Run counterfact with --prefix /something
/something prefix is missing from Swagger
The text was updated successfully, but these errors were encountered: