-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mgmt, fix
SchemaCleanup
for discriminator property (#2774)
* fix SchemaCleanup for discriminator property * re-generate test code --------- Co-authored-by: actions-user <[email protected]>
- Loading branch information
1 parent
892c210
commit 74b9e9f
Showing
11 changed files
with
388 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
typespec-tests/src/main/java/com/cadl/armresourceprovider/models/Dog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// Code generated by Microsoft (R) TypeSpec Code Generator. | ||
|
||
package com.cadl.armresourceprovider.models; | ||
|
||
import com.azure.core.annotation.Fluent; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeId; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
|
||
/** | ||
* Test extensible enum type for discriminator. | ||
*/ | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "kind", defaultImpl = Dog.class, visible = true) | ||
@JsonTypeName("Dog") | ||
@JsonSubTypes({ @JsonSubTypes.Type(name = "golden", value = Golden.class) }) | ||
@Fluent | ||
public class Dog { | ||
/* | ||
* discriminator property | ||
*/ | ||
@JsonTypeId | ||
@JsonProperty(value = "kind", required = true) | ||
private DogKind kind; | ||
|
||
/* | ||
* Weight of the dog | ||
*/ | ||
@JsonProperty(value = "weight", required = true) | ||
private int weight; | ||
|
||
/** | ||
* Creates an instance of Dog class. | ||
*/ | ||
public Dog() { | ||
this.kind = DogKind.fromString("Dog"); | ||
} | ||
|
||
/** | ||
* Get the kind property: discriminator property. | ||
* | ||
* @return the kind value. | ||
*/ | ||
public DogKind kind() { | ||
return this.kind; | ||
} | ||
|
||
/** | ||
* Get the weight property: Weight of the dog. | ||
* | ||
* @return the weight value. | ||
*/ | ||
public int weight() { | ||
return this.weight; | ||
} | ||
|
||
/** | ||
* Set the weight property: Weight of the dog. | ||
* | ||
* @param weight the weight value to set. | ||
* @return the Dog object itself. | ||
*/ | ||
public Dog withWeight(int weight) { | ||
this.weight = weight; | ||
return this; | ||
} | ||
|
||
/** | ||
* Validates the instance. | ||
* | ||
* @throws IllegalArgumentException thrown if the instance is not valid. | ||
*/ | ||
public void validate() { | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
typespec-tests/src/main/java/com/cadl/armresourceprovider/models/DogKind.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// Code generated by Microsoft (R) TypeSpec Code Generator. | ||
|
||
package com.cadl.armresourceprovider.models; | ||
|
||
import com.azure.core.util.ExpandableStringEnum; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import java.util.Collection; | ||
|
||
/** | ||
* extensible enum type for discriminator. | ||
*/ | ||
public final class DogKind extends ExpandableStringEnum<DogKind> { | ||
/** | ||
* Static value golden for DogKind. | ||
*/ | ||
public static final DogKind GOLDEN = fromString("golden"); | ||
|
||
/** | ||
* Creates a new instance of DogKind value. | ||
* | ||
* @deprecated Use the {@link #fromString(String)} factory method. | ||
*/ | ||
@Deprecated | ||
public DogKind() { | ||
} | ||
|
||
/** | ||
* Creates or finds a DogKind from its string representation. | ||
* | ||
* @param name a name to look for. | ||
* @return the corresponding DogKind. | ||
*/ | ||
@JsonCreator | ||
public static DogKind fromString(String name) { | ||
return fromString(name, DogKind.class); | ||
} | ||
|
||
/** | ||
* Gets known DogKind values. | ||
* | ||
* @return known DogKind values. | ||
*/ | ||
public static Collection<DogKind> values() { | ||
return values(DogKind.class); | ||
} | ||
} |
Oops, something went wrong.