Azure / autorest

OpenAPI (f.k.a Swagger) Specification code generator. Supports C#, PowerShell, Go, Java, Node.js, TypeScript, Python
MIT License
4.55k stars 728 forks source link

[openapi-to-typespec] Missing `@typespec/versioning` import #4931

Open catalinaperalta opened 3 months ago

catalinaperalta commented 3 months ago

When converting a swagger to typespec, the @versioned decorator is correctly added, but the spec is missing the import and using statements. We need to add the following in the main.tsp ouput:

import "@typespec/versioning";

using TypeSpec.Versioning;

Showed up when converting the following spec: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/appconfiguration/data-plane/readme.md

cc @joheredi @tadelesh

catalinaperalta commented 3 months ago

Another issue with the versioning support, the enum needs to specify the Azure Core version is depends on.

Current output:

@doc("The available API versions.")
enum Versions {
  v2023_11_01: "2023-11-01",
}

Expected output:

@doc("The available API versions.")
enum Versions {
  @useDependency(Azure.Core.Versions.v1_0_Preview_2)
  v2023_11_01: "2023-11-01",
}