diff --git a/.chronus/changes/canonical_emitter_set_option_and_commontype_check-2024-6-24-11-03-51.md b/.chronus/changes/canonical_emitter_set_option_and_commontype_check-2024-6-24-11-03-51.md new file mode 100644 index 0000000000..984bce54a4 --- /dev/null +++ b/.chronus/changes/canonical_emitter_set_option_and_commontype_check-2024-6-24-11-03-51.md @@ -0,0 +1,9 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@azure-tools/typespec-autorest-canonical" +--- + +set option "use-read-only-status-schema" to true to fix ProvisioningStateMustBeReadOnly bug; +add isArmCommonType check to avoid decorator validation in canonical emitter diff --git a/.chronus/changes/update_canonical_swagger_folder_name-2024-6-6-11-44-3.md b/.chronus/changes/update_canonical_swagger_folder_name-2024-6-6-11-44-3.md new file mode 100644 index 0000000000..14101dc92c --- /dev/null +++ b/.chronus/changes/update_canonical_swagger_folder_name-2024-6-6-11-44-3.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-autorest-canonical" +--- + +update the canonical swagger file folder name diff --git a/packages/typespec-autorest-canonical/package.json b/packages/typespec-autorest-canonical/package.json index bc4cb420f2..778c8801b5 100644 --- a/packages/typespec-autorest-canonical/package.json +++ b/packages/typespec-autorest-canonical/package.json @@ -55,12 +55,14 @@ "peerDependencies": { "@azure-tools/typespec-autorest": "workspace:~", "@azure-tools/typespec-azure-core": "workspace:~", + "@azure-tools/typespec-azure-resource-manager": "workspace:~", "@azure-tools/typespec-client-generator-core": "workspace:~", "@typespec/versioning": "workspace:~" }, "devDependencies": { "@azure-tools/typespec-autorest": "workspace:~", "@azure-tools/typespec-azure-core": "workspace:~", + "@azure-tools/typespec-azure-resource-manager": "workspace:~", "@azure-tools/typespec-client-generator-core": "workspace:~", "@types/node": "~18.11.19", "@typespec/compiler": "workspace:~", diff --git a/packages/typespec-autorest-canonical/src/emitter.ts b/packages/typespec-autorest-canonical/src/emitter.ts index e4919b12b6..2719c39a01 100644 --- a/packages/typespec-autorest-canonical/src/emitter.ts +++ b/packages/typespec-autorest-canonical/src/emitter.ts @@ -4,6 +4,7 @@ import { getOpenAPIForService, sortOpenAPIDocument, } from "@azure-tools/typespec-autorest"; +import { isArmCommonType } from "@azure-tools/typespec-azure-resource-manager"; import { SdkContext, createSdkContext } from "@azure-tools/typespec-client-generator-core"; import { EmitContext, @@ -65,6 +66,7 @@ export async function $onEmit(context: EmitContext { + if (isArmCommonType(prop) || (prop.model && isArmCommonType(prop.model))) { + return; + } + if (getRenamedFrom(program, prop)) { reportDisallowedDecorator("renamedFrom", prop); } diff --git a/packages/typespec-autorest-canonical/test/property-schema.test.ts b/packages/typespec-autorest-canonical/test/property-schema.test.ts deleted file mode 100644 index a9480e0a19..0000000000 --- a/packages/typespec-autorest-canonical/test/property-schema.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { deepStrictEqual, ok } from "assert"; -import { it } from "vitest"; -import { openApiFor } from "./test-host.js"; - -it("produces standard schema for lro status by default", async () => { - const result = await openApiFor( - ` - @service({title: "Test"}) - namespace Test; - - model Bar {propB: int32;} - model Foo { prop1: string;} - - enum FooPrime { Succeeded, Failed, Canceled} - - @pattern("[a-Z0-9]+") - scalar BarPrime extends string; - - model UsesAll { - @visibility("read") - fooProp: Foo; - @visibility("read") - primeProp: FooPrime; - @visibility("read") - barPrimeProp: BarPrime; - } - - op myOp(): void; - - - ` - ); - - ok(!result.isRef); - deepStrictEqual(result.definitions.FooPrime.readOnly, undefined); -}); diff --git a/packages/typespec-autorest-canonical/test/test-host.ts b/packages/typespec-autorest-canonical/test/test-host.ts index 0cc7e9abf8..401ea40aa9 100644 --- a/packages/typespec-autorest-canonical/test/test-host.ts +++ b/packages/typespec-autorest-canonical/test/test-host.ts @@ -1,5 +1,6 @@ import { OpenAPI2Document } from "@azure-tools/typespec-autorest"; import { AzureCoreTestLibrary } from "@azure-tools/typespec-azure-core/testing"; +import { AzureResourceManagerTestLibrary } from "@azure-tools/typespec-azure-resource-manager/testing"; import { SdkTestLibrary as TcgcTestLibrary } from "@azure-tools/typespec-client-generator-core/testing"; import { Diagnostic } from "@typespec/compiler"; import { @@ -26,6 +27,7 @@ export async function createAutorestCanonicalTestHost() { AutorestCanonicalTestLibrary, VersioningTestLibrary, AzureCoreTestLibrary, + AzureResourceManagerTestLibrary, TcgcTestLibrary, ], }); diff --git a/packages/typespec-autorest-canonical/tsconfig.json b/packages/typespec-autorest-canonical/tsconfig.json index f952fb2f3a..c2be90093c 100644 --- a/packages/typespec-autorest-canonical/tsconfig.json +++ b/packages/typespec-autorest-canonical/tsconfig.json @@ -5,7 +5,8 @@ { "path": "../../core/packages/compiler/tsconfig.json" }, { "path": "../../core/packages/http/tsconfig.json" }, { "path": "../../core/packages/openapi/tsconfig.json" }, - { "path": "../typespec-azure-core/tsconfig.json" } + { "path": "../typespec-azure-core/tsconfig.json" }, + { "path": "../typespec-azure-resource-manager/tsconfig.json" } ], "compilerOptions": { "outDir": "dist", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 05124391d2..b204af9594 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1661,6 +1661,9 @@ importers: '@azure-tools/typespec-azure-core': specifier: workspace:~ version: link:../typespec-azure-core + '@azure-tools/typespec-azure-resource-manager': + specifier: workspace:~ + version: link:../typespec-azure-resource-manager '@azure-tools/typespec-client-generator-core': specifier: workspace:~ version: link:../typespec-client-generator-core