Support line wrap or fixed width in generated code snippet string

Open
#334 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
tooling

Research direction

Start at the HTTPSnippet.convert entry point and trace how generated code strings are assembled for the affected targets. Define how a boolean or width option should wrap long values without changing other output, then verify the generated snippet matches the requested formatting example.

Written by the indexing model from the issue text.

Description

Hi, is there any plans to support a fixed width or line break for the generated string from HTTPSnippet.convert?

While generating the string, in certain use cases, the output string could be quite long for some lines, and seems like there is no options to have line break or line wrap.

For example, the following code snippet would be hard to view since it takes too much horizontal width (the url field):

import axios from 'axios';

const options = {
  method: 'POST',
  url: 'https://url.com/this_is_a_super_long_url_this_is_a_super_long_url_this_is_a_super_long_url_this_is_a_super_long_url_'
};

try {
  const { data } = await axios.request(options);
  console.log(data);
} catch (error) {
  console.error(error);
}

If we could possibly add a line break (boolean, or width as a number) as an option:

import axios from 'axios';

const options = {
  method: 'POST',
  url: 'https://url.com/this_is_a_super_long_url
       _this_is_a_super_long_url_this_is_a_sup
       er_long_url_this_is_a_super_long_url_'
};

try {
  const { data } = await axios.request(options);
  console.log(data);
} catch (error) {
  console.error(error);
}
Dominant language
TypeScript
Stars
1.2k
Forks
242
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Kong/httpsnippet

All issues in Kong/httpsnippet

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.