-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Import multiple envs when importing OpenAPI3 #4254
Import multiple envs when importing OpenAPI3 #4254
Conversation
Really looking forward to using this, thank you! |
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.
Thank you for the PR! A couple of notes, namely the _id
and name
generation for the sub-environments.
(The CI errors are linting, which should be fixed up with npm run lint:fix
).
const basePath = (currentServerUrl.pathname || '').replace(/\/$/, ''); | ||
const openapiEnv: ImportRequest = { | ||
_type: 'environment', | ||
_id: 'env___BASE_ENVIRONMENT_ID___sub', |
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.
This will cause all of the sub environments to have the same id and insomnia won't see them as unique.
In other areas we append a hash of the dependent property to make the id deterministic and unique. What would be a dependent property here - the URL? Ie. if the server URL changes, a new sub environment will be created.
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.
Nice catch. I'll fix it.
_type: 'environment', | ||
_id: 'env___BASE_ENVIRONMENT_ID___sub', | ||
parentId: baseEnv._id, | ||
name: 'OpenAPI env', |
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.
Same note as above, the name for each sub environment will be OpenAPI env
. What would you expect the environment created from each new server to be named?
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.
I'll fix it too
@@ -10,3 +10,92 @@ describe('Import errors', () => { | |||
} | |||
}); | |||
}); | |||
|
|||
describe('Import OpenApi', () => { |
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.
Any particular reason you chose to add tests like this instead of adding to the fixtures in packages/insomnia-importers/src/importers/fixtures/openapi3?
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.
No particular reason, just didn't understand the test mechanism. So I wrote this one.
I'll do it in the same way as the other tests.
b737207
to
04fc821
Compare
This would be really useful for getting Insomnia into my organisation. Is there something I can do to help get this finished? I'm not sure what's left to do. |
I also hope to have this improvement in Insomnia. |
This feels very necessary to work with insomnia when our primary source is OpenAPI. Is there a problem with the PR? |
9c8f007
to
26727c4
Compare
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.
Sorry for the long wait @sixdouglas
Rebased with latest develop and fixed lint and tests.
Tested locally, LGTM! Waiting for someone else from @Kong/team-insomnia to give the 👍
5aa1e70
to
e592ea6
Compare
e592ea6
to
a447cb9
Compare
* feat(import): import multiple envs when importing OpenAPI3 When the OpenApi file to import contains multiple servers, import each one as an environment. Closes Kong#3627 * feat(import): import multiple envs when importing OpenAPI3 When the OpenApi file to import contains multiple servers, import each one as an environment. Closes Kong#3627 * fix lint and tests & rebase with latest develop Co-authored-by: SIX Douglas <douglas.six@ext.adeo.com> Co-authored-by: Filipe Freire <livrofubia@gmail.com>
changelog(Improvements): Each OpenAPI server is now imported as a sub-environment
When the OpenApi file to import contains multiple servers, import each one as an environment.
Closes #3627