-
Notifications
You must be signed in to change notification settings - Fork 20
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
root folder determination #50
Comments
Wow, I have the same requirement! It seems a good chance for me to learn some vscode plugin development. 😂 |
I did not take care to separate the environment settings correctly in my implementation of vscode-httpyac. I have found this error before in workspace projects, but it also applies to this requirement. @linkdesu I think it's great if you want to actively support me. I'm just afraid that it's not a good example to start with. I have unfortunately the access to the environementStore scattered and also not cleanly separated between program setting and execution settings. |
Thank you @AnWeber. Yes, regarding the first example I had been using the
That makes sense. I don't know how much overhead this really represents. One thing you may be able to do is just scan once when the
Maybe 🤔. Anyway, you know what vscode extensions can / should do better than I so I'll let you do the thinking. 😇 |
Support for disconnected environments causes problems in some places:
I think the direction is good, but it will take a little while. |
Just a quick update. I already have a working stand locally that searches the folders correctly via tree traversal. There also doesn't seem to be any negative performance impact when parsing or executing. |
Excellent! Sounds like a Is the disabling of env / IntelliJ env settings temporary or will you no longer support them at all from To fully turn POSTman into PASTman in some of my more complicated projects, I plan on testing query dependency (query Since I want to share code between vscode and IntelliJ users, I will also test the limits of IntelliJ... but it looks like it's just too primitive with no ability to run pre-request code, no dependent queries, and maybe (I need to check) no ability to |
I no longer see the benefit in the settings (only httpyac configuration setting, not support for dotenv or intellij). I would have now dotenv and Intellij configurations enabled by default and based on the presence of such a file, detected the root. I don't think |
Makes sense. Even now I actually don't use those settings anyway.
Manually executing in the right order from the editor is essentially what I used to do in
Yes, I was worried when I saw no mention of it and only very simple examples in their docs... but it doesn't necessarily mean it doesn't work. I'll try next week. That honestly would be my biggest problem. IntelliJ's support of |
Since according to Intellij documentation ECMAScript 5.1 is supported and the Idea is developed with Java, I expect Java Nashorn to be used. And in the youtrack of Idea also Nashorn is mentioned (IDEA-241576). And Nashorn does not support
Do you use json schema for simple validation in the test cases? I was wondering myself if this is useful and easy to do, but I don't have much experience with JSON schema. However, my concerns are more about how easily necessary JSON schemas can be generated. |
IMO a well defined JSONschema can be really useful. It can both help generate the open API style documentation for using the endpoints, and also feed the tests. The spec is so flexible that I find that the JSONschema replaces most (often all) tests I would manually write for the endpoint. For JSONschema generally I do something like this:
The schemas are either downloaded or taken from the file system within the open API doc. So there are a bunch of functions for that.. const validate = require('jsonschema').validate
// functions to resolve paths and in-schema references to other files
module.exports.is = async ({ test, response, name }) => {
// ex: this is where my open API spec lives when present in the repo
const schema = require(`${baseRespSchemaDir}/${name}.json`)
test('Schema is valid', function () {
const validation = validate(
response.parsedBody,
convertRefs(schema, baseRespSchemaDir), // the schema object goes here (custom function because I often deeply divide and nest my schemas)
{ required: true }
)
if (validation.valid) return true
const error = new Error('Response schema is incorrect: ' + validation.errors[0].message)
error.name = 'SCHEMA_ERR'
throw error
})
} I usually like to keep schema files small and hierarchical like this: // simple health check endpoint
// schemas/responses/status-ok.json
{
"type": "object",
"properties": {
"status": { "type": "string", "const": "ok" }
},
"required": ["status"]
}
// simple list object with dynamic keys
// schemas/objects/list/index.json
{
"type": "object",
"patternProperties": {
"^[A-Z]{3}$": {
"$ref": "../something/index.json"
}
},
"minProperties": 100
}
// the `something` referenced in the previous schema
// schemas/objects/something/index.json
{
"type": "object",
"properties": {
"name": { "type": "string" },
"last_update": {
"type": "string",
"pattern": "^20[1-9][0-9]-(([1][0-2])|([0][0-9]))-[0-3][0-9]$"
}
},
"required": ["name"]
} |
I will use this week to expand my documentation. The extension has already passed my first test. But I will use the version for one more week at work. You can install them using this guide. |
I have now created a separate page for the documentation: https://httpyac.github.io/. |
In the extension it seems that the httpyac root folder is always assumed to be vscode's root folder. So the extension looks for an
env
folder, or apackage.json
withhttpyac
key, or a.httpyac.json
file there. I think this works fine in a lot of cases but it may break down in a few (ex: monorepo or strict hierarchical structure).Example
I recently tried something like this:
In this structure, it seems the CLI will have no issues if run from
/tests/http
as it will assume this is its root folder (I think), but vscode will only look in its own project root so that the options have to be configured there:Personally I would prefer to keep everything in the
/tests/http
folder in this case.Suggestion
This works but if at all possible, it would be nice to do something like this for vscode:
I realize this may be confusing to the extension if we have something like this:
When running something from
tests1
no problem..tests1
's settings will apply, but then when running something fromtests2
perhaps vscode-httpyac will not be sure what to do (which environments to show and/or apply). If it is possible to namespace and fully isolate when 2 or more configs are found this would be my preference, so that anything fromtests1
is invisible totests2
... and when looking at a file intests2
nothing fromtests1
one shows or applies.The text was updated successfully, but these errors were encountered: