-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[TSP Migration] Migrate healthbot from swagger to TypeSpec #34069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 55 commits
6b95d61
01bcdad
2c25232
9c99306
faff190
ffd9fcb
c6c613e
0b3b4b1
5f0c8bc
bca8a34
58eadfb
4689c6b
fc3d499
aa594d3
e3e5273
ffe66f4
f5ef155
a5baf3e
dd3f5c6
8af8366
40d39ee
5fb60d8
71a0725
5aa2e58
677cc0b
6e73755
ba12d1e
c2cfb43
3a685f3
8d7ad7a
118ee38
a9c6b51
5ee40d3
7f8de9e
42d1779
8dcc1a4
aa18b1c
8b9ac71
2de5a76
adb6660
18fedd3
8457045
7b35532
bed39bb
b89d23e
47d88dd
5bb5ad9
26a819b
fc5251d
317fc2e
ab7b671
8c48db5
54484bf
22c7979
f14c85b
f80ff8a
78702c7
2db438e
098e942
8c950ea
472f517
6fc786c
27c1578
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| import "@azure-tools/typespec-azure-core"; | ||
| import "@azure-tools/typespec-azure-resource-manager"; | ||
| import "@typespec/openapi"; | ||
| import "@typespec/rest"; | ||
|
|
||
| using TypeSpec.Rest; | ||
| using Azure.ResourceManager; | ||
| using TypeSpec.Http; | ||
| using TypeSpec.OpenAPI; | ||
|
|
||
| namespace Microsoft.HealthBot; | ||
| /** | ||
| * Azure Health Bot resource definition | ||
| */ | ||
| model HealthBot | ||
| is Azure.ResourceManager.TrackedResource<HealthBotProperties, true> { | ||
| ...ResourceNameParameter< | ||
| Resource = HealthBot, | ||
| KeyName = "botName", | ||
| SegmentName = "healthBots", | ||
| NamePattern = "^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" | ||
| >; | ||
|
|
||
| /** | ||
| * SKU of the Azure Health Bot. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| sku: Sku; | ||
|
|
||
| /** | ||
| * The identity of the Azure Health Bot. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| identity?: Identity; | ||
| } | ||
|
|
||
| @armResourceOperations | ||
| interface HealthBots { | ||
| /** | ||
| * Get a HealthBot. | ||
| */ | ||
| get is ArmResourceRead<HealthBot, Error = Error>; | ||
|
|
||
| /** | ||
| * Create a new Azure Health Bot. | ||
| */ | ||
| create is ArmResourceCreateOrReplaceAsync< | ||
| HealthBot, | ||
| Error = Error, | ||
| Response = ArmResourceUpdatedResponse<HealthBot> | ArmResourceCreatedResponse< | ||
| HealthBot, | ||
| ArmAsyncOperationHeader & Azure.Core.Foundations.RetryAfterHeader | ||
| > | ||
| >; | ||
|
|
||
| /** | ||
| * Patch a HealthBot. | ||
| */ | ||
| @patch(#{ implicitOptionality: false }) | ||
| update is ArmCustomPatchAsync< | ||
| HealthBot, | ||
| PatchModel = HealthBotUpdateParameters, | ||
| Error = Error, | ||
| Response = ArmResponse<HealthBot> | ArmResourceCreatedResponse< | ||
| HealthBot, | ||
| ArmLroLocationHeader<FinalResult = HealthBot> & | ||
| Azure.Core.Foundations.RetryAfterHeader | ||
| > | ||
| >; | ||
|
|
||
| /** | ||
| * Delete a HealthBot. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like we could have put a better justification here
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is Laurant gave me in wave 1. |
||
| delete is ArmResourceDeleteWithoutOkAsync< | ||
| HealthBot, | ||
| Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse<LroHeaders = ArmLroLocationHeader> | ArmDeletedNoContentResponse, | ||
| Error = Error | ||
| >; | ||
|
|
||
| /** | ||
| * Returns all the resources of a particular type belonging to a resource group | ||
| */ | ||
| listByResourceGroup is ArmResourceListByParent< | ||
| HealthBot, | ||
| Response = ArmResponse<BotResponseList>, | ||
| Error = Error | ||
| >; | ||
|
|
||
| /** | ||
| * Returns all the resources of a particular type belonging to a subscription. | ||
| */ | ||
| list is ArmListBySubscription< | ||
| HealthBot, | ||
| Response = ArmResponse<BotResponseList>, | ||
| Error = Error | ||
| >; | ||
|
|
||
| /** | ||
| * List all secrets of a HealthBot. | ||
| */ | ||
| listSecrets is ArmResourceActionSync< | ||
| HealthBot, | ||
| void, | ||
| ArmResponse<HealthBotKeysResponse>, | ||
| Error = Error | ||
| >; | ||
|
|
||
| /** | ||
| * Regenerate the API JWT Secret of a HealthBot. | ||
| */ | ||
| regenerateApiJwtSecret is ArmResourceActionSync< | ||
| HealthBot, | ||
| void, | ||
| ArmResponse<HealthBotKey>, | ||
| Error = Error | ||
| >; | ||
| } | ||
|
|
||
| @@maxLength(HealthBot.name, 64); | ||
| @@minLength(HealthBot.name, 2); | ||
| @@doc(HealthBot.name, "The name of the Bot resource."); | ||
| @@doc(HealthBot.properties, | ||
| "The set of properties specific to Azure Health Bot resource." | ||
| ); | ||
| @@doc(HealthBots.create::parameters.resource, | ||
| "The parameters to provide for the created Azure Health Bot." | ||
| ); | ||
| @@doc(HealthBots.update::parameters.properties, | ||
| "The parameters to provide for the required Azure Health Bot." | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
|
|
||
| using Azure.ClientGenerator.Core; | ||
| using Microsoft.HealthBot; | ||
|
|
||
| @@clientLocation(HealthBots.get, "Bots"); | ||
| @@clientLocation(HealthBots.create, "Bots"); | ||
| @@clientLocation(HealthBots.update, "Bots"); | ||
| @@clientLocation(HealthBots.delete, "Bots"); | ||
| @@clientLocation(HealthBots.listByResourceGroup, "Bots"); | ||
| @@clientLocation(HealthBots.list, "Bots"); | ||
| @@clientLocation(HealthBots.listSecrets, "Bots"); | ||
| @@clientLocation(HealthBots.regenerateApiJwtSecret, "Bots"); | ||
|
|
||
| @@clientName(HealthBots.create::parameters.resource, "parameters"); | ||
| @@clientName(HealthBots.update::parameters.properties, "parameters"); | ||
| @@visibility(BotResponseList.value, Lifecycle.Read); | ||
| @@clientName(KeyVaultProperties.keyName, "KeyName"); | ||
| @@clientName(KeyVaultProperties.keyVersion, "KeyVersion"); | ||
| @@clientName(KeyVaultProperties.keyVaultUri, "KeyVaultUri"); | ||
| @@clientName(KeyVaultProperties.userIdentity, "UserIdentity"); | ||
| @@clientName(HealthBotKeysResponse, "HealthBotKeysResult", "csharp"); |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are there client customizations in both this file and the back-compatible.tsp file? Should we just use one file to simplify?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is our guidance: https://azure.github.io/typespec-azure/docs/migrate-swagger/checklists/migrate-arm-tips/ ✅ DO add customizations that impact only generated client SDKs in client.tsp ✅ DO add customizations that impact both generated client SDKs and generated OpenAPI specs in back-compat.tsp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
| import "./main.tsp"; | ||
| using Azure.ClientGenerator.Core; | ||
|
|
||
| @@clientName(Microsoft.HealthBot, "HealthbotClient", "javascript"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2025-05-25" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "value": [ | ||
| { | ||
| "name": "Microsoft.Healthbot/healthbots/read", | ||
| "display": { | ||
| "description": "Read Azure Health Bot", | ||
| "operation": "Read Azure Health Bot", | ||
| "provider": "Azure Health Bot", | ||
| "resource": "Azure Health Bot" | ||
| }, | ||
| "origin": "user,system" | ||
| }, | ||
| { | ||
| "name": "Microsoft.Healthbot/healthbots/write", | ||
| "display": { | ||
| "description": "Writes Azure Health Bot", | ||
| "operation": "Write Azure Health Bot", | ||
| "provider": "Azure Health Bot", | ||
| "resource": "Azure Health Bot" | ||
| }, | ||
| "origin": "user,system" | ||
| }, | ||
| { | ||
| "name": "Microsoft.Healthbot/healthbots/delete", | ||
| "display": { | ||
| "description": "Deletes Azure Health Bot", | ||
| "operation": "Delete Azure Health Bot", | ||
| "provider": "Azure Health Bot", | ||
| "resource": "Azure Health Bot" | ||
| }, | ||
| "origin": "user,system" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "Operations_List", | ||
| "title": "Get Operations" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2025-05-25", | ||
| "resourceGroupName": "OneResourceGroupName", | ||
| "subscriptionId": "subscription-id" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "value": [ | ||
| { | ||
| "name": "samplebotname", | ||
| "type": "Microsoft.HealthBot/healthBots", | ||
| "id": "/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.HealthBot/healthBots/samplebotname", | ||
| "location": "East US", | ||
| "properties": { | ||
| "botManagementPortalLink": "https://us.healthbot.microsoft.com/account/samplebotname-1yhd91k" | ||
| }, | ||
| "sku": { | ||
| "name": "F0" | ||
| }, | ||
| "systemData": { | ||
| "createdAt": "2020-05-05T17:18:19.1234567Z", | ||
| "createdBy": "jack@outlook.com", | ||
| "createdByType": "User", | ||
| "lastModifiedAt": "2020-05-06T17:18:19.1234567Z", | ||
| "lastModifiedBy": "ryan@outlook.com", | ||
| "lastModifiedByType": "User" | ||
| } | ||
| }, | ||
| { | ||
| "name": "samplebotname2", | ||
| "type": "Microsoft.HealthBot/healthBots", | ||
| "id": "/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.HealthBot/healthBots/samplebotname2", | ||
| "identity": { | ||
| "type": "SystemAssigned, UserAssigned", | ||
| "principalId": "principalId", | ||
| "tenantId": "tenantId", | ||
| "userAssignedIdentities": { | ||
| "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": {}, | ||
| "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": {} | ||
| } | ||
| }, | ||
| "location": "East US", | ||
| "properties": { | ||
| "botManagementPortalLink": "https://us.healthbot.microsoft.com/account/samplebotname2-hdi1osc" | ||
| }, | ||
| "sku": { | ||
| "name": "S1" | ||
| }, | ||
| "systemData": { | ||
| "createdAt": "2020-05-05T17:18:19.1234567Z", | ||
| "createdBy": "jack@outlook.com", | ||
| "createdByType": "User", | ||
| "lastModifiedAt": "2020-05-06T17:18:19.1234567Z", | ||
| "lastModifiedBy": "ryan@outlook.com", | ||
| "lastModifiedByType": "User" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "Bots_ListByResourceGroup", | ||
| "title": "List Bots by Resource Group" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2025-05-25", | ||
| "resourceGroupName": "OneResourceGroupName", | ||
| "subscriptionId": "subscription-id" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "value": [ | ||
| { | ||
| "name": "samplebotname2", | ||
| "type": "Microsoft.HealthBot/healthBots", | ||
| "id": "/subscriptions/subscription-id/resourceGroups/OneResourceGroupName/providers/Microsoft.HealthBot/healthBots/samplebotname2", | ||
| "identity": { | ||
| "type": "SystemAssigned, UserAssigned", | ||
| "principalId": "principalId", | ||
| "tenantId": "tenantId", | ||
| "userAssignedIdentities": { | ||
| "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi": {}, | ||
| "/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2": {} | ||
| } | ||
| }, | ||
| "location": "East US", | ||
| "properties": { | ||
| "botManagementPortalLink": "https://us.healthbot.microsoft.com/account/samplebotname2-hdi1osc" | ||
| }, | ||
| "sku": { | ||
| "name": "S1" | ||
| }, | ||
| "systemData": { | ||
| "createdAt": "2020-05-05T17:18:19.1234567Z", | ||
| "createdBy": "jack@outlook.com", | ||
| "createdByType": "User", | ||
| "lastModifiedAt": "2020-05-06T17:18:19.1234567Z", | ||
| "lastModifiedBy": "ryan@outlook.com", | ||
| "lastModifiedByType": "User" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "Bots_List", | ||
| "title": "List Bots by Subscription" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2025-05-25", | ||
| "botName": "samplebotname", | ||
| "resourceGroupName": "healthbotClient", | ||
| "subscriptionId": "subid" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "secrets": [ | ||
| { | ||
| "keyName": "APP_SECRET", | ||
| "value": "XXXXX" | ||
| }, | ||
| { | ||
| "keyName": "WEBCHAT_SECRET", | ||
| "value": "XXXXX" | ||
| }, | ||
| { | ||
| "keyName": "API_JWT_SECRET", | ||
| "value": "XXXXX" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "Bots_ListSecrets", | ||
| "title": "Bot List Secrets" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2025-05-25", | ||
| "botName": "samplebotname", | ||
| "resourceGroupName": "healthbotClient", | ||
| "subscriptionId": "subid" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "keyName": "API_JWT_SECRET", | ||
| "value": "XXXXX" | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "Bots_RegenerateApiJwtSecret", | ||
| "title": "Bot Regenerate API JWT Secret" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know why this warning is popping up? Can we design this differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The envelop property in our library is
However, in the original swagger, the sku is required so that we cannot use the envelop one.
Sounds a question to @markcowl