fix ref to allOf wrapper, add tests (#19986)

This commit is contained in:
William Cheng
2024-10-29 10:24:59 +08:00
committed by GitHub
parent 891698784d
commit 48e8375166
6 changed files with 117 additions and 2 deletions

View File

@@ -2689,12 +2689,22 @@ components:
$ref: '#/components/schemas/Scalar'
minItems: 1
type: array
AllOfRefToString:
allOf:
- $ref: '#/components/schemas/OuterString'
description: testing allOf with a ref to string
NewPet:
properties:
id:
format: int64
type: integer
x-is-unique: true
category_ref_to_inline_allof_string:
$ref: '#/components/schemas/AllOfRefToString'
category_inline_allof_string:
allOf:
- $ref: '#/components/schemas/OuterString'
description: testing allOf with a ref to string
category_inline_allof:
$ref: '#/components/schemas/NewPet_category_inline_allof'
category_allOf_ref:

View File

@@ -8,6 +8,8 @@
| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**id** | **Long** | | [optional] |
|**categoryRefToInlineAllofString** | **String** | testing allOf with a ref to string | [optional] |
|**categoryInlineAllofString** | **String** | testing allOf with a ref to string | [optional] |
|**categoryInlineAllof** | [**NewPetCategoryInlineAllof**](NewPetCategoryInlineAllof.md) | | [optional] |
|**categoryAllOfRef** | [**Category**](Category.md) | | [optional] |
|**categoryAllOfRefDescription** | [**Category**](Category.md) | Adding description to property using allOf | [optional] |

View File

@@ -60,6 +60,16 @@ public class NewPet {
@javax.annotation.Nullable
private Long id;
public static final String SERIALIZED_NAME_CATEGORY_REF_TO_INLINE_ALLOF_STRING = "category_ref_to_inline_allof_string";
@SerializedName(SERIALIZED_NAME_CATEGORY_REF_TO_INLINE_ALLOF_STRING)
@javax.annotation.Nullable
private String categoryRefToInlineAllofString;
public static final String SERIALIZED_NAME_CATEGORY_INLINE_ALLOF_STRING = "category_inline_allof_string";
@SerializedName(SERIALIZED_NAME_CATEGORY_INLINE_ALLOF_STRING)
@javax.annotation.Nullable
private String categoryInlineAllofString;
public static final String SERIALIZED_NAME_CATEGORY_INLINE_ALLOF = "category_inline_allof";
@SerializedName(SERIALIZED_NAME_CATEGORY_INLINE_ALLOF)
@javax.annotation.Nullable
@@ -183,6 +193,44 @@ public class NewPet {
}
public NewPet categoryRefToInlineAllofString(@javax.annotation.Nullable String categoryRefToInlineAllofString) {
this.categoryRefToInlineAllofString = categoryRefToInlineAllofString;
return this;
}
/**
* testing allOf with a ref to string
* @return categoryRefToInlineAllofString
*/
@javax.annotation.Nullable
public String getCategoryRefToInlineAllofString() {
return categoryRefToInlineAllofString;
}
public void setCategoryRefToInlineAllofString(@javax.annotation.Nullable String categoryRefToInlineAllofString) {
this.categoryRefToInlineAllofString = categoryRefToInlineAllofString;
}
public NewPet categoryInlineAllofString(@javax.annotation.Nullable String categoryInlineAllofString) {
this.categoryInlineAllofString = categoryInlineAllofString;
return this;
}
/**
* testing allOf with a ref to string
* @return categoryInlineAllofString
*/
@javax.annotation.Nullable
public String getCategoryInlineAllofString() {
return categoryInlineAllofString;
}
public void setCategoryInlineAllofString(@javax.annotation.Nullable String categoryInlineAllofString) {
this.categoryInlineAllofString = categoryInlineAllofString;
}
public NewPet categoryInlineAllof(@javax.annotation.Nullable NewPetCategoryInlineAllof categoryInlineAllof) {
this.categoryInlineAllof = categoryInlineAllof;
return this;
@@ -398,6 +446,8 @@ public class NewPet {
}
NewPet newPet = (NewPet) o;
return Objects.equals(this.id, newPet.id) &&
Objects.equals(this.categoryRefToInlineAllofString, newPet.categoryRefToInlineAllofString) &&
Objects.equals(this.categoryInlineAllofString, newPet.categoryInlineAllofString) &&
Objects.equals(this.categoryInlineAllof, newPet.categoryInlineAllof) &&
Objects.equals(this.categoryAllOfRef, newPet.categoryAllOfRef) &&
Objects.equals(this.categoryAllOfRefDescription, newPet.categoryAllOfRefDescription) &&
@@ -411,7 +461,7 @@ public class NewPet {
@Override
public int hashCode() {
return Objects.hash(id, categoryInlineAllof, categoryAllOfRef, categoryAllOfRefDescription, categoryAllOfRefDescriptionReadonly, name, photoUrls, tags, status, additionalProperties);
return Objects.hash(id, categoryRefToInlineAllofString, categoryInlineAllofString, categoryInlineAllof, categoryAllOfRef, categoryAllOfRefDescription, categoryAllOfRefDescriptionReadonly, name, photoUrls, tags, status, additionalProperties);
}
@Override
@@ -419,6 +469,8 @@ public class NewPet {
StringBuilder sb = new StringBuilder();
sb.append("class NewPet {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" categoryRefToInlineAllofString: ").append(toIndentedString(categoryRefToInlineAllofString)).append("\n");
sb.append(" categoryInlineAllofString: ").append(toIndentedString(categoryInlineAllofString)).append("\n");
sb.append(" categoryInlineAllof: ").append(toIndentedString(categoryInlineAllof)).append("\n");
sb.append(" categoryAllOfRef: ").append(toIndentedString(categoryAllOfRef)).append("\n");
sb.append(" categoryAllOfRefDescription: ").append(toIndentedString(categoryAllOfRefDescription)).append("\n");
@@ -451,6 +503,8 @@ public class NewPet {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet<String>();
openapiFields.add("id");
openapiFields.add("category_ref_to_inline_allof_string");
openapiFields.add("category_inline_allof_string");
openapiFields.add("category_inline_allof");
openapiFields.add("category_allOf_ref");
openapiFields.add("category_allOf_ref_description");
@@ -486,6 +540,12 @@ public class NewPet {
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("category_ref_to_inline_allof_string") != null && !jsonObj.get("category_ref_to_inline_allof_string").isJsonNull()) && !jsonObj.get("category_ref_to_inline_allof_string").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `category_ref_to_inline_allof_string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category_ref_to_inline_allof_string").toString()));
}
if ((jsonObj.get("category_inline_allof_string") != null && !jsonObj.get("category_inline_allof_string").isJsonNull()) && !jsonObj.get("category_inline_allof_string").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `category_inline_allof_string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category_inline_allof_string").toString()));
}
// validate the optional field `category_inline_allof`
if (jsonObj.get("category_inline_allof") != null && !jsonObj.get("category_inline_allof").isJsonNull()) {
NewPetCategoryInlineAllof.validateJsonElement(jsonObj.get("category_inline_allof"));