Generate Robust C# Code
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- csharp, typescript
調査の方向性
C# のスニペット生成のエントリーポイントから始め、現在の form-urlencoded 出力を issue の 2 つの例と比較し、パラメーター名と値がどのように表現されているかに注目します。生成された C# が、エンコード済みのリクエストボディ文字列を 1 つ埋め込むのではなく、実行時に安全な URL エンコードを用いたリクエストパラメーターを使用すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Improvement Suggestion:
I would have liked the following autogenerated C# for a HTTP POST request with the single parameter err of value + & serialized as x-www-form-urlencoded in the body.
var client = new RestClient("https://localhost");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "da4d0044-61a9-3943-40db-9e753aca6020");
request.AddHeader("cache-control", "no-cache");
Action<string,string> parameter = (name, value) => request.AddParameter(name, value);
parameter("err", "+ &");
IRestResponse response = client.Execute(request);
but what Postman did produce for me was the following C# code:
var client = new RestClient("https://localhost");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "da4d0044-61a9-3943-40db-9e753aca6020");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "err=%2B%20%26", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Rationale
parameter("err", "+ &");is more readable than "[..]err=%2B%20%26[..]". The value,+ &, is more recognizable.- The code is more maintanable. At work, I tried the following development workflow:
(a) Type a minimal working example request into to Postman.
(b) Generate C# code.
(c) Copy generated code to Visual Studio.
(d) Replace example values by C# method parameters.
This workflow failed, because the method parameters were not x-www-form-urlencoded at runtime. Generating UrlEncode() calls would make writing a consumer of a HTTP POST x-www-form-urlencoded API effortless. - This usage of
IRestRequest.AddParameteris encouraged, whereas the currently generated code depends on an internal hack not meant for 3rd party usage.
/// - RequestBody: Used by AddBody() (not recommended to use directly)
App Details:
Postman for Windows
Version 5.3.2
win32 6.1.7601 / x64
Continuation of: https://github.com/postmanlabs/postman-app-support/issues/3870
- 主要言語
- TypeScript
- スター
- 1.2k
- フォーク
- 242
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Kong/httpsnippet のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
Kong/httpsnippet#356 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
Kong/httpsnippet#389 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
Kong/httpsnippet#383 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
Kong/httpsnippet#379 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
Kong/httpsnippet#370 ·
Kong/httpsnippet の issue をすべて見る
似ている issue
-
comp/desktop P3 type/bug
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
NousResearch/hermes-agent#118866 ·
-
Browser Waiting for: Product Owner
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
getsentry/sentry-javascript#24577 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
agilepathway/label-checker#640 ·
-
Plugin stuck at "loading" on DSH 0.1.6-alpha.2 — turnTail list slot registration missing options.id オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
chrisparsons83/flexspotff#153 ·