From a91b47543532a9d616995cea354fa9734f9f99b2 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Tue, 20 Feb 2024 16:12:19 -0500 Subject: [PATCH 1/2] don't throw on unknown format --- .../typespec-client-generator-core/src/types.ts | 2 +- .../test/types.test.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/typespec-client-generator-core/src/types.ts b/packages/typespec-client-generator-core/src/types.ts index dbd0ab0b26..bec7ee3a06 100644 --- a/packages/typespec-client-generator-core/src/types.ts +++ b/packages/typespec-client-generator-core/src/types.ts @@ -134,7 +134,7 @@ function addFormatInfo( propertyType.kind = "azureLocation"; break; default: - throw Error(`Unknown format ${format}`); + break; } } } diff --git a/packages/typespec-client-generator-core/test/types.test.ts b/packages/typespec-client-generator-core/test/types.test.ts index 79cdd23a46..c4bab9c57f 100644 --- a/packages/typespec-client-generator-core/test/types.test.ts +++ b/packages/typespec-client-generator-core/test/types.test.ts @@ -205,6 +205,22 @@ describe("typespec-client-generator-core: types", () => { } }); + it("unknown format", async function () { + await runner.compileWithBuiltInService( + ` + @usage(Usage.input | Usage.output) + @access(Access.public) + model Test { + @format("unknown") + unknownProp: string; + } + ` + ); + const models = getAllModelsAssertNoDiagnostics(runner.context); + strictEqual(models[0].kind, "model"); + strictEqual(models[0].properties[0].type.kind, "string"); + }); + it("known values", async function () { await runner.compileWithBuiltInService( ` From c6556aa82b21e0404a47d069d9631fc8c95d2365 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Tue, 20 Feb 2024 16:13:29 -0500 Subject: [PATCH 2/2] add changeset --- .chronus/changes/unknown_format-2024-1-20-16-12-31.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/unknown_format-2024-1-20-16-12-31.md diff --git a/.chronus/changes/unknown_format-2024-1-20-16-12-31.md b/.chronus/changes/unknown_format-2024-1-20-16-12-31.md new file mode 100644 index 0000000000..5d405e1421 --- /dev/null +++ b/.chronus/changes/unknown_format-2024-1-20-16-12-31.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-client-generator-core" +--- + +don't throw for unknown format \ No newline at end of file