forked from loafle/openapi-generator-original
Better inline model resolver to handle inline schema in array item (#12104)
* better support of inline schema in array item * update tests * update samples * regenerate samples * fix allof naming, remove files * add files * update samples * update readme * fix tests * update samples * update samples * add new files * update test spec * add back tests * remove unused files * comment out python test * update js test using own spec * remove files * remove unused files * remove files * remove unused files * better handling of allOf with a single type * comment out go test * remove test_all_of_with_single_ref_single_ref_type.py * fix inline resolver, uncomment go test
This commit is contained in:
@@ -6,6 +6,7 @@ api/openapi.yaml
|
||||
build.gradle
|
||||
build.sbt
|
||||
docs/AdditionalPropertiesClass.md
|
||||
docs/AllOfWithSingleRef.md
|
||||
docs/Animal.md
|
||||
docs/AnotherFakeApi.md
|
||||
docs/ArrayOfArrayOfNumberOnly.md
|
||||
@@ -53,12 +54,12 @@ docs/OuterObjectWithEnumProperty.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/ReadOnlyFirst.md
|
||||
docs/SingleRefType.md
|
||||
docs/SpecialModelName.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/User.md
|
||||
docs/UserApi.md
|
||||
docs/UserType.md
|
||||
git_push.sh
|
||||
gradle.properties
|
||||
gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -88,6 +89,7 @@ src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
|
||||
src/main/java/org/openapitools/client/auth/OAuth.java
|
||||
src/main/java/org/openapitools/client/auth/OAuthFlow.java
|
||||
src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
|
||||
src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java
|
||||
src/main/java/org/openapitools/client/model/Animal.java
|
||||
src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
|
||||
src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
|
||||
@@ -130,7 +132,7 @@ src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java
|
||||
src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java
|
||||
src/main/java/org/openapitools/client/model/Pet.java
|
||||
src/main/java/org/openapitools/client/model/ReadOnlyFirst.java
|
||||
src/main/java/org/openapitools/client/model/SingleRefType.java
|
||||
src/main/java/org/openapitools/client/model/SpecialModelName.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
src/main/java/org/openapitools/client/model/User.java
|
||||
src/main/java/org/openapitools/client/model/UserType.java
|
||||
|
||||
@@ -159,6 +159,7 @@ Class | Method | HTTP request | Description
|
||||
## Documentation for Models
|
||||
|
||||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [AllOfWithSingleRef](docs/AllOfWithSingleRef.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
@@ -201,10 +202,10 @@ Class | Method | HTTP request | Description
|
||||
- [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [SingleRefType](docs/SingleRefType.md)
|
||||
- [SpecialModelName](docs/SpecialModelName.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [User](docs/User.md)
|
||||
- [UserType](docs/UserType.md)
|
||||
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
@@ -1491,7 +1491,6 @@ components:
|
||||
userStatus: 6
|
||||
phone: phone
|
||||
id: 0
|
||||
userType: ""
|
||||
email: email
|
||||
username: username
|
||||
properties:
|
||||
@@ -1515,18 +1514,9 @@ components:
|
||||
description: User Status
|
||||
format: int32
|
||||
type: integer
|
||||
userType:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/UserType'
|
||||
type: object
|
||||
xml:
|
||||
name: User
|
||||
UserType:
|
||||
enum:
|
||||
- admin
|
||||
- user
|
||||
title: UserType
|
||||
type: string
|
||||
Tag:
|
||||
example:
|
||||
name: name
|
||||
@@ -2124,6 +2114,20 @@ components:
|
||||
$ref: '#/components/schemas/Bar'
|
||||
type: array
|
||||
type: object
|
||||
AllOfWithSingleRef:
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
SingleRefType:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/SingleRefType'
|
||||
type: object
|
||||
SingleRefType:
|
||||
enum:
|
||||
- admin
|
||||
- user
|
||||
title: SingleRefType
|
||||
type: string
|
||||
inline_response_default:
|
||||
example:
|
||||
string:
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
# AllOfWithSingleRef
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**username** | **String** | | [optional] |
|
||||
|**singleRefType** | [**SingleRefType**](SingleRefType.md) | | [optional] |
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
# UserType
|
||||
# SingleRefType
|
||||
|
||||
## Enum
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|**password** | **String** | | [optional] |
|
||||
|**phone** | **String** | | [optional] |
|
||||
|**userStatus** | **Integer** | User Status | [optional] |
|
||||
|**userType** | [**UserType**](UserType.md) | | [optional] |
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.SingleRefType;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.util.NoSuchElementException;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* AllOfWithSingleRef
|
||||
*/
|
||||
@JsonPropertyOrder({
|
||||
AllOfWithSingleRef.JSON_PROPERTY_USERNAME,
|
||||
AllOfWithSingleRef.JSON_PROPERTY_SINGLE_REF_TYPE
|
||||
})
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class AllOfWithSingleRef {
|
||||
public static final String JSON_PROPERTY_USERNAME = "username";
|
||||
private String username;
|
||||
|
||||
public static final String JSON_PROPERTY_SINGLE_REF_TYPE = "SingleRefType";
|
||||
private JsonNullable<SingleRefType> singleRefType = JsonNullable.<SingleRefType>undefined();
|
||||
|
||||
public AllOfWithSingleRef() {
|
||||
}
|
||||
|
||||
public AllOfWithSingleRef username(String username) {
|
||||
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get username
|
||||
* @return username
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@ApiModelProperty(value = "")
|
||||
@JsonProperty(JSON_PROPERTY_USERNAME)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_USERNAME)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
||||
public AllOfWithSingleRef singleRefType(SingleRefType singleRefType) {
|
||||
this.singleRefType = JsonNullable.<SingleRefType>of(singleRefType);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get singleRefType
|
||||
* @return singleRefType
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@ApiModelProperty(value = "")
|
||||
@JsonIgnore
|
||||
|
||||
public SingleRefType getSingleRefType() {
|
||||
return singleRefType.orElse(null);
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_SINGLE_REF_TYPE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public JsonNullable<SingleRefType> getSingleRefType_JsonNullable() {
|
||||
return singleRefType;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_SINGLE_REF_TYPE)
|
||||
public void setSingleRefType_JsonNullable(JsonNullable<SingleRefType> singleRefType) {
|
||||
this.singleRefType = singleRefType;
|
||||
}
|
||||
|
||||
public void setSingleRefType(SingleRefType singleRefType) {
|
||||
this.singleRefType = JsonNullable.<SingleRefType>of(singleRefType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
AllOfWithSingleRef allOfWithSingleRef = (AllOfWithSingleRef) o;
|
||||
return Objects.equals(this.username, allOfWithSingleRef.username) &&
|
||||
equalsNullable(this.singleRefType, allOfWithSingleRef.singleRefType);
|
||||
}
|
||||
|
||||
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
||||
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(username, hashCodeNullable(singleRefType));
|
||||
}
|
||||
|
||||
private static <T> int hashCodeNullable(JsonNullable<T> a) {
|
||||
if (a == null) {
|
||||
return 1;
|
||||
}
|
||||
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AllOfWithSingleRef {\n");
|
||||
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
||||
sb.append(" singleRefType: ").append(toIndentedString(singleRefType)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Gets or Sets UserType
|
||||
* Gets or Sets SingleRefType
|
||||
*/
|
||||
public enum UserType {
|
||||
public enum SingleRefType {
|
||||
|
||||
ADMIN("admin"),
|
||||
|
||||
@@ -32,7 +32,7 @@ public enum UserType {
|
||||
|
||||
private String value;
|
||||
|
||||
UserType(String value) {
|
||||
SingleRefType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ public enum UserType {
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static UserType fromValue(String value) {
|
||||
for (UserType b : UserType.values()) {
|
||||
public static SingleRefType fromValue(String value) {
|
||||
for (SingleRefType b : SingleRefType.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
@@ -22,11 +22,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.UserType;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.util.NoSuchElementException;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@@ -41,8 +36,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
User.JSON_PROPERTY_EMAIL,
|
||||
User.JSON_PROPERTY_PASSWORD,
|
||||
User.JSON_PROPERTY_PHONE,
|
||||
User.JSON_PROPERTY_USER_STATUS,
|
||||
User.JSON_PROPERTY_USER_TYPE
|
||||
User.JSON_PROPERTY_USER_STATUS
|
||||
})
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class User {
|
||||
@@ -70,9 +64,6 @@ public class User {
|
||||
public static final String JSON_PROPERTY_USER_STATUS = "userStatus";
|
||||
private Integer userStatus;
|
||||
|
||||
public static final String JSON_PROPERTY_USER_TYPE = "userType";
|
||||
private JsonNullable<UserType> userType = JsonNullable.<UserType>undefined();
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
@@ -292,41 +283,6 @@ public class User {
|
||||
}
|
||||
|
||||
|
||||
public User userType(UserType userType) {
|
||||
this.userType = JsonNullable.<UserType>of(userType);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get userType
|
||||
* @return userType
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
@ApiModelProperty(value = "")
|
||||
@JsonIgnore
|
||||
|
||||
public UserType getUserType() {
|
||||
return userType.orElse(null);
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_USER_TYPE)
|
||||
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
|
||||
|
||||
public JsonNullable<UserType> getUserType_JsonNullable() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
@JsonProperty(JSON_PROPERTY_USER_TYPE)
|
||||
public void setUserType_JsonNullable(JsonNullable<UserType> userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public void setUserType(UserType userType) {
|
||||
this.userType = JsonNullable.<UserType>of(userType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
@@ -343,24 +299,12 @@ public class User {
|
||||
Objects.equals(this.email, user.email) &&
|
||||
Objects.equals(this.password, user.password) &&
|
||||
Objects.equals(this.phone, user.phone) &&
|
||||
Objects.equals(this.userStatus, user.userStatus) &&
|
||||
equalsNullable(this.userType, user.userType);
|
||||
}
|
||||
|
||||
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
||||
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
|
||||
Objects.equals(this.userStatus, user.userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus, hashCodeNullable(userType));
|
||||
}
|
||||
|
||||
private static <T> int hashCodeNullable(JsonNullable<T> a) {
|
||||
if (a == null) {
|
||||
return 1;
|
||||
}
|
||||
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
|
||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -375,7 +319,6 @@ public class User {
|
||||
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
||||
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
||||
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
||||
sb.append(" userType: ").append(toIndentedString(userType)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.SingleRefType;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.util.NoSuchElementException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for AllOfWithSingleRef
|
||||
*/
|
||||
public class AllOfWithSingleRefTest {
|
||||
private final AllOfWithSingleRef model = new AllOfWithSingleRef();
|
||||
|
||||
/**
|
||||
* Model tests for AllOfWithSingleRef
|
||||
*/
|
||||
@Test
|
||||
public void testAllOfWithSingleRef() {
|
||||
// TODO: test AllOfWithSingleRef
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'username'
|
||||
*/
|
||||
@Test
|
||||
public void usernameTest() {
|
||||
// TODO: test username
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'singleRefType'
|
||||
*/
|
||||
@Test
|
||||
public void singleRefTypeTest() {
|
||||
// TODO: test singleRefType
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,15 +19,15 @@ import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for UserType
|
||||
* Model tests for SingleRefType
|
||||
*/
|
||||
public class UserTypeTest {
|
||||
public class SingleRefTypeTest {
|
||||
/**
|
||||
* Model tests for UserType
|
||||
* Model tests for SingleRefType
|
||||
*/
|
||||
@Test
|
||||
public void testUserType() {
|
||||
// TODO: test UserType
|
||||
public void testSingleRefType() {
|
||||
// TODO: test SingleRefType
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user