[Bug]: `@encode(string)` int64 default becomes `null`, and numeric examples ignore the encoding
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- openapi
- 領域
- api
調査の方向性
packages/compiler/src/lib/examples.ts から始めて serializeValueAsJson を読み、NumericValue の処理とプロパティの解決済み @encode に注目してください。提供された Account モデルを再現し、デフォルト値と例について OpenAPI の出力を確認してください。エンコードされた int64 と decimal の値が、巨大な int64 のデフォルト値を含め、null や JSON の数値ではなく文字列として出力されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With @encode(string) id: int64 = 9007199254740993, the OpenAPI output has "default": null, so the value is lost. Other defaults and @example values on @encode(string) int64 and decimal properties come out as JSON numbers, which don't match the type: string next to them.
serializeValueAsJson in packages/compiler/src/lib/examples.ts already resolves the property's @encode, but the NumericValue case returns asNumber() without checking it, and asNumber() gives null when a JS number can't hold the value exactly. Dates and durations already use the encoding in that function (#11731 fixed the milliseconds case). Happy to send a PR.
Reproduction
@example(#{ id: 42, balance: 1050.25 })
model Account {
@encode(string) id: int64 = 9007199254740993;
@encode(string) balance: decimal = 0;
}
OpenAPI 3.0.0 output on current main. 3.1.0 and 3.2.0 give the same defaults.
"properties": {
"id": { "type": "string", "format": "int64", "default": null },
"balance": { "type": "string", "format": "decimal", "default": 0 }
},
"example": { "id": 42, "balance": 1050.25 }
Expected "9007199254740993" and "0" for the defaults, and { "id": "42", "balance": "1050.25" } for the example.
- 主要言語
- Java
- スター
- 5.9k
- フォーク
- 403
- 平均マージ
- 3日 8時間
- マージ済み PR(30日)
- 101
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/typespec のほかの issue
-
Http-client-js operation response on the client doesn't carry the return type対応中かも @reginaldalfret が 14 日前に担当しました。 オープンemitter:client:js
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/typespec#11853 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: @terminalEvent on a model-payload variant emits an unconstrained oneOf branch in OpenAPI 3.2 SSE output対応中かも @Shubham-Padkonde が 25 日前に担当しました。 オープンbug emitter:openapi3 triaged:core
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/typespec#11747 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: [http-server-csharp] Model with a `Record<unknown>[]` property generates C# that does not compile (missing `using System.Text.Json.Nodes;`)再び着手できるかも @nightcityblade が 44 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug emitter:service:csharp triaged:core
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
microsoft/typespec#11733 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
emitter:client:java feature
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
microsoft/typespec#11076 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: http-client-js expand guards use truthy check, dropping falsy values like false and 0再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンemitter:client:js
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/typespec#10264 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
microsoft/typespec の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug new windows
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
GantMan/jail-monkey#380 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
objectionary/jucs#145 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
objectionary/lints#1559 ·
メンテナーはふだん 2 日以内に返信