diff --git a/common/config/rush/pnpm-config.json b/common/config/rush/pnpm-config.json index ba5367bae0..56faadbd44 100644 --- a/common/config/rush/pnpm-config.json +++ b/common/config/rush/pnpm-config.json @@ -1,5 +1,5 @@ { - "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/pnpm-config.schema.json", - "useWorkspaces": true, - "strictPeerDependencies": false + "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/pnpm-config.schema.json", + "useWorkspaces": true, + "strictPeerDependencies": false } diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 2aa31a9c9c..3445535be1 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -191,34 +191,34 @@ importers: ../../packages/typespec-test: specifiers: - '@azure-tools/typespec-autorest': '>=0.33.0 <1.0.0' - '@azure-tools/typespec-azure-core': '>=0.33.0 <1.0.0' - '@azure-tools/typespec-client-generator-core': '>=0.33.0 <1.0.0' + '@azure-tools/typespec-autorest': '>=0.34.0 <1.0.0' + '@azure-tools/typespec-azure-core': '>=0.34.0 <1.0.0' + '@azure-tools/typespec-client-generator-core': 0.35.0-dev.9 '@azure-tools/typespec-ts': workspace:^0.16.0 '@types/mocha': ^5.2.7 '@types/node': ^18.0.0 - '@typespec/compiler': '>=0.47.0 <1.0.0' - '@typespec/http': '>=0.47.0 <1.0.0' - '@typespec/openapi': '>=0.47.0 <1.0.0' - '@typespec/openapi3': '>=0.47.0 <1.0.0' - '@typespec/prettier-plugin-typespec': '>=0.47.0 <1.0.0' - '@typespec/rest': '>=0.47.0 <1.0.0' - '@typespec/versioning': '>=0.47.0 <1.0.0' + '@typespec/compiler': '>=0.48.0 <1.0.0' + '@typespec/http': '>=0.48.0 <1.0.0' + '@typespec/openapi': '>=0.48.0 <1.0.0' + '@typespec/openapi3': '>=0.48.0 <1.0.0' + '@typespec/prettier-plugin-typespec': '>=0.48.0 <1.0.0' + '@typespec/rest': '>=0.48.0 <1.0.0' + '@typespec/versioning': '>=0.48.0 <1.0.0' prettier: 2.7.1 ts-node: ^8.5.2 typescript: ~5.0.0 dependencies: - '@azure-tools/typespec-autorest': 0.33.0_ouhlltfkcmbt2pzjg2glysmpt4 - '@azure-tools/typespec-azure-core': 0.33.1_rsgpzskpshtrui6ybsakstscc4 - '@azure-tools/typespec-client-generator-core': 0.33.0_ccoaydaumvpjzq7pj6wod3i6ou + '@azure-tools/typespec-autorest': 0.34.0_jl56gonsqstmczul43lhj2b6re + '@azure-tools/typespec-azure-core': 0.34.0_hp7rvmmczsxuulqidytkvjza5i + '@azure-tools/typespec-client-generator-core': 0.35.0-dev.9_6erv5apx7dld7z65vulofmtudi '@azure-tools/typespec-ts': link:../typespec-ts - '@typespec/compiler': 0.47.1 - '@typespec/http': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/openapi': 0.47.0_rsgpzskpshtrui6ybsakstscc4 - '@typespec/openapi3': 0.47.0_6zgfza5j6pxgqvpitlqhaqcuje - '@typespec/prettier-plugin-typespec': 0.47.0 - '@typespec/rest': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/versioning': 0.47.0_@typespec+compiler@0.47.1 + '@typespec/compiler': 0.48.0 + '@typespec/http': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/openapi': 0.48.0_hp7rvmmczsxuulqidytkvjza5i + '@typespec/openapi3': 0.48.0_ftmjutoeiczodakwe67k3csnhq + '@typespec/prettier-plugin-typespec': 0.48.0 + '@typespec/rest': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/versioning': 0.48.0_@typespec+compiler@0.48.0 prettier: 2.7.1 devDependencies: '@types/mocha': 5.2.7 @@ -233,8 +233,8 @@ importers: '@azure-tools/cadl-ranch-expect': ^0.6.0 '@azure-tools/cadl-ranch-specs': ^0.18.0 '@azure-tools/rlc-common': workspace:^0.16.0 - '@azure-tools/typespec-azure-core': '>=0.33.0 <1.0.0' - '@azure-tools/typespec-client-generator-core': '>=0.33.0 <1.0.0' + '@azure-tools/typespec-azure-core': '>=0.34.0 <1.0.0' + '@azure-tools/typespec-client-generator-core': 0.35.0-dev.9 '@azure/core-auth': ^1.3.2 '@azure/core-lro': ^2.5.4 '@azure/core-paging': ^1.5.0 @@ -248,10 +248,10 @@ importers: '@types/prettier': ^2.6.0 '@typescript-eslint/eslint-plugin': ^5.58.0 '@typescript-eslint/parser': ^5.58.0 - '@typespec/compiler': '>=0.47.0 <1.0.0' - '@typespec/http': '>=0.47.0 <1.0.0' - '@typespec/rest': '>=0.47.0 <1.0.0' - '@typespec/versioning': '>=0.47.0 <1.0.0' + '@typespec/compiler': '>=0.48.0 <1.0.0' + '@typespec/http': '>=0.48.0 <1.0.0' + '@typespec/rest': '>=0.48.0 <1.0.0' + '@typespec/versioning': '>=0.48.0 <1.0.0' chai: ^4.3.6 chalk: ^4.0.0 cross-env: ^7.0.3 @@ -267,21 +267,21 @@ importers: typescript: ~5.0.0 dependencies: '@azure-tools/rlc-common': link:../rlc-common - '@azure-tools/typespec-azure-core': 0.33.1_rsgpzskpshtrui6ybsakstscc4 - '@azure-tools/typespec-client-generator-core': 0.33.0_ccoaydaumvpjzq7pj6wod3i6ou - '@typespec/compiler': 0.47.1 - '@typespec/http': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/rest': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/versioning': 0.47.0_@typespec+compiler@0.47.1 + '@azure-tools/typespec-azure-core': 0.34.0_hp7rvmmczsxuulqidytkvjza5i + '@azure-tools/typespec-client-generator-core': 0.35.0-dev.9_6erv5apx7dld7z65vulofmtudi + '@typespec/compiler': 0.48.0 + '@typespec/http': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/rest': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/versioning': 0.48.0_@typespec+compiler@0.48.0 fs-extra: 11.1.1 prettier: 2.7.1 ts-morph: 15.1.0 tslib: 2.6.1 devDependencies: '@azure-rest/core-client': 1.1.4 - '@azure-tools/cadl-ranch': 0.7.0_d7m5nitpni5mqp3y5w3y4aqymu - '@azure-tools/cadl-ranch-expect': 0.6.0_ccoaydaumvpjzq7pj6wod3i6ou - '@azure-tools/cadl-ranch-specs': 0.18.0_i6m56vm2373g7aupg6kc6ttsfe + '@azure-tools/cadl-ranch': 0.7.0_7jjucimetrv3zkc4qdajxl7ram + '@azure-tools/cadl-ranch-expect': 0.6.0_6erv5apx7dld7z65vulofmtudi + '@azure-tools/cadl-ranch-specs': 0.18.0_nrocqdo7ik2kdwzqymyxmnaqvq '@azure/core-auth': 1.5.0 '@azure/core-lro': 2.5.4 '@azure/core-paging': 1.5.0 @@ -383,7 +383,22 @@ packages: - supports-color dev: true - /@azure-tools/cadl-ranch-expect/0.6.0_ccoaydaumvpjzq7pj6wod3i6ou: + /@azure-tools/cadl-ranch-expect/0.6.0_6erv5apx7dld7z65vulofmtudi: + resolution: {integrity: sha512-symkbB9p1VMUs6VvFu465ACZPZrPn9sAP/Anjccx9grW0pkrQnE84lA9vkezJ9pJoT+vrJdpPEnjZjNoBQ8GFQ==} + engines: {node: '>=16.0.0'} + peerDependencies: + '@typespec/compiler': ~0.47.0 + '@typespec/http': ~0.47.0 + '@typespec/rest': ~0.47.0 + '@typespec/versioning': ~0.47.0 + dependencies: + '@typespec/compiler': 0.48.0 + '@typespec/http': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/rest': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/versioning': 0.48.0_@typespec+compiler@0.48.0 + dev: true + + /@azure-tools/cadl-ranch-expect/0.6.0_hqlbpuhpecdzwnemap3nprt7re: resolution: {integrity: sha512-symkbB9p1VMUs6VvFu465ACZPZrPn9sAP/Anjccx9grW0pkrQnE84lA9vkezJ9pJoT+vrJdpPEnjZjNoBQ8GFQ==} engines: {node: '>=16.0.0'} peerDependencies: @@ -395,10 +410,10 @@ packages: '@typespec/compiler': 0.47.1 '@typespec/http': 0.47.0_@typespec+compiler@0.47.1 '@typespec/rest': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/versioning': 0.47.0_@typespec+compiler@0.47.1 + '@typespec/versioning': 0.48.0_@typespec+compiler@0.48.0 dev: true - /@azure-tools/cadl-ranch-specs/0.18.0_i6m56vm2373g7aupg6kc6ttsfe: + /@azure-tools/cadl-ranch-specs/0.18.0_nrocqdo7ik2kdwzqymyxmnaqvq: resolution: {integrity: sha512-9BGsOzH+dZZo65vMmxa+faMvAbhFDRJueD4UxC0adgvCWFhloQipQtYcbDPsDqXOBM4PD7i3lzt5pI5/Qkfg0A==} engines: {node: '>=16.0.0'} peerDependencies: @@ -409,28 +424,28 @@ packages: '@typespec/rest': ~0.47.0 '@typespec/versioning': ~0.47.0 dependencies: - '@azure-tools/cadl-ranch': 0.7.0_d7m5nitpni5mqp3y5w3y4aqymu + '@azure-tools/cadl-ranch': 0.7.0_7jjucimetrv3zkc4qdajxl7ram '@azure-tools/cadl-ranch-api': 0.4.0 - '@azure-tools/cadl-ranch-expect': 0.6.0_ccoaydaumvpjzq7pj6wod3i6ou - '@azure-tools/typespec-azure-core': 0.33.1_rsgpzskpshtrui6ybsakstscc4 - '@typespec/compiler': 0.47.1 - '@typespec/http': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/rest': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/versioning': 0.47.0_@typespec+compiler@0.47.1 + '@azure-tools/cadl-ranch-expect': 0.6.0_6erv5apx7dld7z65vulofmtudi + '@azure-tools/typespec-azure-core': 0.34.0_hp7rvmmczsxuulqidytkvjza5i + '@typespec/compiler': 0.48.0 + '@typespec/http': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/rest': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/versioning': 0.48.0_@typespec+compiler@0.48.0 transitivePeerDependencies: - '@types/express' - encoding - supports-color dev: true - /@azure-tools/cadl-ranch/0.7.0_d7m5nitpni5mqp3y5w3y4aqymu: + /@azure-tools/cadl-ranch/0.7.0_7jjucimetrv3zkc4qdajxl7ram: resolution: {integrity: sha512-udtCNpsRvuQC17aBV8ed+D+9gr0X/sF6n9v+JSDeHlT1BEXAqsml2xbU/TuQPj1v11K0E/6Ft336oA+qYvIlDA==} engines: {node: '>=16.0.0'} hasBin: true dependencies: '@azure-tools/cadl-ranch-api': 0.4.0 '@azure-tools/cadl-ranch-coverage-sdk': 0.3.0 - '@azure-tools/cadl-ranch-expect': 0.6.0_ccoaydaumvpjzq7pj6wod3i6ou + '@azure-tools/cadl-ranch-expect': 0.6.0_hqlbpuhpecdzwnemap3nprt7re '@azure/identity': 3.2.4 '@types/js-yaml': 4.0.5 '@typespec/compiler': 0.47.1 @@ -485,52 +500,51 @@ packages: - supports-color dev: true - /@azure-tools/typespec-autorest/0.33.0_ouhlltfkcmbt2pzjg2glysmpt4: - resolution: {integrity: sha512-xA29JJt6Dnb8402xYJrR1dAwzEuhen/gcYeUk4KZrfn/3FsLpfiGQCwTAfcCd6iyLDRx7yQ34ysJmLt5ebcOdw==} + /@azure-tools/typespec-autorest/0.34.0_jl56gonsqstmczul43lhj2b6re: + resolution: {integrity: sha512-Fr5obMJzBgVzeK7pKblUKx1o7+p+KT84C1n+yRqqMP1Rqkq7y09iW3Mj3GO0xgs9DR8yMalBgHhvWWvB9l4yDA==} engines: {node: '>=16.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.33.0 - '@typespec/compiler': ~0.47.0 - '@typespec/http': ~0.47.0 - '@typespec/openapi': ~0.47.0 - '@typespec/rest': ~0.47.0 - '@typespec/versioning': ~0.47.0 - dependencies: - '@azure-tools/typespec-azure-core': 0.33.1_rsgpzskpshtrui6ybsakstscc4 - '@typespec/compiler': 0.47.1 - '@typespec/http': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/openapi': 0.47.0_rsgpzskpshtrui6ybsakstscc4 - '@typespec/rest': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/versioning': 0.47.0_@typespec+compiler@0.47.1 + '@azure-tools/typespec-azure-core': ~0.34.0 + '@typespec/compiler': ~0.48.0 + '@typespec/http': ~0.48.0 + '@typespec/openapi': ~0.48.0 + '@typespec/rest': ~0.48.0 + '@typespec/versioning': ~0.48.0 + dependencies: + '@azure-tools/typespec-azure-core': 0.34.0_hp7rvmmczsxuulqidytkvjza5i + '@typespec/compiler': 0.48.0 + '@typespec/http': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/openapi': 0.48.0_hp7rvmmczsxuulqidytkvjza5i + '@typespec/rest': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/versioning': 0.48.0_@typespec+compiler@0.48.0 dev: false - /@azure-tools/typespec-azure-core/0.33.1_rsgpzskpshtrui6ybsakstscc4: - resolution: {integrity: sha512-g2MbyofjGo5GrPu/L0D3dXRcYXJOIA+abLWS6CRwwGN0RT0W+tnV8SFvGWRbBFsU0gWEZapfJKBwpVVwau6pVQ==} + /@azure-tools/typespec-azure-core/0.34.0_hp7rvmmczsxuulqidytkvjza5i: + resolution: {integrity: sha512-n3WrIx8bAHsknYXivbhl8WO+uzdB6RZMtx27/vnD+Jpo2krxLm0mMJK6pz2m/npTV4qlbY05OIeokhWQrneypw==} engines: {node: '>=16.0.0'} peerDependencies: - '@typespec/compiler': ~0.47.0 - '@typespec/http': ~0.47.0 - '@typespec/rest': ~0.47.0 + '@typespec/compiler': ~0.48.0 + '@typespec/http': ~0.48.0 + '@typespec/rest': ~0.48.0 dependencies: - '@typespec/compiler': 0.47.1 - '@typespec/http': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/lint': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/rest': 0.47.0_@typespec+compiler@0.47.1 + '@typespec/compiler': 0.48.0 + '@typespec/http': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/rest': 0.48.0_@typespec+compiler@0.48.0 - /@azure-tools/typespec-client-generator-core/0.33.0_ccoaydaumvpjzq7pj6wod3i6ou: - resolution: {integrity: sha512-Cm6hxL7oEUfK5pyPHM0gbtlLVPQSE3qJbSVQDiTqGJaU/660GSLEjp9i+NfZ1nl+cDUBCaCKaFqongin+sbKuw==} + /@azure-tools/typespec-client-generator-core/0.35.0-dev.9_6erv5apx7dld7z65vulofmtudi: + resolution: {integrity: sha512-pwFVaKBixTzXd1c/6MBMWdhBgK1Q7sQPXc8wcLsxZQ8iThu02tMc/qCQIvX6l6i7fIwOMvwEIhnRjyErsTzaug==} engines: {node: '>=16.0.0'} peerDependencies: - '@typespec/compiler': ~0.47.0 - '@typespec/http': ~0.47.0 - '@typespec/rest': ~0.47.0 - '@typespec/versioning': ~0.47.0 - dependencies: - '@typespec/compiler': 0.47.1 - '@typespec/http': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/lint': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/rest': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/versioning': 0.47.0_@typespec+compiler@0.47.1 + '@typespec/compiler': ~0.48.1 || >=0.49.0-dev <0.49.0 + '@typespec/http': ~0.48.0 || >=0.49.0-dev <0.49.0 + '@typespec/rest': ~0.48.0 || >=0.49.0-dev <0.49.0 + '@typespec/versioning': ~0.48.0 || >=0.49.0-dev <0.49.0 + dependencies: + '@typespec/compiler': 0.48.0 + '@typespec/http': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/lint': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/rest': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/versioning': 0.48.0_@typespec+compiler@0.48.0 dev: false /@azure/abort-controller/1.1.0: @@ -1342,6 +1356,26 @@ packages: vscode-languageserver: 8.1.0 vscode-languageserver-textdocument: 1.0.8 yargs: 17.7.2 + dev: true + + /@typespec/compiler/0.48.0: + resolution: {integrity: sha512-+BEeSLl7unxtRpC1L8sbTu5A94WIVQaYSFf0egkJ0panN0wWzcFbk4SJiSa9wxjDTr9fh2elSrRVk2t1XTk2nQ==} + engines: {node: '>=16.0.0'} + hasBin: true + dependencies: + '@babel/code-frame': 7.22.10 + ajv: 8.12.0 + change-case: 4.1.2 + globby: 13.1.4 + mustache: 4.2.0 + picocolors: 1.0.0 + prettier: 3.0.1 + prompts: 2.4.2 + semver: 7.5.4 + vscode-languageserver: 8.1.0 + vscode-languageserver-textdocument: 1.0.8 + yaml: 2.3.2 + yargs: 17.7.2 /@typespec/http/0.47.0_@typespec+compiler@0.47.1: resolution: {integrity: sha512-HrVu5mGV+p3KGPtcNFHB5gXm9pU4rYRG3hJWZdLcN8fy+OuwbhmOgjOGN4AB7HLllnISmcFn6LtlqGnr0LpyfA==} @@ -1350,48 +1384,58 @@ packages: '@typespec/compiler': ~0.47.0 dependencies: '@typespec/compiler': 0.47.1 + dev: true - /@typespec/lint/0.47.0_@typespec+compiler@0.47.1: - resolution: {integrity: sha512-+CZ8OC8ABHU+HljjWvkVfLDZzyj2kc8VqEOHoXYdomt7PTo2GdVubyOXZMAYFiXWJr/k4YWHD2moPcvu+e2yTQ==} + /@typespec/http/0.48.0_@typespec+compiler@0.48.0: + resolution: {integrity: sha512-e+0Y0Ky71flUNZSRzCfoOm8XvXsSYGmQgB9VZFDbLl8mQlXwuTfib4tWrU531TCtZHMnylbXx2wAk5+3uC6b9g==} engines: {node: '>=16.0.0'} peerDependencies: - '@typespec/compiler': ~0.47.0 + '@typespec/compiler': ~0.48.0 dependencies: - '@typespec/compiler': 0.47.1 + '@typespec/compiler': 0.48.0 - /@typespec/openapi/0.47.0_rsgpzskpshtrui6ybsakstscc4: - resolution: {integrity: sha512-p10NA5MQ1/z/yltTmK9g/RHgRQa+UPJg7ntcix8I9DIwX6u3yJReYwWBrKLeRNExd8ylNHNqjXTwiHJfptmR3w==} + /@typespec/lint/0.48.0_@typespec+compiler@0.48.0: + resolution: {integrity: sha512-hu08yLr8ORbdljqU+qf25+EqVQBDonpFiAWU9qaJ/2yTnKfdkXRbGSRuBYC17oMvJesLzyxVRwarpWPdBIMycw==} engines: {node: '>=16.0.0'} peerDependencies: - '@typespec/compiler': ~0.47.0 - '@typespec/http': ~0.47.0 - '@typespec/rest': ~0.47.0 + '@typespec/compiler': ~0.48.0 dependencies: - '@typespec/compiler': 0.47.1 - '@typespec/http': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/rest': 0.47.0_@typespec+compiler@0.47.1 + '@typespec/compiler': 0.48.0 dev: false - /@typespec/openapi3/0.47.0_6zgfza5j6pxgqvpitlqhaqcuje: - resolution: {integrity: sha512-N6TxfCKe1PmCyjFRnCH2+yHUyopEHzv8wjF71o7YLh9yWj4Qin51LmBa+Xr3OaRwyF6AJQedDDwB27uaRzIN7A==} + /@typespec/openapi/0.48.0_hp7rvmmczsxuulqidytkvjza5i: + resolution: {integrity: sha512-KptMNQd/+olEetmNGend6jhMjnFa+Lrhw/M+HCP46HcKH/NDVA/RWtX/KcT4KjxJYrmTlRF9sz19/Efg7u02CA==} engines: {node: '>=16.0.0'} peerDependencies: - '@typespec/compiler': ~0.47.0 - '@typespec/http': ~0.47.0 - '@typespec/openapi': ~0.47.0 - '@typespec/rest': ~0.47.0 - '@typespec/versioning': ~0.47.0 + '@typespec/compiler': ~0.48.0 + '@typespec/http': ~0.48.0 + '@typespec/rest': ~0.48.0 dependencies: - '@typespec/compiler': 0.47.1 - '@typespec/http': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/openapi': 0.47.0_rsgpzskpshtrui6ybsakstscc4 - '@typespec/rest': 0.47.0_@typespec+compiler@0.47.1 - '@typespec/versioning': 0.47.0_@typespec+compiler@0.47.1 - js-yaml: 4.1.0 + '@typespec/compiler': 0.48.0 + '@typespec/http': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/rest': 0.48.0_@typespec+compiler@0.48.0 + dev: false + + /@typespec/openapi3/0.48.0_ftmjutoeiczodakwe67k3csnhq: + resolution: {integrity: sha512-2ZiAvN4/LLS8Lt+tju3wKSNeDD8eTXNCaTxHw61jGVvPiCtU7E/HyF+eA2pMlfXAtjlEzpbuQb+rF3eaex1qUA==} + engines: {node: '>=16.0.0'} + peerDependencies: + '@typespec/compiler': ~0.48.0 + '@typespec/http': ~0.48.0 + '@typespec/openapi': ~0.48.0 + '@typespec/rest': ~0.48.0 + '@typespec/versioning': ~0.48.0 + dependencies: + '@typespec/compiler': 0.48.0 + '@typespec/http': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/openapi': 0.48.0_hp7rvmmczsxuulqidytkvjza5i + '@typespec/rest': 0.48.0_@typespec+compiler@0.48.0 + '@typespec/versioning': 0.48.0_@typespec+compiler@0.48.0 + yaml: 2.3.2 dev: false - /@typespec/prettier-plugin-typespec/0.47.0: - resolution: {integrity: sha512-7QHrCp9gK2cW09drxCqQ1xb6YqBGLJeZJ0gFRtV3jt1zbt5+YB5VGFwSZw97//+ULfUDGM0zlykSaqo82XdXQw==} + /@typespec/prettier-plugin-typespec/0.48.0: + resolution: {integrity: sha512-GktQSZ0Rc3d7xQ/QnzqwFX9V0l91kCU12T18wQxYzn3kDIqhTT8aL2GFP8a74X2DcbOj+ksrb9EcTZukLPc3Tg==} dependencies: prettier: 3.0.1 dev: false @@ -1403,14 +1447,23 @@ packages: '@typespec/compiler': ~0.47.0 dependencies: '@typespec/compiler': 0.47.1 + dev: true - /@typespec/versioning/0.47.0_@typespec+compiler@0.47.1: - resolution: {integrity: sha512-j3NUBm61k40ZI5aljgqfVFvduoR+q7ijLpwt+lzXw/DecOgNWZX7R/GGzwCmUVyfJUZpMA/8zhuxmx4fB36P7g==} + /@typespec/rest/0.48.0_@typespec+compiler@0.48.0: + resolution: {integrity: sha512-PM41o2a7qsTi6OIiCE53OB5uh+GTas8YObJjV5Z9JHYtHhQKVQaRHE72qoZQp3919vJNStXTdDEbIjzMIVt3Ow==} engines: {node: '>=16.0.0'} peerDependencies: - '@typespec/compiler': ~0.47.0 + '@typespec/compiler': ~0.48.0 dependencies: - '@typespec/compiler': 0.47.1 + '@typespec/compiler': 0.48.0 + + /@typespec/versioning/0.48.0_@typespec+compiler@0.48.0: + resolution: {integrity: sha512-WF26vmMPwizhSnjX0ox23nbp7hthtB4cN/J5w1tlryXyp/BXySHoYsJEMK7fviSpj4WdreVXdM6wmRIG33zqig==} + engines: {node: '>=16.0.0'} + peerDependencies: + '@typespec/compiler': ~0.48.0 + dependencies: + '@typespec/compiler': 0.48.0 /@ungap/promise-all-settled/1.1.2: resolution: {integrity: sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==} @@ -3680,6 +3733,7 @@ packages: hasBin: true dependencies: argparse: 2.0.1 + dev: true /jsbn/0.1.1: resolution: {integrity: sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==} @@ -6011,6 +6065,10 @@ packages: /yallist/4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + /yaml/2.3.2: + resolution: {integrity: sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==} + engines: {node: '>= 14'} + /yargs-parser/20.2.4: resolution: {integrity: sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==} engines: {node: '>=10'} diff --git a/packages/typespec-test/package.json b/packages/typespec-test/package.json index 7626c65e66..de8941dc8d 100644 --- a/packages/typespec-test/package.json +++ b/packages/typespec-test/package.json @@ -3,17 +3,17 @@ "version": "1.0.0", "type": "module", "dependencies": { - "@typespec/compiler": ">=0.47.0 <1.0.0", + "@typespec/compiler": ">=0.48.0 <1.0.0", "@azure-tools/typespec-ts": "workspace:^0.16.0", - "@typespec/http": ">=0.47.0 <1.0.0", - "@typespec/rest": ">=0.47.0 <1.0.0", - "@typespec/openapi": ">=0.47.0 <1.0.0", - "@typespec/versioning": ">=0.47.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.33.0 <1.0.0", - "@azure-tools/typespec-autorest": ">=0.33.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.33.0 <1.0.0", - "@typespec/openapi3": ">=0.47.0 <1.0.0", - "@typespec/prettier-plugin-typespec": ">=0.47.0 <1.0.0", + "@typespec/http": ">=0.48.0 <1.0.0", + "@typespec/rest": ">=0.48.0 <1.0.0", + "@typespec/openapi": ">=0.48.0 <1.0.0", + "@typespec/versioning": ">=0.48.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.34.0 <1.0.0", + "@azure-tools/typespec-autorest": ">=0.34.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": "0.35.0-dev.9", + "@typespec/openapi3": ">=0.48.0 <1.0.0", + "@typespec/prettier-plugin-typespec": ">=0.48.0 <1.0.0", "prettier": "2.7.1" }, "devDependencies": { diff --git a/packages/typespec-test/test/anomalyDetector/generated/openapi/v1.1/openapi.json b/packages/typespec-test/test/anomalyDetector/generated/openapi/v1.1/openapi.json index cd034c3dea..694868df7a 100644 --- a/packages/typespec-test/test/anomalyDetector/generated/openapi/v1.1/openapi.json +++ b/packages/typespec-test/test/anomalyDetector/generated/openapi/v1.1/openapi.json @@ -20,15 +20,15 @@ { "name": "Endpoint", "in": "path", - "required": true, "description": "Supported Cognitive Services endpoints (protocol and hostname, for example:\nhttps://westus2.api.cognitive.microsoft.com).", + "required": true, "type": "string" }, { "name": "ApiVersion", "in": "path", - "required": true, "description": "Api Version", + "required": true, "type": "string", "enum": [ "v1.1" @@ -95,8 +95,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } @@ -141,8 +141,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } @@ -186,8 +186,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } @@ -222,8 +222,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } @@ -253,8 +253,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } @@ -308,8 +308,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } @@ -353,8 +353,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } @@ -391,8 +391,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } @@ -429,8 +429,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } @@ -467,8 +467,8 @@ }, "headers": { "x-ms-error-code": { - "description": "Error code.", - "type": "string" + "type": "string", + "description": "Error code." } } } diff --git a/packages/typespec-test/test/authoring/generated/openapi/openapi.json b/packages/typespec-test/test/authoring/generated/openapi/openapi.json index aa570260ff..ab49458b7f 100644 --- a/packages/typespec-test/test/authoring/generated/openapi/openapi.json +++ b/packages/typespec-test/test/authoring/generated/openapi/openapi.json @@ -19,8 +19,8 @@ { "name": "Endpoint", "in": "path", - "required": true, "description": "The endpoint to use.", + "required": true, "type": "string" } ] @@ -68,8 +68,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -109,8 +109,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -139,7 +139,7 @@ "description": "The resource instance.", "required": true, "schema": { - "$ref": "#/definitions/ProjectUpdate" + "$ref": "#/definitions/ProjectCreateOrUpdate" } } ], @@ -177,8 +177,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -240,8 +240,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -286,8 +286,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -329,8 +329,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -381,8 +381,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -420,8 +420,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -468,8 +468,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -540,8 +540,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -610,8 +610,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -663,8 +663,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -715,8 +715,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -760,8 +760,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -801,8 +801,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -844,8 +844,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1033,8 +1033,7 @@ }, "ExportedProject": { "type": "object", - "description": "The details of an exported project.", - "properties": {} + "description": "The details of an exported project." }, "Job": { "type": "object", @@ -1281,6 +1280,36 @@ "lastDeployedDateTime" ] }, + "ProjectCreateOrUpdate": { + "type": "object", + "description": "The details of a project.", + "properties": { + "projectKind": { + "$ref": "#/definitions/ProjectKind", + "description": "The project kind." + }, + "storageInputContainerName": { + "type": "string", + "description": "The storage container name." + }, + "settings": { + "$ref": "#/definitions/ProjectSettings", + "description": "The project settings." + }, + "multilingual": { + "type": "boolean", + "description": "Whether the project would be used for multiple languages or not." + }, + "description": { + "type": "string", + "description": "The project description." + }, + "language": { + "type": "string", + "description": "The project language. This is BCP-47 representation of a language. For example, use \"en\" for English, \"en-gb\" for English (UK), \"es\" for Spanish etc." + } + } + }, "ProjectKind": { "type": "string", "description": "Represents the project kind.", @@ -1318,36 +1347,6 @@ "type": "string" } }, - "ProjectUpdate": { - "type": "object", - "description": "The details of a project.", - "properties": { - "projectKind": { - "$ref": "#/definitions/ProjectKind", - "description": "The project kind." - }, - "storageInputContainerName": { - "type": "string", - "description": "The storage container name." - }, - "settings": { - "$ref": "#/definitions/ProjectSettings", - "description": "The project settings." - }, - "multilingual": { - "type": "boolean", - "description": "Whether the project would be used for multiple languages or not." - }, - "description": { - "type": "string", - "description": "The project description." - }, - "language": { - "type": "string", - "description": "The project language. This is BCP-47 representation of a language. For example, use \"en\" for English, \"en-gb\" for English (UK), \"es\" for Spanish etc." - } - } - }, "SupportedLanguage": { "type": "object", "description": "Represents a supported language.", diff --git a/packages/typespec-test/test/confidentialLedger/generated/openapi/openapi.json b/packages/typespec-test/test/confidentialLedger/generated/openapi/openapi.json index 05f0e11bd9..27beacd9db 100644 --- a/packages/typespec-test/test/confidentialLedger/generated/openapi/openapi.json +++ b/packages/typespec-test/test/confidentialLedger/generated/openapi/openapi.json @@ -80,8 +80,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -109,8 +109,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -138,8 +138,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -167,8 +167,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -199,8 +199,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -241,8 +241,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -280,8 +280,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -319,8 +319,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -354,8 +354,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -399,8 +399,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -439,8 +439,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -471,7 +471,7 @@ "description": "The resource instance.", "required": true, "schema": { - "$ref": "#/definitions/LedgerUserUpdate" + "$ref": "#/definitions/LedgerUserCreateOrUpdate" } } ], @@ -495,8 +495,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -530,8 +530,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -672,6 +672,16 @@ "assignedRole" ] }, + "LedgerUserCreateOrUpdate": { + "type": "object", + "description": "Details about a Confidential ledger user.", + "properties": { + "assignedRole": { + "$ref": "#/definitions/LedgerUserRole", + "description": "The user's assigned role." + } + } + }, "LedgerUserRole": { "type": "string", "description": "Represents an assignable role.", @@ -685,16 +695,6 @@ "modelAsString": false } }, - "LedgerUserUpdate": { - "type": "object", - "description": "Details about a Confidential ledger user.", - "properties": { - "assignedRole": { - "$ref": "#/definitions/LedgerUserRole", - "description": "The user's assigned role." - } - } - }, "MyFlow": { "type": "object", "description": "Define the auth flow", @@ -768,8 +768,7 @@ }, "ReceiptContents": { "type": "object", - "description": "The contents of a receipt.", - "properties": {} + "description": "The contents of a receipt." }, "TransactionId": { "type": "string", diff --git a/packages/typespec-test/test/contoso/generated/openapi/2022-11-01-preview/openapi.json b/packages/typespec-test/test/contoso/generated/openapi/2022-11-01-preview/openapi.json index ca7cb18e6e..fd7bed4766 100644 --- a/packages/typespec-test/test/contoso/generated/openapi/2022-11-01-preview/openapi.json +++ b/packages/typespec-test/test/contoso/generated/openapi/2022-11-01-preview/openapi.json @@ -43,8 +43,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -84,8 +84,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -114,7 +114,7 @@ "description": "The resource instance.", "required": true, "schema": { - "$ref": "#/definitions/WidgetUpdate" + "$ref": "#/definitions/WidgetCreateOrUpdate" } } ], @@ -152,8 +152,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -215,8 +215,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -284,8 +284,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -410,7 +410,7 @@ "createdDate" ] }, - "FakedSharedModelUpdate": { + "FakedSharedModelCreateOrUpdate": { "type": "object", "description": "Faked shared model", "properties": { @@ -486,7 +486,7 @@ "manufacturerId" ] }, - "WidgetUpdate": { + "WidgetCreateOrUpdate": { "type": "object", "description": "A widget.", "properties": { @@ -495,7 +495,7 @@ "description": "The ID of the widget's manufacturer." }, "sharedModel": { - "$ref": "#/definitions/FakedSharedModelUpdate", + "$ref": "#/definitions/FakedSharedModelCreateOrUpdate", "description": "The faked shared model." } } diff --git a/packages/typespec-test/test/contoso/generated/typespec-ts/review/contosowidgetmanager-rest.api.md b/packages/typespec-test/test/contoso/generated/typespec-ts/review/contosowidgetmanager-rest.api.md index 69e76cff07..167ae0f588 100644 --- a/packages/typespec-test/test/contoso/generated/typespec-ts/review/contosowidgetmanager-rest.api.md +++ b/packages/typespec-test/test/contoso/generated/typespec-ts/review/contosowidgetmanager-rest.api.md @@ -151,9 +151,6 @@ export function getLongRunningPoller(client: Client, initialResponse: DeleteWidget202Response | DeleteWidgetDefaultResponse, options?: CreateHttpPollerOptions>): Promise, TResult>>; -// @public (undocumented) -export function getLongRunningPoller(client: Client, initialResponse: GetWidgetOperationStatus200Response | GetWidgetOperationStatusDefaultResponse, options?: CreateHttpPollerOptions>): Promise, TResult>>; - // @public export type GetPage = (pageLink: string, maxPageSize?: number) => Promise<{ page: TPage; @@ -218,14 +215,6 @@ export interface GetWidgetOperationStatusDefaultResponse extends HttpResponse { status: string; } -// @public -export interface GetWidgetOperationStatusLogicalResponse extends HttpResponse { - // (undocumented) - body: ResourceOperationStatusOutput; - // (undocumented) - status: "200"; -} - // @public (undocumented) export type GetWidgetOperationStatusParameters = RequestParameters; @@ -242,7 +231,7 @@ export function isUnexpected(response: CreateOrUpdateWidget200Response | CreateO export function isUnexpected(response: DeleteWidget202Response | DeleteWidgetLogicalResponse | DeleteWidgetDefaultResponse): response is DeleteWidgetDefaultResponse; // @public (undocumented) -export function isUnexpected(response: GetWidgetOperationStatus200Response | GetWidgetOperationStatusLogicalResponse | GetWidgetOperationStatusDefaultResponse): response is GetWidgetOperationStatusDefaultResponse; +export function isUnexpected(response: GetWidgetOperationStatus200Response | GetWidgetOperationStatusDefaultResponse): response is GetWidgetOperationStatusDefaultResponse; // @public (undocumented) export function isUnexpected(response: ListWidgets200Response | ListWidgetsDefaultResponse): response is ListWidgetsDefaultResponse; diff --git a/packages/typespec-test/test/contoso/generated/typespec-ts/src/isUnexpected.ts b/packages/typespec-test/test/contoso/generated/typespec-ts/src/isUnexpected.ts index 589e0da528..b0f68a77f5 100644 --- a/packages/typespec-test/test/contoso/generated/typespec-ts/src/isUnexpected.ts +++ b/packages/typespec-test/test/contoso/generated/typespec-ts/src/isUnexpected.ts @@ -12,7 +12,6 @@ import { DeleteWidgetLogicalResponse, DeleteWidgetDefaultResponse, GetWidgetOperationStatus200Response, - GetWidgetOperationStatusLogicalResponse, GetWidgetOperationStatusDefaultResponse, ListWidgets200Response, ListWidgetsDefaultResponse, @@ -45,7 +44,6 @@ export function isUnexpected( export function isUnexpected( response: | GetWidgetOperationStatus200Response - | GetWidgetOperationStatusLogicalResponse | GetWidgetOperationStatusDefaultResponse ): response is GetWidgetOperationStatusDefaultResponse; export function isUnexpected( @@ -63,7 +61,6 @@ export function isUnexpected( | DeleteWidgetLogicalResponse | DeleteWidgetDefaultResponse | GetWidgetOperationStatus200Response - | GetWidgetOperationStatusLogicalResponse | GetWidgetOperationStatusDefaultResponse | ListWidgets200Response | ListWidgetsDefaultResponse diff --git a/packages/typespec-test/test/contoso/generated/typespec-ts/src/pollingHelper.ts b/packages/typespec-test/test/contoso/generated/typespec-ts/src/pollingHelper.ts index 62095e4d3b..6b327461a5 100644 --- a/packages/typespec-test/test/contoso/generated/typespec-ts/src/pollingHelper.ts +++ b/packages/typespec-test/test/contoso/generated/typespec-ts/src/pollingHelper.ts @@ -18,9 +18,6 @@ import { DeleteWidget202Response, DeleteWidgetDefaultResponse, DeleteWidgetLogicalResponse, - GetWidgetOperationStatus200Response, - GetWidgetOperationStatusDefaultResponse, - GetWidgetOperationStatusLogicalResponse, } from "./responses"; /** * Helper function that builds a Poller object to help polling a long running operation. @@ -48,17 +45,6 @@ export async function getLongRunningPoller< initialResponse: DeleteWidget202Response | DeleteWidgetDefaultResponse, options?: CreateHttpPollerOptions> ): Promise, TResult>>; -export async function getLongRunningPoller< - TResult extends - | GetWidgetOperationStatusLogicalResponse - | GetWidgetOperationStatusDefaultResponse ->( - client: Client, - initialResponse: - | GetWidgetOperationStatus200Response - | GetWidgetOperationStatusDefaultResponse, - options?: CreateHttpPollerOptions> -): Promise, TResult>>; export async function getLongRunningPoller( client: Client, initialResponse: TResult, diff --git a/packages/typespec-test/test/contoso/generated/typespec-ts/src/responses.ts b/packages/typespec-test/test/contoso/generated/typespec-ts/src/responses.ts index 6c7af0a838..10a5354590 100644 --- a/packages/typespec-test/test/contoso/generated/typespec-ts/src/responses.ts +++ b/packages/typespec-test/test/contoso/generated/typespec-ts/src/responses.ts @@ -44,12 +44,6 @@ export interface GetWidgetOperationStatusDefaultResponse extends HttpResponse { headers: RawHttpHeaders & GetWidgetOperationStatusDefaultHeaders; } -/** The final response for long-running getWidgetOperationStatus operation */ -export interface GetWidgetOperationStatusLogicalResponse extends HttpResponse { - status: "200"; - body: ResourceOperationStatusOutput; -} - export interface CreateOrUpdateWidget200Headers { /** The location for monitoring the operation state. */ "operation-location": string; diff --git a/packages/typespec-test/test/loadTest/generated/openapi/2022-11-01/openapi.json b/packages/typespec-test/test/loadTest/generated/openapi/2022-11-01/openapi.json index 111f62b6f1..4cc06307b6 100644 --- a/packages/typespec-test/test/loadTest/generated/openapi/2022-11-01/openapi.json +++ b/packages/typespec-test/test/loadTest/generated/openapi/2022-11-01/openapi.json @@ -127,8 +127,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -169,8 +169,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -207,7 +207,7 @@ "description": "The resource instance.", "required": true, "schema": { - "$ref": "#/definitions/TestRunUpdate" + "$ref": "#/definitions/TestRunCreateOrUpdate" } } ], @@ -245,8 +245,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -280,8 +280,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -319,8 +319,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -358,8 +358,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -413,8 +413,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -459,8 +459,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -505,8 +505,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -563,8 +563,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -605,8 +605,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -726,8 +726,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -768,8 +768,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -823,8 +823,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -893,8 +893,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -935,8 +935,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -990,8 +990,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1024,8 +1024,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1063,8 +1063,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1118,8 +1118,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1157,8 +1157,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1206,8 +1206,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1296,8 +1296,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1337,8 +1337,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1376,8 +1376,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1431,8 +1431,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -1644,8 +1644,7 @@ } }, "Dimension": { - "type": "object", - "properties": {} + "type": "object" }, "DimensionFilter": { "type": "object", @@ -3097,6 +3096,50 @@ } } }, + "TestRunCreateOrUpdate": { + "type": "object", + "description": "Load test run model", + "properties": { + "passFailCriteria": { + "$ref": "#/definitions/PassFailCriteria", + "description": "Pass fail criteria for a test." + }, + "secrets": { + "type": "object", + "description": "Secrets can be stored in an Azure Key Vault or any other secret store. If the\nsecret is stored in an Azure Key Vault, the value should be the secret\nidentifier and the type should be AKV_SECRET_URI. If the secret is stored\nelsewhere, the secret value should be provided directly and the type should be\nSECRET_VALUE.", + "additionalProperties": { + "$ref": "#/definitions/Secret" + } + }, + "certificate": { + "$ref": "#/definitions/CertificateMetadata", + "description": "Certificates metadata" + }, + "environmentVariables": { + "type": "object", + "description": "Environment variables which are defined as a set of pairs.", + "additionalProperties": { + "type": "string" + } + }, + "loadTestConfiguration": { + "$ref": "#/definitions/LoadTestConfiguration", + "description": "The load test configuration." + }, + "displayName": { + "type": "string", + "description": "Display name of a testRun." + }, + "testId": { + "type": "string", + "description": "Associated test Id." + }, + "description": { + "type": "string", + "description": "The test run description." + } + } + }, "TestRunInputArtifacts": { "type": "object", "description": "The input artifacts for the test run.", @@ -3271,50 +3314,6 @@ } } }, - "TestRunUpdate": { - "type": "object", - "description": "Load test run model", - "properties": { - "passFailCriteria": { - "$ref": "#/definitions/PassFailCriteria", - "description": "Pass fail criteria for a test." - }, - "secrets": { - "type": "object", - "description": "Secrets can be stored in an Azure Key Vault or any other secret store. If the\nsecret is stored in an Azure Key Vault, the value should be the secret\nidentifier and the type should be AKV_SECRET_URI. If the secret is stored\nelsewhere, the secret value should be provided directly and the type should be\nSECRET_VALUE.", - "additionalProperties": { - "$ref": "#/definitions/Secret" - } - }, - "certificate": { - "$ref": "#/definitions/CertificateMetadata", - "description": "Certificates metadata" - }, - "environmentVariables": { - "type": "object", - "description": "Environment variables which are defined as a set of pairs.", - "additionalProperties": { - "type": "string" - } - }, - "loadTestConfiguration": { - "$ref": "#/definitions/LoadTestConfiguration", - "description": "The load test configuration." - }, - "displayName": { - "type": "string", - "description": "Display name of a testRun." - }, - "testId": { - "type": "string", - "description": "Associated test Id." - }, - "description": { - "type": "string", - "description": "The test run description." - } - } - }, "TestRuns": { "type": "object", "description": "Load test run model", diff --git a/packages/typespec-test/test/loadTest/spec/routes.tsp b/packages/typespec-test/test/loadTest/spec/routes.tsp index ef5a2a70fb..8dd90a8803 100644 --- a/packages/typespec-test/test/loadTest/spec/routes.tsp +++ b/packages/typespec-test/test/loadTest/spec/routes.tsp @@ -298,7 +298,7 @@ numeric, underscore or hyphen characters. @summary("Create and start a new test run with the given name.") @doc("Create and start a new test run with the given name.") - @pollingOperation(LoadTestRun.GetTestRun) + // @pollingOperation(LoadTestRun.GetTestRun) CreateOrUpdateTestRun is LongRunningResourceCreateOrUpdate< TestRun, QueryParametersTrait< diff --git a/packages/typespec-test/test/loadtesting_modular/spec/routes.tsp b/packages/typespec-test/test/loadtesting_modular/spec/routes.tsp index ef5a2a70fb..8dd90a8803 100644 --- a/packages/typespec-test/test/loadtesting_modular/spec/routes.tsp +++ b/packages/typespec-test/test/loadtesting_modular/spec/routes.tsp @@ -298,7 +298,7 @@ numeric, underscore or hyphen characters. @summary("Create and start a new test run with the given name.") @doc("Create and start a new test run with the given name.") - @pollingOperation(LoadTestRun.GetTestRun) + // @pollingOperation(LoadTestRun.GetTestRun) CreateOrUpdateTestRun is LongRunningResourceCreateOrUpdate< TestRun, QueryParametersTrait< diff --git a/packages/typespec-test/test/openai/generated/openapi/2022-12-01/openapi.json b/packages/typespec-test/test/openai/generated/openapi/2022-12-01/openapi.json index 6db33867be..b2694d940d 100644 --- a/packages/typespec-test/test/openai/generated/openapi/2022-12-01/openapi.json +++ b/packages/typespec-test/test/openai/generated/openapi/2022-12-01/openapi.json @@ -20,8 +20,8 @@ { "name": "endpoint", "in": "path", - "required": true, "description": "Supported Cognitive Services endpoints (protocol and hostname, for example:\nhttps://westus.api.cognitive.microsoft.com).", + "required": true, "type": "string" } ] @@ -103,8 +103,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } @@ -150,8 +150,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } diff --git a/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/api/operations.ts b/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/api/operations.ts index 661e7bc19d..81ff5be853 100644 --- a/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/api/operations.ts +++ b/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/api/operations.ts @@ -14,7 +14,6 @@ import { BeginAzureBatchImageGenerationLogicalResponse, GetAzureBatchImageGenerationOperationStatus200Response, GetAzureBatchImageGenerationOperationStatusDefaultResponse, - GetAzureBatchImageGenerationOperationStatusLogicalResponse, GetChatCompletions200Response, GetChatCompletionsDefaultResponse, GetChatCompletionsWithAzureExtensions200Response, @@ -600,7 +599,6 @@ export function _getAzureBatchImageGenerationOperationStatusSend( ): StreamableMethod< | GetAzureBatchImageGenerationOperationStatus200Response | GetAzureBatchImageGenerationOperationStatusDefaultResponse - | GetAzureBatchImageGenerationOperationStatusLogicalResponse > { return context .path("/operations/images/{operationId}", operationId) @@ -611,7 +609,6 @@ export async function _getAzureBatchImageGenerationOperationStatusDeserialize( result: | GetAzureBatchImageGenerationOperationStatus200Response | GetAzureBatchImageGenerationOperationStatusDefaultResponse - | GetAzureBatchImageGenerationOperationStatusLogicalResponse ): Promise { if (isUnexpected(result)) { throw result.body; diff --git a/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/isUnexpected.ts b/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/isUnexpected.ts index 5dab3fe0ef..a223638aa8 100644 --- a/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/isUnexpected.ts +++ b/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/isUnexpected.ts @@ -11,7 +11,6 @@ import { GetChatCompletionsWithAzureExtensions200Response, GetChatCompletionsWithAzureExtensionsDefaultResponse, GetAzureBatchImageGenerationOperationStatus200Response, - GetAzureBatchImageGenerationOperationStatusLogicalResponse, GetAzureBatchImageGenerationOperationStatusDefaultResponse, BeginAzureBatchImageGeneration202Response, BeginAzureBatchImageGenerationLogicalResponse, @@ -45,7 +44,6 @@ export function isUnexpected( export function isUnexpected( response: | GetAzureBatchImageGenerationOperationStatus200Response - | GetAzureBatchImageGenerationOperationStatusLogicalResponse | GetAzureBatchImageGenerationOperationStatusDefaultResponse ): response is GetAzureBatchImageGenerationOperationStatusDefaultResponse; export function isUnexpected( @@ -65,7 +63,6 @@ export function isUnexpected( | GetChatCompletionsWithAzureExtensions200Response | GetChatCompletionsWithAzureExtensionsDefaultResponse | GetAzureBatchImageGenerationOperationStatus200Response - | GetAzureBatchImageGenerationOperationStatusLogicalResponse | GetAzureBatchImageGenerationOperationStatusDefaultResponse | BeginAzureBatchImageGeneration202Response | BeginAzureBatchImageGenerationLogicalResponse diff --git a/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/pollingHelper.ts b/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/pollingHelper.ts index 47d8fdcea6..2a79964f9c 100644 --- a/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/pollingHelper.ts +++ b/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/pollingHelper.ts @@ -11,9 +11,6 @@ import { createHttpPoller, } from "@azure/core-lro"; import { - GetAzureBatchImageGenerationOperationStatus200Response, - GetAzureBatchImageGenerationOperationStatusDefaultResponse, - GetAzureBatchImageGenerationOperationStatusLogicalResponse, BeginAzureBatchImageGeneration202Response, BeginAzureBatchImageGenerationDefaultResponse, BeginAzureBatchImageGenerationLogicalResponse, @@ -36,17 +33,6 @@ export async function getLongRunningPoller< | BeginAzureBatchImageGenerationDefaultResponse, options?: CreateHttpPollerOptions> ): Promise, TResult>>; -export async function getLongRunningPoller< - TResult extends - | GetAzureBatchImageGenerationOperationStatusLogicalResponse - | GetAzureBatchImageGenerationOperationStatusDefaultResponse ->( - client: Client, - initialResponse: - | GetAzureBatchImageGenerationOperationStatus200Response - | GetAzureBatchImageGenerationOperationStatusDefaultResponse, - options?: CreateHttpPollerOptions> -): Promise, TResult>>; export async function getLongRunningPoller( client: Client, initialResponse: TResult, diff --git a/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/responses.ts b/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/responses.ts index 5f5fcb9ad1..efe68d78c4 100644 --- a/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/responses.ts +++ b/packages/typespec-test/test/openai_modular/generated/typespec-ts/src/rest/responses.ts @@ -100,13 +100,6 @@ export interface GetAzureBatchImageGenerationOperationStatusDefaultResponse GetAzureBatchImageGenerationOperationStatusDefaultHeaders; } -/** The final response for long-running getAzureBatchImageGenerationOperationStatus operation */ -export interface GetAzureBatchImageGenerationOperationStatusLogicalResponse - extends HttpResponse { - status: "200"; - body: BatchImageGenerationOperationResponseOutput; -} - export interface BeginAzureBatchImageGeneration202Headers { /** The location for monitoring the operation state. */ "operation-location": string; diff --git a/packages/typespec-test/test/parametrizedHost/generated/openapi/openapi.json b/packages/typespec-test/test/parametrizedHost/generated/openapi/openapi.json index 630142285a..432e839a74 100644 --- a/packages/typespec-test/test/parametrizedHost/generated/openapi/openapi.json +++ b/packages/typespec-test/test/parametrizedHost/generated/openapi/openapi.json @@ -20,29 +20,29 @@ "name": "host", "in": "path", "required": false, - "default": "one", - "type": "string" + "type": "string", + "default": "one" }, { "name": "subdomain", "in": "path", "required": false, - "default": "two", - "type": "string" + "type": "string", + "default": "two" }, { "name": "sufix", "in": "path", "required": false, - "default": "three", - "type": "string" + "type": "string", + "default": "three" }, { "name": "apiVersion", "in": "path", "required": false, - "default": "v1", - "type": "string" + "type": "string", + "default": "v1" } ] }, @@ -100,8 +100,8 @@ }, "headers": { "x-ms-error-code": { - "description": "String error code indicating what went wrong.", - "type": "string" + "type": "string", + "description": "String error code indicating what went wrong." } } } diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/review/widget_dpg.api.md b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/review/widget_dpg.api.md index 785c6af696..c63016acc8 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/review/widget_dpg.api.md +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/review/widget_dpg.api.md @@ -17,9 +17,6 @@ export interface AnalyzeResult { export interface AnalyzeWidgetOptions extends OperationOptions { } -// @public (undocumented) -export type ColorType = "red" | "blue"; - // @public (undocumented) export interface CreateWidgetOptions extends OperationOptions { } @@ -38,13 +35,13 @@ export interface ListWidgetsOptions extends OperationOptions { // @public (undocumented) export interface UpdateWidgetOptions extends OperationOptions { - color?: ColorType; + color?: "red" | "blue"; weight?: number; } // @public (undocumented) export interface Widget { - color: ColorType; + color: "red" | "blue"; id: string; weight: number; } @@ -53,7 +50,7 @@ export interface Widget { export class WidgetServiceClient { constructor(endpoint: string, options?: WidgetServiceClientOptions); analyzeWidget(id: string, options?: AnalyzeWidgetOptions): Promise; - createWidget(weight: number, color: ColorType, options?: CreateWidgetOptions): Promise; + createWidget(weight: number, color: "red" | "blue", options?: CreateWidgetOptions): Promise; deleteWidget(id: string, options?: DeleteWidgetOptions): Promise; getWidget(id: string, options?: GetWidgetOptions): Promise; listWidgets(options?: ListWidgetsOptions): Promise; diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/WidgetServiceClient.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/WidgetServiceClient.ts index d29671ddc4..42353a42ce 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/WidgetServiceClient.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/WidgetServiceClient.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { Widget, ColorType, AnalyzeResult } from "./models/models.js"; +import { Widget, AnalyzeResult } from "./models/models.js"; import { ListWidgetsOptions, GetWidgetOptions, @@ -58,7 +58,7 @@ export class WidgetServiceClient { */ createWidget( weight: number, - color: ColorType, + color: "red" | "blue", options: CreateWidgetOptions = { requestOptions: {} } ): Promise { return createWidget(this._client, weight, color, options); diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/api/operations.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/api/operations.ts index 2f4d6c7d41..34440bb8db 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/api/operations.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/api/operations.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { Widget, ColorType, AnalyzeResult } from "../models/models.js"; +import { Widget, AnalyzeResult } from "../models/models.js"; import { AnalyzeWidget200Response, AnalyzeWidgetDefaultResponse, @@ -104,7 +104,7 @@ export async function getWidget( export function _createWidgetSend( context: Client, weight: number, - color: ColorType, + color: "red" | "blue", options: CreateWidgetOptions = { requestOptions: {} } ): StreamableMethod { return context @@ -138,7 +138,7 @@ export async function _createWidgetDeserialize( export async function createWidget( context: Client, weight: number, - color: ColorType, + color: "red" | "blue", options: CreateWidgetOptions = { requestOptions: {} } ): Promise { const result = await _createWidgetSend(context, weight, color, options); diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/index.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/index.ts index fda6174d1e..2e594c1f68 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/index.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/index.ts @@ -7,7 +7,6 @@ export { } from "./WidgetServiceClient.js"; export { Widget, - ColorType, AnalyzeResult, ListWidgetsOptions, GetWidgetOptions, diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/index.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/index.ts index f72df41501..3f04419ec5 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/index.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/index.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -export { Widget, ColorType, AnalyzeResult } from "./models.js"; +export { Widget, AnalyzeResult } from "./models.js"; export { ListWidgetsOptions, GetWidgetOptions, diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/models.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/models.ts index 37a04d647e..5e924b62a6 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/models.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/models.ts @@ -7,13 +7,9 @@ export interface Widget { /** The weight of the widget. This is an int32, but must be greater than zero. */ weight: number; /** The color of the widget. */ - color: ColorType; + color: "red" | "blue"; } -/** Type of ColorType */ -/** */ -export type ColorType = "red" | "blue"; - export interface AnalyzeResult { summary: string; } diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/options.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/options.ts index 2ece90dfac..83038b0a3d 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/options.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/sources/generated/src/models/options.ts @@ -2,7 +2,6 @@ // Licensed under the MIT license. import { OperationOptions } from "@azure-rest/core-client"; -import { ColorType } from "./models.js"; export interface ListWidgetsOptions extends OperationOptions {} @@ -14,7 +13,7 @@ export interface UpdateWidgetOptions extends OperationOptions { /** The weight of the widget. This is an int32, but must be greater than zero. */ weight?: number; /** The color of the widget. */ - color?: ColorType; + color?: "red" | "blue"; } export interface DeleteWidgetOptions extends OperationOptions {} diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/WidgetServiceClient.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/WidgetServiceClient.ts index d29671ddc4..42353a42ce 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/WidgetServiceClient.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/WidgetServiceClient.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { Widget, ColorType, AnalyzeResult } from "./models/models.js"; +import { Widget, AnalyzeResult } from "./models/models.js"; import { ListWidgetsOptions, GetWidgetOptions, @@ -58,7 +58,7 @@ export class WidgetServiceClient { */ createWidget( weight: number, - color: ColorType, + color: "red" | "blue", options: CreateWidgetOptions = { requestOptions: {} } ): Promise { return createWidget(this._client, weight, color, options); diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/api/operations.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/api/operations.ts index 2f4d6c7d41..34440bb8db 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/api/operations.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/api/operations.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { Widget, ColorType, AnalyzeResult } from "../models/models.js"; +import { Widget, AnalyzeResult } from "../models/models.js"; import { AnalyzeWidget200Response, AnalyzeWidgetDefaultResponse, @@ -104,7 +104,7 @@ export async function getWidget( export function _createWidgetSend( context: Client, weight: number, - color: ColorType, + color: "red" | "blue", options: CreateWidgetOptions = { requestOptions: {} } ): StreamableMethod { return context @@ -138,7 +138,7 @@ export async function _createWidgetDeserialize( export async function createWidget( context: Client, weight: number, - color: ColorType, + color: "red" | "blue", options: CreateWidgetOptions = { requestOptions: {} } ): Promise { const result = await _createWidgetSend(context, weight, color, options); diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/index.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/index.ts index fda6174d1e..2e594c1f68 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/index.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/index.ts @@ -7,7 +7,6 @@ export { } from "./WidgetServiceClient.js"; export { Widget, - ColorType, AnalyzeResult, ListWidgetsOptions, GetWidgetOptions, diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/index.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/index.ts index f72df41501..3f04419ec5 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/index.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/index.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -export { Widget, ColorType, AnalyzeResult } from "./models.js"; +export { Widget, AnalyzeResult } from "./models.js"; export { ListWidgetsOptions, GetWidgetOptions, diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/models.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/models.ts index 37a04d647e..5e924b62a6 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/models.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/models.ts @@ -7,13 +7,9 @@ export interface Widget { /** The weight of the widget. This is an int32, but must be greater than zero. */ weight: number; /** The color of the widget. */ - color: ColorType; + color: "red" | "blue"; } -/** Type of ColorType */ -/** */ -export type ColorType = "red" | "blue"; - export interface AnalyzeResult { summary: string; } diff --git a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/options.ts b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/options.ts index 2ece90dfac..83038b0a3d 100644 --- a/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/options.ts +++ b/packages/typespec-test/test/widget_dpg/generated/typespec-ts/src/models/options.ts @@ -2,7 +2,6 @@ // Licensed under the MIT license. import { OperationOptions } from "@azure-rest/core-client"; -import { ColorType } from "./models.js"; export interface ListWidgetsOptions extends OperationOptions {} @@ -14,7 +13,7 @@ export interface UpdateWidgetOptions extends OperationOptions { /** The weight of the widget. This is an int32, but must be greater than zero. */ weight?: number; /** The color of the widget. */ - color?: ColorType; + color?: "red" | "blue"; } export interface DeleteWidgetOptions extends OperationOptions {} diff --git a/packages/typespec-ts/package.json b/packages/typespec-ts/package.json index a66f0c755d..59eeb0a4fd 100644 --- a/packages/typespec-ts/package.json +++ b/packages/typespec-ts/package.json @@ -66,12 +66,12 @@ "@azure/core-util": "^1.4.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": ">=0.33.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.33.0 <1.0.0", - "@typespec/compiler": ">=0.47.0 <1.0.0", - "@typespec/http": ">=0.47.0 <1.0.0", - "@typespec/rest": ">=0.47.0 <1.0.0", - "@typespec/versioning": ">=0.47.0 <1.0.0" + "@azure-tools/typespec-azure-core": ">=0.34.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": "0.35.0-dev.9", + "@typespec/compiler": ">=0.48.0 <1.0.0", + "@typespec/http": ">=0.48.0 <1.0.0", + "@typespec/rest": ">=0.48.0 <1.0.0", + "@typespec/versioning": ">=0.48.0 <1.0.0" }, "dependencies": { "prettier": "^2.6.1", diff --git a/packages/typespec-ts/src/modular/buildCodeModel.ts b/packages/typespec-ts/src/modular/buildCodeModel.ts index ef279ac4a3..e1951192a6 100644 --- a/packages/typespec-ts/src/modular/buildCodeModel.ts +++ b/packages/typespec-ts/src/modular/buildCodeModel.ts @@ -66,8 +66,9 @@ import { getClientNamespaceString, getSdkUnion, getAllModels, - SdkSimpleType, - getSdkSimpleType + SdkBuiltInType, + getSdkBuiltInType, + getClientType } from "@azure-tools/typespec-client-generator-core"; import { getResourceOperation } from "@typespec/rest"; import { @@ -94,7 +95,8 @@ import { import { getOperationGroupName, getOperationName, - isIgnoredHeaderParam + isIgnoredHeaderParam, + isLongRunningOperation } from "../utils/operationUtil.js"; import { SdkContext } from "../utils/interfaces.js"; import { Project } from "ts-morph"; @@ -171,15 +173,6 @@ function getDocStr(program: Program, target: Type): string { return getDoc(program, target) ?? ""; } -function isLro(_program: Program, operation: Operation): boolean { - for (const decorator of operation.decorators) { - if (decorator.decorator.name === "$pollingOperation") { - return true; - } - } - return false; -} - function isDiscriminator( context: SdkContext, type: Model, @@ -628,7 +621,10 @@ function emitOperation( operationGroupName: string, rlcModels: RLCModel ): HrlcOperation { - const lro = isLro(context.program, operation); + const lro = isLongRunningOperation( + context.program, + ignoreDiagnostics(getHttpOperation(context.program, operation)) + ); const paging = getPagedResult(context.program, operation); if (lro && paging) { return emitLroPagingOperation( @@ -1235,6 +1231,7 @@ function capitalize(name: string): string { function emitUnion(context: SdkContext, type: Union): Record { const sdkType = getSdkUnion(context, type); + const nonNullOptions = getNonNullOptions(type); if (sdkType === undefined) { throw Error("Should not have an empty union"); } @@ -1246,29 +1243,65 @@ function emitUnion(context: SdkContext, type: Union): Record { description: `Type of ${unionName}`, internal: true, type: "combined", - types: sdkType.values.map((x) => getType(context, x.__raw)), + types: sdkType.values.map((x) => getType(context, x.__raw!)), xmlMetadata: {} }; } else if (sdkType.kind === "enum") { return { name: sdkType.name, nullable: sdkType.nullable, - description: sdkType.doc || `Type of ${sdkType.name}`, + description: sdkType.description || `Type of ${sdkType.name}`, internal: true, type: sdkType.kind, - valueType: emitSimpleType(context, sdkType.valueType as SdkSimpleType), + valueType: emitSimpleType(context, sdkType.valueType as SdkBuiltInType), values: sdkType.values.map((x) => emitEnumMember(x)), - isFixed: sdkType.isFixed === false ? false : true, + isFixed: sdkType.isFixed, + xmlMetadata: {} + }; + } else if ( + isStringOrNumberKind(context.program, sdkType.kind) && + isStringOrNumberKind(context.program, nonNullOptions[0]?.kind) + ) { + return { + name: undefined, // string/number union will be mapped as fixed enum without name + nullable: sdkType.nullable, + internal: true, + type: "enum", + valueType: emitSimpleType(context, sdkType as SdkBuiltInType), + values: nonNullOptions + .map((x) => getClientType(context, x)) + .map((x) => emitEnumMember(x)), + isFixed: true, xmlMetadata: {} }; } else { - return { nullable: sdkType.nullable, ...emitType(context, sdkType.__raw) }; + return { nullable: sdkType.nullable, ...emitType(context, sdkType.__raw!) }; + } +} + +function isStringOrNumberKind(program: Program, kind?: string): boolean { + if (!kind) { + return false; + } + kind = kind.toLowerCase(); + try { + const type = emitStdScalar(program, { name: kind } as any); + kind = type["type"] ?? kind; + } catch (e: any) { + // ignore } + return ["string", "number", "integer", "float"].includes(kind!); +} + +function getNonNullOptions(type: Union) { + return [...type.variants.values()] + .map((x) => x.type) + .filter((t) => !isNullType(t)); } function emitEnumMember(type: any): Record { return { - name: enumName(type.name), + name: type.name ? enumName(type.name) : undefined, value: type.value, description: type.doc }; @@ -1276,37 +1309,22 @@ function emitEnumMember(type: any): Record { function emitSimpleType( context: SdkContext, - type: Scalar | IntrinsicType | SdkSimpleType + type: Scalar | IntrinsicType | SdkBuiltInType ): Record { - let sdkType: SdkSimpleType; + let sdkType: SdkBuiltInType; if (type.kind === "Scalar" || type.kind === "Intrinsic") { - sdkType = getSdkSimpleType(context, type); + sdkType = getSdkBuiltInType(context, type); } else { sdkType = type; } - const extraInformation: Record = {}; - if (sdkType.kind === "string") { - extraInformation["pattern"] = sdkType.pattern; - extraInformation["minLength"] = sdkType.minLength; - extraInformation["maxLength"] = sdkType.maxLength; - } else if ( - sdkType.kind === "int32" || - sdkType.kind === "int64" || - sdkType.kind === "float32" || - sdkType.kind === "float64" - ) { - extraInformation["minValue"] = sdkType.minValue; - extraInformation["maxValue"] = sdkType.maxValue; - } return { nullable: sdkType.nullable, type: "number", // TODO: switch to kind - doc: sdkType.doc, - apiVersions: sdkType.apiVersions, - sdkDefaultValue: sdkType.sdkDefaultValue, - format: sdkType.format, - ...extraInformation + doc: "", + apiVersions: [], + sdkDefaultValue: undefined, + format: undefined }; } @@ -1644,7 +1662,7 @@ export function emitCodeModel( simpleTypesMap.clear(); const allModels = getAllModels(dpgContext); for (const model of allModels) { - getType(dpgContext, model); + getType(dpgContext, model.__raw!); } for (const namespace of getNamespaces(dpgContext)) { diff --git a/packages/typespec-ts/src/modular/emitModels.ts b/packages/typespec-ts/src/modular/emitModels.ts index ad43acba3c..2f13125270 100644 --- a/packages/typespec-ts/src/modular/emitModels.ts +++ b/packages/typespec-ts/src/modular/emitModels.ts @@ -46,8 +46,9 @@ export function buildModels( typeName = `${typeName}[]`; } if (model.type === "enum") { - if (modelsFile.getTypeAlias(model.name!)) { + if (!model.name || modelsFile.getTypeAlias(model.name!)) { // If the enum is already defined, we don't need to do anything + // If the enum is anonymous, we don't build any type alias for it continue; } modelsFile.addTypeAlias({ diff --git a/packages/typespec-ts/src/modular/helpers/typeHelpers.ts b/packages/typespec-ts/src/modular/helpers/typeHelpers.ts index e126771566..cf46be0a24 100644 --- a/packages/typespec-ts/src/modular/helpers/typeHelpers.ts +++ b/packages/typespec-ts/src/modular/helpers/typeHelpers.ts @@ -1,4 +1,4 @@ -import { Type } from "../modularCodeModel.js"; +import { EnumValue, Type } from "../modularCodeModel.js"; export interface TypeMetadata { name: string; @@ -15,6 +15,12 @@ function getNullableType(name: string, type: Type): string { return name; } +function getAnonymousEnumName(values: EnumValue[]): string { + return values + .map((v) => (typeof v.value === "string" ? `"${v.value}"` : `${v.value}`)) + .join(" | "); +} + export function getType(type: Type, format?: string): TypeMetadata { switch (type.type) { case "Key": @@ -41,11 +47,18 @@ export function getType(type: Type, format?: string): TypeMetadata { case "datetime": return { name: getNullableType("Date", type) }; case "enum": - if (!type.name) { + if ( + !type.name && + (!type?.valueType?.type || + !["string", "number"].includes(type?.valueType?.type)) + ) { throw new Error("Unable to process enum without name"); } return { - name: getNullableType(type.name, type), + name: getNullableType( + type.name ?? getAnonymousEnumName(type.values ?? []), + type + ), originModule: "models.js" }; case "float": diff --git a/packages/typespec-ts/src/utils/clientUtils.ts b/packages/typespec-ts/src/utils/clientUtils.ts index 98ccec5ef1..28d2b915df 100644 --- a/packages/typespec-ts/src/utils/clientUtils.ts +++ b/packages/typespec-ts/src/utils/clientUtils.ts @@ -1,5 +1,5 @@ import { SdkClient } from "@azure-tools/typespec-client-generator-core"; -import { listServices } from "@typespec/compiler"; +import { Namespace, listServices } from "@typespec/compiler"; import { SdkContext } from "./interfaces.js"; export function getRLCClients(dpgContext: SdkContext): SdkClient[] { @@ -10,11 +10,18 @@ export function getRLCClients(dpgContext: SdkContext): SdkClient[] { kind: "SdkClient", name: service.type.name + "Client", service: service.type, - type: service.type + type: service.type, + arm: isArm(service.type) }; }); } +function isArm(service: Namespace): boolean { + return service.decorators.some( + (decorator) => decorator.decorator.name === "$armProviderNamespace" + ); +} + export function isRLCMultiEndpoint(dpgContext: SdkContext): boolean { return getRLCClients(dpgContext).length > 1; } diff --git a/packages/typespec-ts/test/modularUnit/modelsGenerator.spec.ts b/packages/typespec-ts/test/modularUnit/modelsGenerator.spec.ts index cc37c24fe9..c0d9efd5e1 100644 --- a/packages/typespec-ts/test/modularUnit/modelsGenerator.spec.ts +++ b/packages/typespec-ts/test/modularUnit/modelsGenerator.spec.ts @@ -1,5 +1,8 @@ import { assert } from "chai"; -import { emitModularModelsFromTypeSpec, emitModularOperationsFromTypeSpec } from "../util/emitUtil.js"; +import { + emitModularModelsFromTypeSpec, + emitModularOperationsFromTypeSpec +} from "../util/emitUtil.js"; import { assertEqualContent } from "../util/testUtil.js"; describe("modular model type", () => { @@ -23,7 +26,7 @@ describe("modular encode test for property type datetime", () => { prop4: offsetDateTime; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -40,7 +43,8 @@ describe("modular encode test for property type datetime", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -99,12 +103,13 @@ describe("modular encode test for property type datetime", () => { it("should handle header parameter type utcDateTime with default encoding", async () => { const tspContent = ` op read(@header prop: utcDateTime): OkResponse; - ` + `; const operationFiles = await emitModularOperationsFromTypeSpec(tspContent); assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -155,7 +160,7 @@ describe("modular encode test for property type datetime", () => { prop2: offsetDateTime; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -170,7 +175,8 @@ describe("modular encode test for property type datetime", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -227,7 +233,7 @@ describe("modular encode test for property type datetime", () => { prop2: offsetDateTime; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -242,7 +248,8 @@ describe("modular encode test for property type datetime", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -297,7 +304,7 @@ describe("modular encode test for property type datetime", () => { prop1: utcDateTime; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -311,7 +318,8 @@ describe("modular encode test for property type datetime", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -363,7 +371,7 @@ describe("modular encode test for property type duration", () => { prop1: duration; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -377,7 +385,8 @@ describe("modular encode test for property type duration", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -428,7 +437,7 @@ describe("modular encode test for property type duration", () => { prop1: duration; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -442,7 +451,8 @@ describe("modular encode test for property type duration", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -495,7 +505,7 @@ describe("modular encode test for property type duration", () => { prop2: duration; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -510,7 +520,8 @@ describe("modular encode test for property type duration", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -566,7 +577,7 @@ describe("modular encode test for property type bytes", () => { prop1: bytes; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -580,7 +591,8 @@ describe("modular encode test for property type bytes", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -635,7 +647,7 @@ describe("modular encode test for property type bytes", () => { prop1: bytes; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -649,7 +661,8 @@ describe("modular encode test for property type bytes", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -704,7 +717,7 @@ describe("modular encode test for property type bytes", () => { prop1: bytes; } op read(@body body: Foo): { @body body: Foo }; - ` + `; const modelFile = await emitModularModelsFromTypeSpec(tspContent); assert.ok(modelFile); assertEqualContent( @@ -718,7 +731,8 @@ describe("modular encode test for property type bytes", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -782,7 +796,7 @@ describe("inheritance & polymorphism", () => { kind: "dog"; bark: string; } - op read(): { @body body: Pet }; + op read(): { @body body: Cat | Dog }; `); assert.ok(modelFile); assertEqualContent( @@ -834,18 +848,14 @@ describe("inheritance & polymorphism", () => { export interface Cat extends Pet { kind: "cat"; meow: number; - } - - export interface Dog extends Pet { - kind: "dog"; - bark: string; }` ); const operationFiles = await emitModularOperationsFromTypeSpec(tspContent); assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -881,7 +891,8 @@ describe("inheritance & polymorphism", () => { const result = await _readSend(context, options); return _readDeserialize(result); } - `); + ` + ); }); it("should handle multi level inheritance model in operations", async () => { @@ -921,7 +932,8 @@ describe("inheritance & polymorphism", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -957,7 +969,8 @@ describe("inheritance & polymorphism", () => { const result = await _readSend(context, options); return _readDeserialize(result); } - `); + ` + ); }); it("should handle inheritance model with discriminator in operations", async () => { @@ -1004,7 +1017,8 @@ describe("inheritance & polymorphism", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -1040,7 +1054,92 @@ describe("inheritance & polymorphism", () => { const result = await _readSend(context, options); return _readDeserialize(result); } - `); + ` + ); + }); + + it("should handle base model with discriminator in operations", async () => { + const tspContent = ` + @discriminator("kind") + model Pet { + kind: string; + name: string; + weight?: float32; + } + model Cat extends Pet { + kind: "cat"; + meow: int32; + } + model Dog extends Pet { + kind: "dog"; + bark: string; + } + op read(): { @body body: Pet }; + `; + const modelFile = await emitModularModelsFromTypeSpec(tspContent); + assert.ok(modelFile); + assertEqualContent( + modelFile?.getFullText()!, + ` + export interface Pet { + /** the discriminator possible values cat, dog */ + kind: string; + name: string; + weight?: number; + } + + export interface Cat extends Pet { + kind: "cat"; + meow: number; + } + + export interface Dog extends Pet { + kind: "dog"; + bark: string; + }` + ); + const operationFiles = await emitModularOperationsFromTypeSpec(tspContent); + assert.ok(operationFiles); + assert.equal(operationFiles?.length, 1); + assertEqualContent( + operationFiles?.[0]?.getFullText()!, + ` + import { TestingContext as Client } from "../rest/index.js"; + import { + StreamableMethod, + operationOptionsToRequestParameters, + } from "@azure-rest/core-client"; + + export function _readSend( + context: Client, + options: ReadOptions = { requestOptions: {} } + ): StreamableMethod { + return context + .path("/") + .get({ ...operationOptionsToRequestParameters(options) }); + } + + export async function _readDeserialize(result: Read200Response): Promise { + if (result.status !== "200") { + throw result.body; + } + + return { + kind: result.body["kind"], + name: result.body["name"], + weight: result.body["weight"] + }; + } + + export async function read( + context: Client, + options: ReadOptions = { requestOptions: {} } + ): Promise { + const result = await _readSend(context, options); + return _readDeserialize(result); + } + ` + ); }); /** * TODO: This test is skipped because typespec has some issues. https://github.com/microsoft/typespec/issues/2411 @@ -1089,7 +1188,8 @@ describe("inheritance & polymorphism", () => { assert.ok(operationFiles); assert.equal(operationFiles?.length, 1); assertEqualContent( - operationFiles?.[0]?.getFullText()!,` + operationFiles?.[0]?.getFullText()!, + ` import { TestingContext as Client } from "../rest/index.js"; import { StreamableMethod, @@ -1126,6 +1226,7 @@ describe("inheritance & polymorphism", () => { const result = await _readSend(context, options); return _readDeserialize(result); } - `); + ` + ); }); }); diff --git a/packages/typespec-ts/test/modularUnit/type.spec.ts b/packages/typespec-ts/test/modularUnit/type.spec.ts new file mode 100644 index 0000000000..0d674d6227 --- /dev/null +++ b/packages/typespec-ts/test/modularUnit/type.spec.ts @@ -0,0 +1,113 @@ +import { assert } from "chai"; +import { emitModularModelsFromTypeSpec } from "../util/emitUtil.js"; +import { assertEqualContent } from "../util/testUtil.js"; + +describe("model type", () => { + describe("string | string literal | nullable", () => { + it("string enum", async () => { + const modelFile = await emitModularModelsFromTypeSpec(` + model Test { + color: "red" | "blue"; + } + op read(@body body: Test): void; + `); + assert.ok(modelFile); + assertEqualContent( + modelFile!.getFullText()!, + ` + export interface Test { + color: "red" | "blue"; + }` + ); + }); + + // TODO: tgcg lib has a bug here: https://github.com/Azure/typespec-azure/issues/3623 + it.skip("nullable string literal", async () => { + const modelFile = await emitModularModelsFromTypeSpec(` + model Test { + content: "red" | null; + } + op read(@body body: Test): void; + `); + assert.ok(modelFile); + assertEqualContent( + modelFile!.getFullText()!, + ` + export interface Test { + content: "red" | null; + }` + ); + }); + + it("nullable string", async () => { + const modelFile = await emitModularModelsFromTypeSpec(` + model Test { + content: string | null; + } + op read(@body body: Test): void; + `); + assert.ok(modelFile); + assertEqualContent( + modelFile!.getFullText()!, + ` + export interface Test { + content: string | null; + }` + ); + }); + }); + + describe("number | numeric literal | nullable", () => { + it("number enum", async () => { + const modelFile = await emitModularModelsFromTypeSpec(` + model Test { + color: 1 | 2; + } + op read(@body body: Test): void; + `); + assert.ok(modelFile); + assertEqualContent( + modelFile!.getFullText()!, + ` + export interface Test { + color: 1 | 2; + }` + ); + }); + + // TODO: tgcg lib has a bug here: https://github.com/Azure/typespec-azure/issues/3623 + it.skip("nullable numeric literal", async () => { + const modelFile = await emitModularModelsFromTypeSpec(` + model Test { + content: 1 | null; + } + op read(@body body: Test): void; + `); + assert.ok(modelFile); + assertEqualContent( + modelFile!.getFullText()!, + ` + export interface Test { + content: 1 | null; + }` + ); + }); + + it("nullable number", async () => { + const modelFile = await emitModularModelsFromTypeSpec(` + model Test { + content: int32 | null; + } + op read(@body body: Test): void; + `); + assert.ok(modelFile); + assertEqualContent( + modelFile!.getFullText()!, + ` + export interface Test { + content: number | null; + }` + ); + }); + }); +}); diff --git a/packages/typespec-ts/test/unit/modelsGenerator.spec.ts b/packages/typespec-ts/test/unit/modelsGenerator.spec.ts index a6f8556db6..be4a74765f 100644 --- a/packages/typespec-ts/test/unit/modelsGenerator.spec.ts +++ b/packages/typespec-ts/test/unit/modelsGenerator.spec.ts @@ -1613,9 +1613,9 @@ describe("Input/output model type", () => { x: int32; } - @@projectedName(FooModel.x, "client", "NotToUseMeAsName") // Should be ignored - @@projectedName(FooModel.x, "javascript", "MadeForTS") - @@projectedName(FooModel.x, "json", "xJson") + @@projectedName(FooModel.x, "client", "NotToUseMeAsName"); // Should be ignored + @@projectedName(FooModel.x, "javascript", "MadeForTS"); + @@projectedName(FooModel.x, "json", "xJson"); `; const tspType = "FooModel"; const inputModelName = "FooModel";