-
Notifications
You must be signed in to change notification settings - Fork 30
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
Swagger emitter makes up new name for the same model with different schemas #688
Comments
IMO, this is by design. ArmResourcePatch creates a set of schema that are compatible with current RPC guidelines on PATCH. Many legacy APIs used older guidelines, or predated any real enforcement on how PATCH worked. Additionally, there are no controls over how types created from metadata are named (for which there is an existing design issue). For ARM brownfield APIs, though, most APIs should be using ArmCustomPatch, which allows you to specify your own request body schema, here is an example playground showing this . You may need to change the parameterVisibility for the operation if there are required properties in your PATCH schema. |
Hi @markcowl , If I'm understanding correctly, there's a new guideline of the PATCH model schema name right? May I ask which guideline are you referring to? On the other hand, if we were to follow this new guideline for all SDKs, I think we should enforce this in some common places, e.g. compiler or TCGC, instead of this implict behavior that exists only in |
This problem is not new. Prior to TypeSpec, service teams all have different approaches in swagger, some use the root model while some use update model for Patch. I assume you reproduce that faithfully at that time as well, right? |
let's use playground as an example, there are two kinds of model separation logics:
i believe we do not discuss them separately in the meeting. imo, for 1, we should leave as it is. nothing should do for emitter or tcgc. for 2, if we could have consensus across all languages' sdk that we need do it, we could opt it in tcgc, otherwise i don't like such implicitly behavior. and since you all think it is a client behavior, why we do this in openapi and autorest emitter, if not, why http library do it for all emitter? |
Hello @pshao25, |
Clowing this issue in favor of #859 |
Background:
We have some customers that already have their typespec. However, our generators still have some limitations so that we cannot support typespec input. So these customers have to generate swagger first from swagger emitter and then call our generator with swagger input. We expect when our generator is ready to accept typespec input, their original typespec generates same SDK, which means the swagger generated from typespec should be equivalent.
Problem:
There are several scenarios under which the model names in the generated swagger are different from original typespec:
AssetEndpointProfileUpdate
as well as its nested models.Expected behavior:
From this additional trial of "a model with all the optional properties in a patch operation", which don't have any made-up name, I could understand the swagger emitter produces new name because of there are more than one schema needed for the same model. But IMO we should keep the name unchanged and figure out another way to handle the different representation of the same model.
The text was updated successfully, but these errors were encountered: