Http requests - using multiple http-client.private.env.json files in different directories

I have a single project, and within it I want to test multiple APIs.  Some of these are defined within the project, and some are 3rd party.  So roughly speaking I have:

tests
    api1
        http-client-private.env.json
        ....some .http files
    api2
        http-client-private.env.json
        ....some .http files
   ...etc...

However, when I try to run the http scripts in api1, I see environments defined for both api1 and api2.  This means I need to carefully choose which environment to select, as some in the list won't apply, and I choose the wrong one it errors.  (Actually the lists are 100% mutually exclusive)

Worse than this, if I define the same host names in both files, then I just get an error.  Yes I could name "local" to be "local-api1" and "dev" to be "dev-api1", etc etc but it compounds the first problem.

Is this a bug or by design ??  It would make more sense to me if settings cascaded down from parent directories, but in sibling or unrelated directories they were independent.

I'm using PyCharm, but I'm reasonably sure I've seen it in other IDEs, so posted it in intellij as I think it's a core issue rather than IDE specific.

11

It's worse than that.  This also causes problems with the http-client.env.json if two separate files define the same environment. 

So if you import 2 modlues that both define the same environments it complains that the environment is defined in multiple files.

If there are multiple files, instead of an error it should use some form of priority to pick a file (or merge the files and have a priority to pick a value in the case of conflicting values).  E.g. look in the current directory first, otherwise up the directory hierarchy, otherwise anywhere in the current module (if there are multiple files, order them by their alpha path to the file), otherwise anywhere in the current project (again resolve multiples using alpha sort on the. path).

As it currently works, I have to delete the file from the second project and remember not to check it in.  Or I have to use different environment names in every module, which is really subpar.

In my case this was using IntelliJ.

2

请先登录再写评论。