-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: OpenAPI import: create a default environment #1240
feat: OpenAPI import: create a default environment #1240
Conversation
The previous solution constructed a default server baseUrl and directly concatenated it into each request of the collection. This makes it difficult to change it later through the UI if it is wrong or if the same OpenAPI spec can be used in multiple environments. This solution instead creates a default environment with two variables "protocol" and "host", which are filled according to the previously constructed default baseUrl. This makes it very easy to change for all requests.
Any updates on getting this merged...? This is a pain when working with large APIs with different environments... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your solution is not any better than the way it currently works. I need the whole host to come from a variable, and your solution would break that. You can just replace your hosts in your collection this way with your own script if you need it. That's what I ended up doing anyway
Right, but this way you can change it through the UI, that's better than writing a script, if you ask me. Would you be happy with this PR if the whole base url was a single variable? |
Hello, Maybe we can use vars and define an OpenAPI extension for describe envrionments https://spec.openapis.org/oas/latest.html#specification-extensions If OpenAPI spec file contain x-bruno-environments, we can use it for environments generation "servers": [
{
"url": "https://{{hostApim}}{{pathSites}}"
}
],
"x-bruno-environments": [
{
"name": "dev",
"vars": [
{
"name": "hostApim",
"value": "gatewayapi-dev.com",
"enabled": true
},
{
"name": "pathSites",
"value": "/myapi",
"enabled": true
},
{
"name": "apiKey",
"value": "9ef58158-0235-4a75-821d-51a12256b0ku",
"enabled": true
}
]
},
{
"name": "prd",
"vars": [
{
"name": "hostApim",
"value": "gatewayapi-prd.com",
"enabled": true
},
{
"name": "pathSites",
"value": "/myapi",
"enabled": true
},
{
"name": "apiKey",
"value": "",
"enabled": true
}
]
}
] |
I make a PR with my proposition #2088 with that you can create and describe multiple environment. |
Closing this PR as this has been addressed in #3267 |
Description
Fixes #1239
The previous solution constructed a default server baseUrl and directly concatenated it into each request of the collection. This makes it difficult to change it later through the UI if it is wrong or if the same OpenAPI spec can be used in multiple environments.
This solution instead creates a default environment with two variables "protocol" and "host", which are filled according to the previously constructed default baseUrl. This makes it very easy to change for all requests while preserving the server information extracted from the spec.
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.