-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Migrate Bicep service to TypeSpec #35306
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7a222fb
Migrate Bicep service to TypeSpec
anthony-c-martin 8e065eb
Merge branch 'main' into ant/bicep_ts
anthony-c-martin db9c7bb
Merge branch 'main' into ant/bicep_ts
anthony-c-martin f4159bc
Merge branch 'main' into ant/bicep_ts
anthony-c-martin 240af19
Update configuration files to use TypeSpec
anthony-c-martin a166643
Merge branch 'main' into ant/bicep_ts
anthony-c-martin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
specification/resources/Bicep.Management/examples/2023-11-01/DecompileBicep.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2023-11-01", | ||
| "decompileOperationRequest": { | ||
| "template": "{\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"metadata\": {\r\n \"_generator\": {\r\n \"name\": \"bicep\",\r\n \"version\": \"0.15.31.15270\",\r\n \"templateHash\": \"9249505596133208719\"\r\n }\r\n },\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"string\"\r\n }\r\n },\r\n \"resources\": []\r\n}" | ||
| }, | ||
| "subscriptionId": "00000000-0000-0000-0000-000000000000" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "entryPoint": "main.bicep", | ||
| "files": [ | ||
| { | ||
| "path": "main.bicep", | ||
| "contents": "param storageAccountName string" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "Decompile_Bicep", | ||
| "title": "Decompile an ARM json template into a Bicep file" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** | ||
| * PLEASE DO NOT REMOVE - USED FOR CONVERTER METRICS | ||
| * Generated by package: @autorest/openapi-to-typespec | ||
| * Parameters used: | ||
| * isFullCompatible: false | ||
| * guessResourceKey: false | ||
| * Version: 0.11.1 | ||
| * Date: 2025-06-17T02:23:33.791Z | ||
| */ | ||
| import "@typespec/rest"; | ||
| import "@typespec/versioning"; | ||
| import "@azure-tools/typespec-azure-core"; | ||
| import "@azure-tools/typespec-azure-resource-manager"; | ||
| import "./models.tsp"; | ||
| import "./routes.tsp"; | ||
|
|
||
| using TypeSpec.Rest; | ||
| using TypeSpec.Http; | ||
| using Azure.ResourceManager.Foundations; | ||
| using Azure.Core; | ||
| using Azure.ResourceManager; | ||
| using TypeSpec.Versioning; | ||
| /** | ||
| * Bicep Client | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint" "Operations API defined separately - namespace is shared between multiple services." | ||
| @armProviderNamespace("Microsoft.Resources") | ||
| @service(#{ title: "Bicep Client" }) | ||
| @versioned(Versions) | ||
| @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) | ||
| namespace BicepClient; | ||
|
|
||
| /** | ||
| * The available API versions. | ||
| */ | ||
| enum Versions { | ||
| /** | ||
| * The 2023-11-01 API version. | ||
| */ | ||
| @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) | ||
| @useDependency(Azure.Core.Versions.v1_0_Preview_1) | ||
| v2023_11_01: "2023-11-01", | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import "@typespec/rest"; | ||
| import "@typespec/http"; | ||
| import "@azure-tools/typespec-azure-resource-manager"; | ||
|
|
||
| using TypeSpec.Rest; | ||
| using TypeSpec.Http; | ||
| using Azure.ResourceManager; | ||
| using Azure.ResourceManager.Foundations; | ||
|
|
||
| namespace BicepClient; | ||
|
|
||
| /** | ||
| * The body of the request for the decompileBicep operation | ||
| */ | ||
| model DecompileOperationRequest { | ||
| /** | ||
| * The ARM json template to be decompiled into a Bicep file | ||
| */ | ||
| template: string; | ||
| } | ||
|
|
||
| /** | ||
| * The response of the decompileBicep operation | ||
| */ | ||
| model DecompileOperationSuccessResponse { | ||
| /** | ||
| * An array of key-value pairs containing the entryPoint string as the key for the Bicep file decompiled from the ARM json template | ||
| */ | ||
| @OpenAPI.extension("x-ms-identifiers", #["path"]) | ||
| files: FileDefinition[]; | ||
|
|
||
| /** | ||
| * The file path to the main Bicep file generated from the decompiled ARM json template. | ||
| */ | ||
| entryPoint: string; | ||
| } | ||
|
|
||
| /** | ||
| * The definition of a file along with its contents | ||
| */ | ||
| model FileDefinition { | ||
| /** | ||
| * The file path of the Bicep file. | ||
| */ | ||
| path?: string; | ||
|
|
||
| /** | ||
| * The contents of the Bicep file. | ||
| */ | ||
| contents?: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import "@azure-tools/typespec-azure-core"; | ||
| import "@typespec/rest"; | ||
| import "./models.tsp"; | ||
| import "@azure-tools/typespec-azure-resource-manager"; | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
| import "@typespec/openapi"; | ||
|
|
||
| using TypeSpec.Rest; | ||
| using TypeSpec.Http; | ||
| using Azure.ResourceManager; | ||
| using TypeSpec.OpenAPI; | ||
| using Azure.ClientGenerator.Core; | ||
|
|
||
| namespace BicepClient; | ||
|
|
||
| @armResourceOperations | ||
| interface DecompileOperationGroup { | ||
| /** | ||
| * Decompiles an ARM json template into a Bicep template | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/no-openapi" "For backward compatibility" | ||
| @autoRoute | ||
| @action("decompileBicep") | ||
| @operationId("Decompile_Bicep") | ||
| bicep is ArmProviderActionSync< | ||
| Request = DecompileOperationRequest, | ||
| Response = DecompileOperationSuccessResponse, | ||
| Scope = SubscriptionActionScope, | ||
| Parameters = {} | ||
| >; | ||
| } | ||
|
|
||
| @@clientName(DecompileOperationGroup.bicep::parameters.body, | ||
| "decompileOperationRequest" | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| parameters: | ||
| "service-dir": | ||
| default: "sdk/resources" | ||
| emit: | ||
| - "@azure-tools/typespec-autorest" | ||
| options: | ||
| "@azure-tools/typespec-autorest": | ||
| omit-unreachable-types: true | ||
| emitter-output-dir: "{project-root}/.." | ||
| azure-resource-provider-folder: "resource-manager" | ||
| output-file: "{azure-resource-provider-folder}/Microsoft.Resources/bicep/{version-status}/{version}/bicepClient.json" | ||
| examples-dir: "{project-root}/examples" | ||
| "@azure-tools/typespec-csharp": | ||
| flavor: azure | ||
| package-dir: "Azure.ResourceManager.Resources.Bicep" | ||
| clear-output-folder: true | ||
| model-namespace: true | ||
| namespace: "{package-dir}" | ||
| "@azure-tools/typespec-python": | ||
| package-dir: "azure-mgmt-resources-bicep" | ||
| namespace: "azure.mgmt.resources.bicep" | ||
| generate-test: true | ||
| generate-sample: true | ||
| flavor: "azure" | ||
| "@azure-tools/typespec-java": | ||
| package-dir: "azure-resourcemanager-resources-bicep" | ||
| namespace: "com.azure.resourcemanager.resources.bicep" | ||
| service-name: "Bicep Provider" | ||
| flavor: azure | ||
| "@azure-tools/typespec-ts": | ||
| package-dir: "arm-resourcesbicep" | ||
| flavor: azure | ||
| experimental-extensible-enums: true | ||
| package-details: | ||
| name: "@azure/arm-resourcesbicep" | ||
| "@azure-tools/typespec-go": | ||
| service-dir: "sdk/resourcemanager/resources" | ||
| package-dir: "armbicep" | ||
| module: "github.com/Azure/azure-sdk-for-go/{service-dir}/{package-dir}" | ||
| fix-const-stuttering: true | ||
| flavor: "azure" | ||
| generate-samples: true | ||
| generate-fakes: true | ||
| head-as-boolean: true | ||
| inject-spans: true | ||
| linter: | ||
| extends: | ||
| - "@azure-tools/typespec-azure-rulesets/resource-manager" |
15 changes: 0 additions & 15 deletions
15
...ification/resources/resource-manager/Microsoft.Resources/bicep/readme.csharp.md
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
specification/resources/resource-manager/Microsoft.Resources/bicep/readme.go.md
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
specification/resources/resource-manager/Microsoft.Resources/bicep/readme.java.md
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
...ification/resources/resource-manager/Microsoft.Resources/bicep/readme.python.md
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...ation/resources/resource-manager/Microsoft.Resources/bicep/readme.typescript.md
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@mikeharder do you know why it didn't report error of the folder structure? as the swagger is folder structure v2 but the typespec is using v1.
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.
This is technically still v1. Before v2, there were existing specs in main, with the TSP outside data-plane/resource-manager, but the swagger under resource-manager happened to already follow v2.
In v1, any folder structure for the swagger was allowed. The only requirement, was that the TSP sources had to be directly under the org-name (not under DP/RM).
The only thing that determines if a spec is v1 or v2, is whether the TSP sources are under DP/RM (or not):
azure-rest-api-specs/eng/tools/typespec-validation/src/rules/folder-structure.ts
Lines 24 to 27 in 9bf0bec
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.
Is it possible to determine if a spec is v1 or v2 based on the inner most readme.md that typespec-autorest output file would refer to?
In this case, the typespec-autorest output-file is
specification/resources/resource-manager/Microsoft.Resources/bicep/stable/2023-11-01/bicepClient.jsonAnd the inner most readme.md file is
specification/resources/resource-manager/Microsoft.Resources/bicep/readme.mdwhich means this is a v2 folder structure. Therefore, the typespec should also follow the v2 folder structure.
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.
I do not think you can use this as a heuristic, because there are existing v1 specs with readme.md at all levels of the folder structure:
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.
Actually, the list you mentioned are all real v2 folder structure for the new split services.
Kubernetesconfiguration has split into multiple services a long time ago, the only reason they have readme.md under resource-manager folder is that they have some apis need to be deprecated, that's why Jeffrey suggests them to keep those file where they are, no need to split new services for them.
For the monitor services PipelineGroups and Operations, they have migrated to typespec https://github.com/Azure/azure-rest-api-specs/tree/main/specification/monitor
For the PrivateLinkScopes, service team themself has mentioned that they want to move off PrivateLinkScopes as an independent service.
Uh oh!
There was an error while loading. Please reload this page.
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.
If you believe something should change in the TypeSpecValidation v2 folder structure rule, please open an issue or a PR for the change, and assign to me.
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.
issue created https://github.com/Azure/azure-sdk-tools/issues/10975, thanks