Skip to content
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

The new swagger generated using TSP contains extra response code #5076

Open
melina5656 opened this issue Feb 14, 2025 · 0 comments
Open

The new swagger generated using TSP contains extra response code #5076

melina5656 opened this issue Feb 14, 2025 · 0 comments
Labels
openapi-to-tsp Tracks OpenAPI to Cadl converter issues

Comments

@melina5656
Copy link
Member

Describe the bug

I generated the TSP project for keyvault using the command "npx TSP client convert - swagger readme [path to readme. md] - arm - fully compatible The generated TSP project contains the following code:

  /**
   * Permanently deletes the specified managed HSM.
   */
  #suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
  @action("purge")
  @operationId("ManagedHsms_PurgeDeleted")
  purgeDeleted is ArmResourceActionAsync<
    DeletedManagedHsm,
    void,
    void,
    BaseParameters = Azure.ResourceManager.Foundations.SubscriptionBaseParameters
  >;

The swagger generated using this code contains two response codes: 202 and 204. But in the original swagger, the response code should only be 202, so I tried to modify void to AcceptedResponse or ArmAcceptedLroResponse, but this modification would result in an error: Error: Multiple responses are not supported.
So I tried another modification method, changing ArmResourceActionAsync to ArmResourceActionAsyncBase.

 /**
   * Permanently deletes the specified managed HSM.
   */
  #suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
  @action("purge")
  @operationId("ManagedHsms_PurgeDeleted")
  purgeDeleted is ArmResourceActionAsyncBase<
    DeletedManagedHsm,
    void,
    Response = ArmAcceptedLroResponse,
    BaseParameters = Azure.ResourceManager.Foundations.SubscriptionBaseParameters
  >;

Is this modification reasonable?

The original swagger:
https://github.com/Azure/azure-rest-api-specs/blob/main/specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2024-11-01/managedHsm.json#L510

Expected behavior
The generated swagger only contains 202

Actual behavior
The generated swagger contains 202 and 204

@pshao25 pshao25 added the openapi-to-tsp Tracks OpenAPI to Cadl converter issues label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openapi-to-tsp Tracks OpenAPI to Cadl converter issues
Projects
None yet
Development

No branches or pull requests

2 participants