Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

mgmt azure-json, fix flattened properties in parent class#2817

Merged
XiaofeiCao merged 9 commits into
Azure:mainfrom
XiaofeiCao:mgmt_azure_json_flatten
Jun 18, 2024
Merged

mgmt azure-json, fix flattened properties in parent class#2817
XiaofeiCao merged 9 commits into
Azure:mainfrom
XiaofeiCao:mgmt_azure_json_flatten

Conversation

@XiaofeiCao

@XiaofeiCao XiaofeiCao commented Jun 14, 2024

Copy link
Copy Markdown
Contributor

Regened compute and network, mvn verify passed for both.

@XiaofeiCao
XiaofeiCao marked this pull request as ready for review June 14, 2024 08:51
Comment thread typespec-tests/tspconfig.yaml Outdated
Comment thread javagen/src/main/java/com/azure/autorest/template/ModelTemplate.java Outdated
Comment on lines 558 to +560
*/
public static boolean hasSetter(ClientModelPropertyAccess property, JavaSettings settings) {
// If the property isn't read-only or required and part of the constructor, and it isn't private,
// add a setter.
return !isReadOnlyOrInConstructor(property, settings) && !isPrivateAccess(property);
}

// A property has private access when it is to be flattened.
// Only applies to mgmt, no effect on vanilla or DPG.
private static boolean isPrivateAccess(ClientModelPropertyAccess property) {
boolean privateAccess = false;
// ClientModelPropertyReference never refers to a private access property, so only check ClientModelProperty here.
if (property instanceof ClientModelProperty) {
privateAccess = ((ClientModelProperty) property).getClientFlatten();
}
return privateAccess;
public static boolean needsPublicSetter(ClientModelPropertyAccess property, JavaSettings settings) {
return !isReadOnlyOrInConstructor(property, settings) && !isFlattenedProperty(property);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor to make this method's purpose more clear.

@weidongxu-microsoft

Copy link
Copy Markdown
Member

You may do a follow-up PR to change the default (for Swagger) to true, and see how it works for existing test and the generation action https://github.com/Azure/autorest.java/actions/workflows/fluent-test-gen-all.yml

@XiaofeiCao
XiaofeiCao merged commit ae4e568 into Azure:main Jun 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mgmt azure-json, flatten property in parent class will cause issue in child class in a different package

4 participants