diff --git a/common/changes/@autorest/openapi-to-typespec/update_config_2024-01-23-17-46.json b/common/changes/@autorest/openapi-to-typespec/update_config_2024-01-23-17-46.json new file mode 100644 index 0000000000..59bb86c114 --- /dev/null +++ b/common/changes/@autorest/openapi-to-typespec/update_config_2024-01-23-17-46.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@autorest/openapi-to-typespec", + "comment": "Improve data-plane tspconfig", + "type": "patch" + } + ], + "packageName": "@autorest/openapi-to-typespec" +} \ No newline at end of file diff --git a/packages/extensions/openapi-to-typespec/src/emiters/emit-typespec-config.ts b/packages/extensions/openapi-to-typespec/src/emiters/emit-typespec-config.ts index d51f92e61a..f89e847534 100644 --- a/packages/extensions/openapi-to-typespec/src/emiters/emit-typespec-config.ts +++ b/packages/extensions/openapi-to-typespec/src/emiters/emit-typespec-config.ts @@ -1,24 +1,34 @@ +import { pascalCase } from "@azure-tools/codegen"; +import { TypespecProgram } from "interfaces"; import { getSession } from "../autorest-session"; import { getOptions } from "../options"; import { formatFile } from "../utils/format"; -export async function emitTypespecConfig(filePath: string): Promise { +export async function emitTypespecConfig(filePath: string, programDetails: TypespecProgram): Promise { const session = getSession(); const { isArm } = getOptions(); - let content = `emit: - - "@azure-tools/typespec-autorest" - # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code - # "@azure-tools/typespec-python": - # "basic-setup-py": true - # "package-version": - # "package-name": - # "output-path": - # Uncomment this line and add "@azure-tools/typespec-java" to your package.json to generate Java code - # "@azure-tools/typespec-java": true - # Uncomment this line and add "@azure-tools/typespec-csharp" to your package.json to generate C# code - # "@azure-tools/typespec-csharp": true - # Uncomment this line and add "@azure-tools/typespec-ts" to your package.json to generate Typescript code - # "@azure-tools/typespec-ts": true + let content = ` + emit: + - "@azure-tools/typespec-autorest" + + options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" + # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code + # "@azure-tools/typespec-python": + # "basic-setup-py": true + # "package-version": + # "package-name": + # "output-path": + # Uncomment this line and add "@azure-tools/typespec-java" to your package.json to generate Java code + # "@azure-tools/typespec-java": true + # Uncomment this line and add "@azure-tools/typespec-csharp" to your package.json to generate C# code + # "@azure-tools/typespec-csharp": true + # Uncomment this line and add "@azure-tools/typespec-ts" to your package.json to generate Typescript code + # "@azure-tools/typespec-ts": true `; if (isArm) { diff --git a/packages/extensions/openapi-to-typespec/src/main.ts b/packages/extensions/openapi-to-typespec/src/main.ts index be6dbc0bd7..06b4acdf5b 100644 --- a/packages/extensions/openapi-to-typespec/src/main.ts +++ b/packages/extensions/openapi-to-typespec/src/main.ts @@ -35,7 +35,7 @@ export async function processConverter(host: AutorestExtensionHost) { await emitRoutes(getFilePath(session, "routes.tsp"), programDetails); await emitMain(getFilePath(session, "main.tsp"), programDetails); await emitPackage(getFilePath(session, "package.json"), programDetails); - await emitTypespecConfig(getFilePath(session, "tspconfig.yaml")); + await emitTypespecConfig(getFilePath(session, "tspconfig.yaml"), programDetails); } function getOutuptDirectory(session: Session) { diff --git a/packages/extensions/openapi-to-typespec/test/analyzeText/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/analyzeText/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/analyzeText/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/analyzeText/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/anomalyDetector/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/anomalyDetector/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/anomalyDetector/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/anomalyDetector/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/batch/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/batch/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/batch/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/batch/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/bodyComplex/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/bodyComplex/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/bodyComplex/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/bodyComplex/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/complexObject/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/complexObject/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/complexObject/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/complexObject/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/confidentialLedger/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/confidentialLedger/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/confidentialLedger/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/confidentialLedger/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/keyvault/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/keyvault/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/keyvault/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/keyvault/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/loadTest/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/loadTest/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/loadTest/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/loadTest/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/nh/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/nh/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/nh/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/nh/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/openAI/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/openAI/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/openAI/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/openAI/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/pagination/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/pagination/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/pagination/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/pagination/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/qna/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/qna/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/qna/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/qna/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/qnaAuthoring/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/qnaAuthoring/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/qnaAuthoring/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/qnaAuthoring/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/qnaRuntime/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/qnaRuntime/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/qnaRuntime/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/qnaRuntime/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/schemaRegistry/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/schemaRegistry/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/schemaRegistry/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/schemaRegistry/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/url/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/url/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/url/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/url/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true diff --git a/packages/extensions/openapi-to-typespec/test/webpubsub/tsp-output/tspconfig.yaml b/packages/extensions/openapi-to-typespec/test/webpubsub/tsp-output/tspconfig.yaml index fb405fa449..ca5603dc70 100644 --- a/packages/extensions/openapi-to-typespec/test/webpubsub/tsp-output/tspconfig.yaml +++ b/packages/extensions/openapi-to-typespec/test/webpubsub/tsp-output/tspconfig.yaml @@ -1,5 +1,12 @@ emit: - "@azure-tools/typespec-autorest" + +options: + "@azure-tools/typespec-autorest": + azure-resource-provider-folder: "data-plane" + emitter-output-dir: "{project-root}/.." + examples-directory: "{project-root}/examples" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" # Uncomment this line and add "@azure-tools/typespec-python" to your package.json to generate Python code # "@azure-tools/typespec-python": # "basic-setup-py": true