="` 傳入。">
Skip to content

Emitter 選項

tspconfig.yaml 設定,或在 CLI 以 --option "tsp-asyncapi.<name>=<value>" 傳入。

選項型別預設值效果
file-type"yaml" | "json"yaml文件的序列化格式。
output-filestringasyncapi.yamlfile-typejson 時是 asyncapi.json輸出檔名,寫在 tsp-output/tsp-asyncapi/ 底下。
asyncapi-idstring(省略)輸出為文件頂層的 id 欄位,即應用程式的全域識別碼,慣例上用 URN。
default-content-typestring(省略)輸出為 defaultContentType。message 沒宣告 content type 時,payload 用這個。

沒設定的選項會整個從文件省略,不會輸出空值。

tspconfig.yaml

yaml
emit:
  - "tsp-asyncapi"
options:
  "tsp-asyncapi":
    output-file: "orders.yaml"
    file-type: "yaml"
    asyncapi-id: "urn:com:example:orders"
    default-content-type: "application/json"

用 CLI

bash
tsp compile . --emit tsp-asyncapi \
  --option "tsp-asyncapi.file-type=json" \
  --option "tsp-asyncapi.asyncapi-id=urn:com:example:orders"

未知的選項名稱會在編譯時驗證失敗(additionalProperties: false)。打錯字會被抓到,不會被靜默忽略。