-
Notifications
You must be signed in to change notification settings - Fork 27
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
[TCGC] [ARM] Expected client code on definition model UserAssignedIdentities is Record<UserAssignedIdentity>;
#825
Comments
For swagger, since m4 will convert such model as just a record, I believe for TypeSpec it should be fixed in arm tsp definition. cc: @allenjzhang |
Python has similar issue, too. |
This was changed to keep TypeSpec in sync with the common-types.json which we cannot break https://github.com/Azure/azure-rest-api-specs/blob/b627f6cb13b1d596e7329c6d7aae415519a373c2/specification/common-types/resource-management/v5/managedidentity.json#L9 |
can you explain what you would have been doing here in openapi and why this is different. |
Questions:
|
I assume we should be achieving "to keep the generated SDK unchanged after switched to typespec". And it is too much a cost that we break the SDKs in order to keep swagger "not breaking", not to mention it semantically does not break because it actually represents the same JSON schema. Swagger has a shortage that it cannot write different expressions for "a model with additional properties but no known properties", or "a pure dictionary", because these two things are the same from json's perspective, which is the thing swagger is representing. And speaking of "keeping swagger common-types unchanged", I think it does not have to be as precisely as "it cannot change in a single character", I think it could be fine if the schema it represents is not changed. It is an advantage that typespec now can express differently from the two different SDK APIs (models with additional properties and dictionaries), we should not give it up. Therefore in order to keep our SDK unchanged - and the swagger is "unchanged" originally with some minor representation change, we have the following options:
|
@timotheeguerin public final class ManagedServiceIdentity {
/*
* The identities assigned to this resource by the user.
*/
@JsonProperty(value = "userAssignedIdentities")
private UserAssignedIdentities userAssignedIdentities;
}
public final class UserAssignedIdentities {
/*
* The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.",
*
* Additional properties
*/
@JsonIgnore
private Map<String, UserAssignedIdentity> additionalProperties;
} But previously generating from swagger, Modular4 will interprete the swagger as @Fluent
public final class ManagedServiceIdentity {
/*
* The identities assigned to this resource by the user.
*/
@JsonProperty(value = "userAssignedIdentities")
@JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
private Map<String, UserAssignedIdentity> userAssignedIdentities;
} To solve this:
|
add a playground to show the root cause. |
|
If this issue prevents correct / desired generation of greenfield APIs, then it should be high priority. If this is about not breaking BrownField APIs that convert to TypeSpec, I am not sure it has the same priority. |
Hi @timotheeguerin , woule like to double confirm my understanding: Tsp team tends to change |
It affects greenfield service generation, and almost half of the mgmt-plane services have |
Fixed with hotfix version 0.42.1 for |
typespec-azure-resource-manager
changed the defnition forUserAssignedIdentities
in version0.42
, fromuserAssignedIdentities?: Record<UserAssignedIdentity>;
(code ) tomodel UserAssignedIdentities is Record<UserAssignedIdentity>;
(code)Link Bug #824
For
model A is Record<>
case, TCGC will return modelA
with additional property, this will be potential breaking changes in Mgmt plane, as current generated code based on swagger will useMap
directly, instead of model with additional properties. I think we should align with the current generated code, otherwise there will be many breaking changes. See current code: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-resourcemanager-maps/src/main/java/com/azure/resourcemanager/maps/models/ManagedServiceIdentity.java#L43-L45To solve this:
UserAssignedIdentities
to return it asMap
directly.common-types
have similar definition, but previously M4 seems consider it as dictionary.The text was updated successfully, but these errors were encountered: