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

[typespec-autorest] - how to handle empty object ({}) in typespec #2044

Open
4 tasks done
dolauli opened this issue Jan 7, 2025 · 0 comments
Open
4 tasks done

[typespec-autorest] - how to handle empty object ({}) in typespec #2044

dolauli opened this issue Jan 7, 2025 · 0 comments
Assignees

Comments

@dolauli
Copy link

dolauli commented Jan 7, 2025

Clear and concise description of the problem

Currently, typespec-autorest converts an empty object ({}) to {"type": "object"} in Swagger. When using autorest to generate SDKs from these Swaggers, modelerfour converts this to the any type.

For our team (Azure PowerShell), our current strategy is as follows:
For the PowerShell emitter, we follow the same strategy as Java, which is to generate a named empty class.

This conversion results in different code being generated when using autorest with Swagger compared to using typespec with the emitter, which also means future breaking changes when we replace swagger based codegen with typespec based codegen.

Potential solutions:

  1. Don't allow empty object in typespec, use Record< unknown > instead.
  2. Extend Swagger and modelerfour to support named empty classes

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For feature request in the typespec language or core libraries file it in the TypeSpec repo
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants