Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
43 changes: 43 additions & 0 deletions specification/resources/Bicep.Management/main.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
Copy link
Member

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.

Copy link
Member

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):

// If the folder containing TypeSpec sources is under "data-plane" or "resource-manager", the spec
// must be using "folder structure v2". Otherwise, it must be using v1.
const structureVersion =
relativePath.includes("data-plane") || relativePath.includes("resource-manager") ? 2 : 1;

Copy link
Member

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.json
And the inner most readme.md file is
specification/resources/resource-manager/Microsoft.Resources/bicep/readme.md
which means this is a v2 folder structure. Therefore, the typespec should also follow the v2 folder structure.

Copy link
Member

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:

$ find specification -type f -name 'readme.md' | grep resource-manager | grep -v r
esource-manager/readme.md

specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/extensionTypes/readme.md

specification/monitor/resource-manager/Microsoft.Insights/PrivateLinkScopes/readme.md

specification/monitor/resource-manager/Microsoft.Monitor/Operations/readme.md

specification/monitor/resource-manager/Microsoft.Monitor/PipelineGroups/readme.md

Copy link
Member

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.

Copy link
Member

@mikeharder mikeharder Jun 24, 2025

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* 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",
}
51 changes: 51 additions & 0 deletions specification/resources/Bicep.Management/models.tsp
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;
}
35 changes: 35 additions & 0 deletions specification/resources/Bicep.Management/routes.tsp
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"
);
48 changes: 48 additions & 0 deletions specification/resources/Bicep.Management/tspconfig.yaml
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"

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# Bicep

> see https://aka.ms/autorest

This is the AutoRest configuration file for Bicep.
This is the AutoRest configuration file.

## Getting Started

To build the SDKs for Bicep, simply install AutoRest via `npm` (`npm install -g autorest`) and then run:
To build the SDKs, simply install AutoRest via `npm` (`npm install -g autorest`) and then run:

> `autorest readme.md`

To see additional help and options, run:

> `autorest --help`

For other options on installation see [Installing AutoRest](https://aka.ms/autorest/install) on the AutoRest github page.

---
Expand All @@ -22,7 +19,7 @@ For other options on installation see [Installing AutoRest](https://aka.ms/autor

### Basic Information

These are the global settings for the Bicep client.
These are the global settings.

``` yaml
title: BicepClient
Expand All @@ -31,8 +28,6 @@ openapi-type: arm
tag: package-2023-11
```

---

### Tag: package-2023-11

These settings apply only when `--tag=package-2023-11` is specified on the command line.
Expand All @@ -49,41 +44,4 @@ directive:
- suppress: OperationsAPIImplementation
from: bicepClient.json
reason: Operations API is implemented as a separate service.
```

# Code Generation

## Swagger to SDK

This section describes what SDK should be generated by the automatic system.
This is not used by Autorest itself.

``` yaml $(swagger-to-sdk)
swagger-to-sdk:
- repo: azure-sdk-for-net
- repo: azure-sdk-for-python
- repo: azure-sdk-for-java
- repo: azure-sdk-for-go
- repo: azure-sdk-for-js
- repo: azure-powershell
```

## CSharp

See configuration in [readme.csharp.md](./readme.csharp.md)

## Go

See configuration in [readme.go.md](./readme.go.md)

## Java

See configuration in [readme.java.md](./readme.java.md)

## Python

See configuration in [readme.python.md](./readme.python.md)

## TypeScript

See configuration in [readme.typescript.md](./readme.typescript.md)
```

This file was deleted.

This file was deleted.

Loading
Loading