Skip to content
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

.httpyac.json file not overriding hard coded defaults #3

Closed
timhill-iress opened this issue Apr 8, 2021 · 12 comments
Closed

.httpyac.json file not overriding hard coded defaults #3

timhill-iress opened this issue Apr 8, 2021 · 12 comments

Comments

@timhill-iress
Copy link

What was I trying to do
I want to turn off console ansi colouring in the output

What did I try
I added a file called .httpyac.json and set the commandline --root parameter to the folder the file was in.
My .httpyac.json file contains:

{
    "log":{
        "supportAnsiColors":false
    }
}

What did I expect to happen
I expected the console output to not contain Colour Code characters.
Rather than this

�[33maccept-encoding�[0m: gzip, deflate, br

I expected
accept-encoding: gzip, deflate, br

What happened
The output still contained the colour code information
�[33maccept-encoding�[0m: gzip, deflate, br

Offer of help
I'm happy to make change and submit a PR, it may be overkill as it seems to be a one line change
https://github.com/AnWeber/httpyac/blob/main/src/environments/environmentStore.ts#L108

const environmentConfig: EnvironmentConfig = merge({}, ...(await this.loadFileEnvironemntConfigs(rootDirs)), config);
should be
const environmentConfig: EnvironmentConfig = merge({}, config, ...(await this.loadFileEnvironemntConfigs(rootDirs)));
to allow the .httpyac.config to overwrite the default configuration.

@AnWeber
Copy link
Owner

AnWeber commented Apr 8, 2021

Feel free to make a pull request. If not I can also change it tomorrow. I started from the vscode case, and initially wanted vscode settings to win. But I agree with you that it's probably better that way.

@AnWeber
Copy link
Owner

AnWeber commented Apr 8, 2021

Which Terminal do you use? Chalk supports detection of ansi support. Maybe I can use it.

@timhill-iress
Copy link
Author

I use the default Ubuntu terminal, the colours come out fine on that.
What I'm trying to do is generate some documentation that shows the actual request and response from the logged output that I could share with others.

@timhill-iress
Copy link
Author

I used to use Postman, then tried RestClient. I think httpyac will give me more of what I'm looking for.
I'm looking to re-create the type of documentation that you can generate from Postman when you save requests and responses as 'Examples' - the variables have been resolved. I think I might be able to do this with some custom script. A pre-request script to add add some markdown format headers to each request might give me something like what I would like.

@AnWeber
Copy link
Owner

AnWeber commented Apr 8, 2021

have now adjusted the priority. The defaults are now configured in the environmentStore, then httpyac.json and at the end the explicitly passed by the command line.

@AnWeber
Copy link
Owner

AnWeber commented Apr 8, 2021

For your use case I would use a Post Script and possibly copy and adapt code from toMarkdown

GET https://httpbin.org/json

{{
  const {toMarkdown} = require('./yourscript.js');
  const markdown = toMarkdown(httpRegion);
  console.info(markdown); // or require('fs').writeFile('...', markdown);
}}

Maybe you use my extension for vscode. There the console outputs are written to a separate OutputChannel. This is what I use for this use case (but without Markdown)

@AnWeber
Copy link
Owner

AnWeber commented Apr 9, 2021

I published a new release. Can you please verify the change.

@thegruffalo
Copy link

No problem, I'm happy to verify. I'll take a look on Saturday.
I'd had a little time today to look at your idea with producing the markdown from a global script at the end, I'll post details tomorrow.

@timhill-iress
Copy link
Author

Hi @AnWeber,
I checked out your changes for the .httpyac.json file. It now works, many thanks!
I did trip up with the .env file issue which I see you have already fixed, I managed to add

"dotenv": {
        "enabled": true,
        "defaultFiles": [".env"],
        "dirname": "env"
      },

to my httpyac.json file to get around it.

I've not had a chance to look at the new markdown functionality yet, but I'll look tomorrow.

@timhill-iress
Copy link
Author

Hi @AnWeber,
The markdown functionality also looks good. I've taken inspiration from your markdown utils to tailor it to my needs. Mostly filtering the headers down to the important headers.

@AnWeber
Copy link
Owner

AnWeber commented Apr 11, 2021

Glad I could help. Let me know if you have any other ideas for improvements.

@AnWeber
Copy link
Owner

AnWeber commented Jun 20, 2021

What I'm trying to do is generate some documentation that shows the actual request and response from the logged output that I could share with others.

@timhill-iress: You mentioned, that you were looking for a way to exchange documentation. Currently, notebooks are hyped for exactly this use case. I tried to do just that with httpBook. I'd be interested in your opinion on this, since you actually got me started on it.

httpbin.http
example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants