Azure / autorest.python

Extension for AutoRest (https://github.com/Azure/autorest) that generates Python code
MIT License
79 stars 57 forks source link

[MPG][Diff] SDK from Typespec still generate model when model defines no property #2586

Closed msyyc closed 4 months ago

msyyc commented 4 months ago

Compared with SDK between typespec and swagger, typespec definition has a model which has no property:

image

iscai-msft commented 4 months ago

Python is in an interesting situation, where since our models are also a dictionary type, it wouldn't be breaking for us if we took empty models and generated them as dictionaries, then when later properties were added we would generate a model. I don't think tcgc should return empty models as dictionaries, but I could be open to python generating these empty models as dictionaries. However, I still think it's better to not do any magic here: is it breaking mgmt if we just return empty models? I don't believe it is bc our models are dictionaries

msyyc commented 4 months ago

I don't think it is a problem for Python, either. Since we only release SDK from typespec for green field service, it is not breaking for python. I agree that we just keep current logic.

tadelesh commented 4 months ago

opened discussion for TCGC: https://github.com/Azure/typespec-azure/issues/846

tadelesh commented 4 months ago
Swagger m4 Python
"XXX": {"type": "object"} anyObject JSON
"XXX": {} any Any

please help to confirm the python behavior @msyyc @iscai-msft @lmazuel @johanste

TypeSpec TCGC Python
{} anonymous model with no properties Any
model EmptyModel {} named model with no properties class EmptyModel: ...
unknown any Any
msyyc commented 4 months ago

Swagger m4 Python "XXX": {"type": "object"} anyObject JSON "XXX": {} any Any please help to confirm the python behavior @msyyc @iscai-msft @lmazuel @johanste

TypeSpec TCGC Python {} anonymous model with no properties Any model EmptyModel {} named model with no properties class EmptyModel: ... unknown any Any

I confirm current python emitter behavior is same as your comment

msyyc commented 4 months ago

After discussion, we decide to keep current behavior