Kong / Kong/httpsnippet

Support line wrap or fixed width in generated code snippet string

未关闭
#334 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
TypeScript
星标
1.2k
派生
242
PR 合并指标
30 天内没有已合并 PR

描述

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);
}

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 HTTPSnippet.convert 入口点开始,跟踪受影响目标的生成代码字符串是如何组装的。定义布尔选项或宽度选项应如何换行长值,同时不改变其他输出,然后验证生成的代码片段是否与请求的格式示例一致。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
tooling
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。