-
Notifications
You must be signed in to change notification settings - Fork 241
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
Allow custom server/base urls in config #609
Comments
Hi @Dr-Electron, although what you're asking for is technically feasible, it would effectively allow the plugin to override the OpenAPI specification, which is a departure from the "read-only" approach we take today. Were you able to come up with a suitable workaround? |
Hi @sserrata I See your point, but I think having the possibility to allow custom "configs" on top of the spec is really worth it.
Other than that I didn't think too much about it yet, wanted to hear some other opinions first. |
I think it'd be a handy feature for anyone using an API for which they don't control the spec. As well, it'd be nice to allow users to manually input an endpoint when they hit |
This can already be achieved by adjusting the OpenAPI spec in
You can inject this before or after you generate the Inject beforeFor example in // Define new OpenApiServer
options.AddServer(new OpenApiServer
{
// Create a template URL and put the variables into {curly brackets}
Url = "https://{host}:{port}/v1",
// Define the variables and their default values
Variables =
{
{ "host": new OpenApiServerVariable { Default = "localhost" }},
{ "port": new OpenApiServerVariable { Default = 3000 }}
}
}); Inject afterTo inject after you'll need to augment the generated I created a separate How the script works:
You can learn more about the posibilities in the Swagger documentation: |
Supporting helpers to adapt OpenAPI spec server URLs for different envs is outside of the scope of this plugin. As mentioned in this thread, maintainers can use variables to support custom server URLs as needed. |
Is your feature request related to a problem?
Currently I generate a lot of API docs with your plugin, but as the endpoints are not fixed for our staging and production environment, I can't have static urls inside the specs.
Describe the solution you'd like
Would be nice to be able to specify a list of urls in the config.
Describe alternatives you've considered
I saw that there was another issue open at some point, which would allow adding new urls on the website, but that's not what I would need. It would be a nice feature, but for us the problem is more that we can't specify static urls. But I guess both could be added in one PR, with a config that allows the user to disable/enable the "add custom url in browser" feature and a possible list of urls.
The text was updated successfully, but these errors were encountered: