Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ $job = @(
"$VANILLA_ARGUMENTS --input-file=vanilla-tests/swagger/special-header.json --namespace=fixtures.specialheader",
"$VANILLA_ARGUMENTS --input-file=vanilla-tests/swagger/required-fields-as-ctor-args-transformation.json --namespace=fixtures.requiredfieldsascotrargstransformation --required-fields-as-ctor-args=true --output-model-immutable --null-byte-array-maps-to-empty-array",
"$VANILLA_ARGUMENTS --input-file=vanilla-tests/swagger/discriminator-enum.json --namespace=fixtures.discriminatorenum"
"$VANILLA_ARGUMENTS --input-file=vanilla-tests/swagger/discriminator-enum.json --namespace=fixtures.discriminatorsetter --models-subpackage=implementation.models --custom-types-subpackage=models --custom-types=Golden"
) | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob

$job | Wait-Job -Timeout 120
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public String getKind() {
* @param kind the kind value to set.
* @return the OperationDetails object itself.
*/
OperationDetails setKind(String kind) {
protected OperationDetails setKind(String kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String getFishType() {
* @param fishType the fishType value to set.
* @return the DotFish object itself.
*/
DotFish setFishType(String fishType) {
protected DotFish setFishType(String fishType) {
this.fishType = fishType;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public String getFishtype() {
* @param fishtype the fishtype value to set.
* @return the Fish object itself.
*/
Fish setFishtype(String fishtype) {
protected Fish setFishtype(String fishtype) {
this.fishtype = fishtype;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public MyKind getKind() {
* @param kind the kind value to set.
* @return the MyBaseType object itself.
*/
MyBaseType setKind(MyKind kind) {
protected MyBaseType setKind(MyKind kind) {
this.kind = kind;
return this;
}
Expand Down
3 changes: 3 additions & 0 deletions fluent-tests/Initialize-Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ $job = @(
# model inherit ErrorResponse
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/196886564583ff59186bd0ef44d923120aaf3f78/specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/NetworkFabrics.json --java.namespace=com.azure.mgmtlitetest.managednetworkfabric",

# polymorphic models in different packages
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=https://github.com/Azure/azure-rest-api-specs/blob/64337ca106a20055b389f9652ea8cf942aa94252/specification/consumption/resource-manager/Microsoft.Consumption/stable/2023-11-01/consumption.json --java.namespace=com.azure.mgmtlitetest.consumption --generate-tests=false"

# schema clean-up
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=./swagger/schema-cleanup.json --java.namespace=com.azure.mgmtlitetest.schemacleanup"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.azure.core.management.SystemData;
import com.azure.core.management.exception.ManagementError;
import com.azure.core.management.exception.ManagementException;
import com.azure.mgmtlitetest.consumption.models.LegacyReservationRecommendation;
import com.azure.mgmttest.appservice.fluent.WebSiteManagementClient;
import com.azure.mgmttest.appservice.models.DefaultErrorResponseErrorException;
import com.azure.mgmttest.authorization.models.GraphError;
Expand Down Expand Up @@ -160,4 +161,8 @@ public void testSharedError() {
ErrorDetails errorDetails = mock(ErrorDetails.class);
errorDetails.getHttpStatusCode();
}

public void testPolymophicSubClass() {
LegacyReservationRecommendation legacyReservationRecommendation = new LegacyReservationRecommendation();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,12 @@ public final void write(ClientModel model, JavaFile javaFile) {
boolean definedByModel = modelDefinesProperty(model, property);
if (hasDerivedTypes && notIncludedInConstructor && definedByModel
&& (settings.isStreamStyleSerialization() || property.isPolymorphicDiscriminator())) {
// Super class and child classes may be in different packages.
// Since we call polymorphic setter in child classes' constructor, we need the setter to be visibility of protected.
methodVisibility = property.isPolymorphicDiscriminator() ? JavaVisibility.Protected : JavaVisibility.PackagePrivate;
generateSetterJavadoc(classBlock, model, property);
addGeneratedAnnotation(classBlock);
classBlock.method(JavaVisibility.PackagePrivate, null,
classBlock.method(methodVisibility, null,
model.getName() + " " + property.getSetterName() + "(" + propertyWireType + " "
+ property.getName() + ")",
methodBlock -> addSetterMethod(propertyWireType, propertyWireType, property, treatAsXml,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public String getKind() {
* @return the AbstractModel object itself.
*/
@Generated
AbstractModel setKind(String kind) {
protected AbstractModel setKind(String kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String getType() {
* @return the Data object itself.
*/
@Generated
Data setType(String type) {
protected Data setType(String type) {
this.type = type;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public String getKind() {
* @return the Fish object itself.
*/
@Generated
Fish setKind(String kind) {
protected Fish setKind(String kind) {
this.kind = kind;
this.updatedProperties.add("kind");
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public DogKind getKind() {
* @return the Dog object itself.
*/
@Generated
Dog setKind(DogKind kind) {
protected Dog setKind(DogKind kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public SnakeKind getKind() {
* @return the Snake object itself.
*/
@Generated
Snake setKind(SnakeKind kind) {
protected Snake setKind(SnakeKind kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public String getKind() {
* @return the Fish object itself.
*/
@Generated
Fish setKind(String kind) {
protected Fish setKind(String kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public String getKind() {
* @return the Bird object itself.
*/
@Generated
Bird setKind(String kind) {
protected Bird setKind(String kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public String getKind() {
* @return the Dinosaur object itself.
*/
@Generated
Dinosaur setKind(String kind) {
protected Dinosaur setKind(String kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public String getKind() {
* @return the ExtendsUnknownAdditionalPropertiesDiscriminated object itself.
*/
@Generated
ExtendsUnknownAdditionalPropertiesDiscriminated setKind(String kind) {
protected ExtendsUnknownAdditionalPropertiesDiscriminated setKind(String kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public String getKind() {
* @return the IsUnknownAdditionalPropertiesDiscriminated object itself.
*/
@Generated
IsUnknownAdditionalPropertiesDiscriminated setKind(String kind) {
protected IsUnknownAdditionalPropertiesDiscriminated setKind(String kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String getFishType() {
* @param fishType the fishType value to set.
* @return the DotFish object itself.
*/
DotFish setFishType(String fishType) {
protected DotFish setFishType(String fishType) {
this.fishType = fishType;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public String getFishtype() {
* @param fishtype the fishtype value to set.
* @return the Fish object itself.
*/
Fish setFishtype(String fishtype) {
protected Fish setFishtype(String fishtype) {
this.fishtype = fishtype;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public MyKind getKind() {
* @param kind the kind value to set.
* @return the MyBaseType object itself.
*/
MyBaseType setKind(MyKind kind) {
protected MyBaseType setKind(MyKind kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public DogKind getKind() {
* @param kind the kind value to set.
* @return the Dog object itself.
*/
Dog setKind(DogKind kind) {
protected Dog setKind(DogKind kind) {
this.kind = kind;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Odatatype getOdataType() {
* @param odataType the odataType value to set.
* @return the MetricAlertCriteria object itself.
*/
MetricAlertCriteria setOdataType(Odatatype odataType) {
protected MetricAlertCriteria setOdataType(Odatatype odataType) {
this.odataType = odataType;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Odatatype getOdataType() {
* @param odataType the odataType value to set.
* @return the MetricAlertCriteria object itself.
*/
MetricAlertCriteria setOdataType(Odatatype odataType) {
protected MetricAlertCriteria setOdataType(Odatatype odataType) {
this.odataType = odataType;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Odatatype getOdataType() {
* @param odataType the odataType value to set.
* @return the MetricAlertCriteria object itself.
*/
MetricAlertCriteria setOdataType(Odatatype odataType) {
protected MetricAlertCriteria setOdataType(Odatatype odataType) {
this.odataType = odataType;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Odatatype getOdataType() {
* @param odataType the odataType value to set.
* @return the MetricAlertCriteria object itself.
*/
MetricAlertCriteria setOdataType(Odatatype odataType) {
protected MetricAlertCriteria setOdataType(Odatatype odataType) {
this.odataType = odataType;
return this;
}
Expand Down
Loading