From 25c0ffe834f84837382164243aabf7a11a67befa Mon Sep 17 00:00:00 2001 From: Martin <2026226+martin-mfg@users.noreply.github.com> Date: Sun, 10 Sep 2023 15:58:14 +0200 Subject: [PATCH 1/7] add nullable case to spring test spec --- ...ith-fake-endpoints-models-for-testing.yaml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml index 6814753bd2fa..cbd88e8adfd8 100644 --- a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml @@ -924,6 +924,23 @@ paths: responses: "200": description: successful operation + /fake/nullable: + post: + tags: + - fake + summary: test nullable parent property + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation /fake/body-with-query-params: put: tags: @@ -1743,6 +1760,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + type: object + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - ChildWithNullable + nullableProperty: + type: string + nullable: true + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - type: object + properties: + otherProperty: + type: string StringBooleanMap: additionalProperties: type: boolean From 5c2371d13679f29d1d5fd0098d022a1f78850f3d Mon Sep 17 00:00:00 2001 From: Martin <2026226+martin-mfg@users.noreply.github.com> Date: Sun, 10 Sep 2023 16:05:25 +0200 Subject: [PATCH 2/7] generate samples for changed spring input --- .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 19 ++ .../openapitools/model/ChildWithNullable.java | 111 ++++++++++++ .../model/ParentWithNullable.java | 163 +++++++++++++++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 19 ++ .../model/ChildWithNullableDto.java | 113 ++++++++++++ .../model/ParentWithNullableDto.java | 164 +++++++++++++++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 27 +++ .../openapitools/model/ChildWithNullable.java | 114 ++++++++++++ .../model/ParentWithNullable.java | 167 +++++++++++++++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 29 +++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 14 ++ .../openapitools/model/ChildWithNullable.java | 114 ++++++++++++ .../model/ParentWithNullable.java | 167 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 114 ++++++++++++ .../model/ParentWithNullable.java | 167 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 27 +++ .../openapitools/model/ChildWithNullable.java | 114 ++++++++++++ .../model/ParentWithNullable.java | 167 +++++++++++++++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 101 +++++++++++ .../model/ParentWithNullable.java | 153 ++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 115 ++++++++++++ .../model/ParentWithNullable.java | 168 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 29 +++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 14 ++ .../openapitools/model/ChildWithNullable.java | 115 ++++++++++++ .../model/ParentWithNullable.java | 168 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 29 +++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 14 ++ .../openapitools/model/ChildWithNullable.java | 115 ++++++++++++ .../model/ParentWithNullable.java | 168 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 115 ++++++++++++ .../model/ParentWithNullable.java | 168 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 31 ++++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 17 ++ .../openapitools/model/ChildWithNullable.java | 115 ++++++++++++ .../model/ParentWithNullable.java | 168 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++++ .../openapitools/api/FakeApiController.java | 1 + .../org/openapitools/api/FakeApiDelegate.java | 17 ++ .../openapitools/model/ChildWithNullable.java | 115 ++++++++++++ .../model/ParentWithNullable.java | 168 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++++ .../openapitools/api/FakeApiController.java | 1 + .../openapitools/model/ChildWithNullable.java | 115 ++++++++++++ .../model/ParentWithNullable.java | 168 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../.openapi-generator/FILES | 2 + .../openapitools/virtualan/api/FakeApi.java | 31 ++++ .../virtualan/api/FakeApiController.java | 1 + .../virtualan/model/ChildWithNullable.java | 114 ++++++++++++ .../virtualan/model/ParentWithNullable.java | 167 +++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ .../springboot/.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 30 ++++ .../openapitools/api/FakeApiController.java | 1 + .../model/ChildWithNullableDto.java | 117 ++++++++++++ .../model/ParentWithNullableDto.java | 169 ++++++++++++++++++ .../src/main/resources/openapi.yaml | 40 +++++ 93 files changed, 5528 insertions(+) create mode 100644 samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java create mode 100644 samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java create mode 100644 samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java create mode 100644 samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java create mode 100644 samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java create mode 100644 samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java diff --git a/samples/client/petstore/spring-http-interface-reactive/.openapi-generator/FILES b/samples/client/petstore/spring-http-interface-reactive/.openapi-generator/FILES index bf0cf4464f99..00c83508cbe9 100644 --- a/samples/client/petstore/spring-http-interface-reactive/.openapi-generator/FILES +++ b/samples/client/petstore/spring-http-interface-reactive/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -45,6 +46,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/api/FakeApi.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/api/FakeApi.java index 723d5e8c348c..537d7e748a60 100644 --- a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -321,6 +322,24 @@ Mono> testJsonFormData( ); + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @HttpExchange( + method = "POST", + value = "/fake/nullable", + accept = "application/json", + contentType = "application/json" + ) + Mono> testNullable( + @RequestBody Mono childWithNullable + ); + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..190a9033d2d8 --- /dev/null +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,111 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.constraints.NotNull; + + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..f02a9851d667 --- /dev/null +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,163 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.constraints.NotNull; + + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/client/petstore/spring-http-interface/.openapi-generator/FILES b/samples/client/petstore/spring-http-interface/.openapi-generator/FILES index d06abb86e88d..e2cf92c77d63 100644 --- a/samples/client/petstore/spring-http-interface/.openapi-generator/FILES +++ b/samples/client/petstore/spring-http-interface/.openapi-generator/FILES @@ -24,6 +24,7 @@ src/main/java/org/openapitools/model/BigCatDto.java src/main/java/org/openapitools/model/CapitalizationDto.java src/main/java/org/openapitools/model/CatDto.java src/main/java/org/openapitools/model/CategoryDto.java +src/main/java/org/openapitools/model/ChildWithNullableDto.java src/main/java/org/openapitools/model/ClassModelDto.java src/main/java/org/openapitools/model/ClientDto.java src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -44,6 +45,7 @@ src/main/java/org/openapitools/model/NumberOnlyDto.java src/main/java/org/openapitools/model/OrderDto.java src/main/java/org/openapitools/model/OuterCompositeDto.java src/main/java/org/openapitools/model/OuterEnumDto.java +src/main/java/org/openapitools/model/ParentWithNullableDto.java src/main/java/org/openapitools/model/PetDto.java src/main/java/org/openapitools/model/ReadOnlyFirstDto.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNamesDto.java diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/api/FakeApi.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/api/FakeApi.java index cd1c35c6adbf..de4747c2d4c0 100644 --- a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullableDto; import org.openapitools.model.ClientDto; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClassDto; @@ -317,6 +318,24 @@ ResponseEntity testJsonFormData( ); + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullableDto request body (required) + * @return successful operation (status code 200) + */ + @HttpExchange( + method = "POST", + value = "/fake/nullable", + accept = "application/json", + contentType = "application/json" + ) + ResponseEntity testNullable( + @RequestBody ChildWithNullableDto childWithNullableDto + ); + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java new file mode 100644 index 000000000000..8c3fa92f59a4 --- /dev/null +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java @@ -0,0 +1,113 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullableDto; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.constraints.NotNull; + + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * ChildWithNullableDto + */ + + +@JsonTypeName("ChildWithNullable") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullableDto extends ParentWithNullableDto { + + private String otherProperty; + + public ChildWithNullableDto otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullableDto type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullableDto nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullableDto childWithNullable = (ChildWithNullableDto) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullableDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java new file mode 100644 index 000000000000..85c1e88f3cc8 --- /dev/null +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java @@ -0,0 +1,164 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import jakarta.validation.constraints.NotNull; + + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * ParentWithNullableDto + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullableDto.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullableDto { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullableDto type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullableDto nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullableDto parentWithNullable = (ParentWithNullableDto) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullableDto {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES index 9446e6b01873..d70f392ac96e 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/.openapi-generator/FILES @@ -22,6 +22,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -44,6 +45,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java index 9d8480d8fdeb..72d45bdee9e3 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -451,6 +452,32 @@ ResponseEntity testJsonFormData( ); + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = "application/json" + ) + ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ); + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..c3cca4b9a770 --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..c1d7117e7f6c --- /dev/null +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES index 79b659e26790..ef8ff140b423 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES +++ b/samples/openapi3/server/petstore/springboot-delegate/.openapi-generator/FILES @@ -40,6 +40,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -62,6 +63,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java index ae12a17eb3bd..47db3311b8aa 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -506,6 +507,34 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return getDelegate().testNullable(childWithNullable); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java index b88f61719554..c0125b8d57d3 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java index c8b380f33c01..e04c34be3b06 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -299,6 +300,19 @@ default ResponseEntity testJsonFormData(String param, } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default ResponseEntity testNullable(ChildWithNullable childWithNullable) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..c3cca4b9a770 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..c1d7117e7f6c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES index d1488c7ee6cf..7def1540283e 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,6 +57,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java index 8933208533ce..48b273fb6fce 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -551,6 +552,35 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java index 9121a3951829..4f901db76d70 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..c3cca4b9a770 --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..c1d7117e7f6c --- /dev/null +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/.openapi-generator/FILES b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/.openapi-generator/FILES index 13cadadce134..1a5883abc128 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/.openapi-generator/FILES +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/.openapi-generator/FILES @@ -23,6 +23,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -45,6 +46,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/api/FakeApi.java index 1b881b2651d9..173ca2a64051 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -478,6 +479,32 @@ ResponseEntity testJsonFormData( ) throws Exception; + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) throws Exception; + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..c3cca4b9a770 --- /dev/null +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..c1d7117e7f6c --- /dev/null +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES b/samples/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES index 8360f1fc4d3f..56a788d90d4d 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,6 +57,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java index 2223eaece425..ac40279c6702 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -544,6 +545,35 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java index 9121a3951829..4f901db76d70 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..68c0c1261cce --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,101 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.openapitools.model.ParentWithNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(otherProperty, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..8c57b73ad6b6 --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,153 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private String nullableProperty = null; + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public String getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + Objects.equals(this.nullableProperty, parentWithNullable.nullableProperty); + } + + @Override + public int hashCode() { + return Objects.hash(type, nullableProperty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-beanvalidation/.openapi-generator/FILES b/samples/server/petstore/springboot-beanvalidation/.openapi-generator/FILES index cf841650425e..05cb1e1cc0a7 100644 --- a/samples/server/petstore/springboot-beanvalidation/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-beanvalidation/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,6 +57,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java index 2223eaece425..ac40279c6702 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -544,6 +545,35 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java index 9121a3951829..4f901db76d70 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..5a7df76b879b --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..359a889813fc --- /dev/null +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-beanvalidation/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-beanvalidation/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-delegate-j8/.openapi-generator/FILES b/samples/server/petstore/springboot-delegate-j8/.openapi-generator/FILES index fea9a8ab4926..4cd633acf1ac 100644 --- a/samples/server/petstore/springboot-delegate-j8/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-delegate-j8/.openapi-generator/FILES @@ -40,6 +40,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -62,6 +63,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java index b06abb7467f8..601013398bea 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -499,6 +500,34 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return getDelegate().testNullable(childWithNullable); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiController.java index b88f61719554..c0125b8d57d3 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java index c8b380f33c01..e04c34be3b06 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -299,6 +300,19 @@ default ResponseEntity testJsonFormData(String param, } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default ResponseEntity testNullable(ChildWithNullable childWithNullable) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..5a7df76b879b --- /dev/null +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..359a889813fc --- /dev/null +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-delegate-j8/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-delegate-j8/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-delegate/.openapi-generator/FILES b/samples/server/petstore/springboot-delegate/.openapi-generator/FILES index fea9a8ab4926..4cd633acf1ac 100644 --- a/samples/server/petstore/springboot-delegate/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-delegate/.openapi-generator/FILES @@ -40,6 +40,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -62,6 +63,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java index b06abb7467f8..601013398bea 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -499,6 +500,34 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return getDelegate().testNullable(childWithNullable); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java index b88f61719554..c0125b8d57d3 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java index c8b380f33c01..e04c34be3b06 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -299,6 +300,19 @@ default ResponseEntity testJsonFormData(String param, } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default ResponseEntity testNullable(ChildWithNullable childWithNullable) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..5a7df76b879b --- /dev/null +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..359a889813fc --- /dev/null +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-delegate/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-delegate/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/server/petstore/springboot-delegate/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-delegate/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES b/samples/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES index 8360f1fc4d3f..56a788d90d4d 100644 --- a/samples/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-implicitHeaders/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,6 +57,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java index 3cb28e2bcc1a..21a90acea537 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -544,6 +545,35 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java index 9121a3951829..4f901db76d70 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..5a7df76b879b --- /dev/null +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..359a889813fc --- /dev/null +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/FILES b/samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/FILES index 6e18cfc78747..27b0a42adb34 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/FILES @@ -39,6 +39,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -61,6 +62,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java index c007639214d9..c9470e15a9f6 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java @@ -7,6 +7,7 @@ import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -532,6 +533,36 @@ default Mono testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + @ResponseStatus(HttpStatus.OK) + default Mono testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody Mono childWithNullable, + @ApiIgnore final ServerWebExchange exchange + ) { + return getDelegate().testNullable(childWithNullable, exchange); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiController.java index 159a5330fcb7..26840ffb0ead 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiController.java @@ -2,6 +2,7 @@ import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiDelegate.java index 5392a1a9baf9..e606ecfe26a4 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -2,6 +2,7 @@ import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -339,6 +340,22 @@ default Mono testJsonFormData(String param, } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default Mono testNullable(Mono childWithNullable, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(childWithNullable).then(Mono.empty()); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..5a7df76b879b --- /dev/null +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..359a889813fc --- /dev/null +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-reactive/.openapi-generator/FILES b/samples/server/petstore/springboot-reactive/.openapi-generator/FILES index 6e18cfc78747..27b0a42adb34 100644 --- a/samples/server/petstore/springboot-reactive/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-reactive/.openapi-generator/FILES @@ -39,6 +39,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -61,6 +62,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java index a957c78388c6..1ce75cf75866 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApi.java @@ -7,6 +7,7 @@ import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -518,6 +519,35 @@ default Mono> testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default Mono> testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody Mono childWithNullable, + @ApiIgnore final ServerWebExchange exchange + ) { + return getDelegate().testNullable(childWithNullable, exchange); + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java index ea2bb6629564..cb1695a319e1 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiController.java @@ -2,6 +2,7 @@ import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java index 8fa3ade10771..e1303c319373 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java @@ -2,6 +2,7 @@ import springfox.documentation.annotations.ApiIgnore; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -340,6 +341,22 @@ default Mono> testJsonFormData(String param, } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + * @see FakeApi#testNullable + */ + default Mono> testNullable(Mono childWithNullable, + ServerWebExchange exchange) { + Mono result = Mono.empty(); + exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED); + return result.then(childWithNullable).then(Mono.empty()); + + } + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..5a7df76b879b --- /dev/null +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..359a889813fc --- /dev/null +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-reactive/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-useoptional/.openapi-generator/FILES b/samples/server/petstore/springboot-useoptional/.openapi-generator/FILES index 8360f1fc4d3f..56a788d90d4d 100644 --- a/samples/server/petstore/springboot-useoptional/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-useoptional/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/model/BigCat.java src/main/java/org/openapitools/model/Capitalization.java src/main/java/org/openapitools/model/Cat.java src/main/java/org/openapitools/model/Category.java +src/main/java/org/openapitools/model/ChildWithNullable.java src/main/java/org/openapitools/model/ClassModel.java src/main/java/org/openapitools/model/Client.java src/main/java/org/openapitools/model/ContainerDefaultValue.java @@ -56,6 +57,7 @@ src/main/java/org/openapitools/model/NumberOnly.java src/main/java/org/openapitools/model/Order.java src/main/java/org/openapitools/model/OuterComposite.java src/main/java/org/openapitools/model/OuterEnum.java +src/main/java/org/openapitools/model/ParentWithNullable.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/ReadOnlyFirst.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java index eb001348b4e9..19bcbf722b64 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; @@ -544,6 +545,35 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java index 9121a3951829..4f901db76d70 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.api; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..5a7df76b879b --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,115 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..359a889813fc --- /dev/null +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,168 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-useoptional/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot-virtualan/.openapi-generator/FILES b/samples/server/petstore/springboot-virtualan/.openapi-generator/FILES index 7d38d2b7a005..4941895d13f6 100644 --- a/samples/server/petstore/springboot-virtualan/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-virtualan/.openapi-generator/FILES @@ -34,6 +34,7 @@ src/main/java/org/openapitools/virtualan/model/BigCat.java src/main/java/org/openapitools/virtualan/model/Capitalization.java src/main/java/org/openapitools/virtualan/model/Cat.java src/main/java/org/openapitools/virtualan/model/Category.java +src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java src/main/java/org/openapitools/virtualan/model/ClassModel.java src/main/java/org/openapitools/virtualan/model/Client.java src/main/java/org/openapitools/virtualan/model/ContainerDefaultValue.java @@ -56,6 +57,7 @@ src/main/java/org/openapitools/virtualan/model/NumberOnly.java src/main/java/org/openapitools/virtualan/model/Order.java src/main/java/org/openapitools/virtualan/model/OuterComposite.java src/main/java/org/openapitools/virtualan/model/OuterEnum.java +src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java src/main/java/org/openapitools/virtualan/model/Pet.java src/main/java/org/openapitools/virtualan/model/ReadOnlyFirst.java src/main/java/org/openapitools/virtualan/model/ResponseObjectWithDifferentFieldNames.java diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java index 8f23a56bccb0..9410ee5fea14 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApi.java @@ -6,6 +6,7 @@ package org.openapitools.virtualan.api; import java.math.BigDecimal; +import org.openapitools.virtualan.model.ChildWithNullable; import org.openapitools.virtualan.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.virtualan.model.FileSchemaTestClass; @@ -568,6 +569,36 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullable request body (required) + * @return successful operation (status code 200) + */ + @ApiVirtual + @Operation( + operationId = "testNullable", + summary = "test nullable parent property", + description = "", + tags = { "fake" }, + responses = { + @ApiResponse(responseCode = "200", description = "successful operation") + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @Parameter(name = "ChildWithNullable", description = "request body", required = true) @Valid @RequestBody ChildWithNullable childWithNullable + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApiController.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApiController.java index 6745966de43f..2073874d33cc 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApiController.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/api/FakeApiController.java @@ -1,6 +1,7 @@ package org.openapitools.virtualan.api; import java.math.BigDecimal; +import org.openapitools.virtualan.model.ChildWithNullable; import org.openapitools.virtualan.model.Client; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.virtualan.model.FileSchemaTestClass; diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java new file mode 100644 index 000000000000..5da8631d7b07 --- /dev/null +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java @@ -0,0 +1,114 @@ +package org.openapitools.virtualan.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.virtualan.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullable + */ + + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @Schema(name = "otherProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullable type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullable nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java new file mode 100644 index 000000000000..e38b43c30ea7 --- /dev/null +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java @@ -0,0 +1,167 @@ +package org.openapitools.virtualan.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullable + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullable { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @Schema(name = "type", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @Schema(name = "nullableProperty", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot-virtualan/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-virtualan/src/main/resources/openapi.yaml index ae88e043d50b..f4e143554fb2 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-virtualan/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/springboot/.openapi-generator/FILES b/samples/server/petstore/springboot/.openapi-generator/FILES index 857b86d938fc..8a0be4b78a6d 100644 --- a/samples/server/petstore/springboot/.openapi-generator/FILES +++ b/samples/server/petstore/springboot/.openapi-generator/FILES @@ -35,6 +35,7 @@ src/main/java/org/openapitools/model/BigCatDto.java src/main/java/org/openapitools/model/CapitalizationDto.java src/main/java/org/openapitools/model/CatDto.java src/main/java/org/openapitools/model/CategoryDto.java +src/main/java/org/openapitools/model/ChildWithNullableDto.java src/main/java/org/openapitools/model/ClassModelDto.java src/main/java/org/openapitools/model/ClientDto.java src/main/java/org/openapitools/model/ContainerDefaultValueDto.java @@ -55,6 +56,7 @@ src/main/java/org/openapitools/model/NumberOnlyDto.java src/main/java/org/openapitools/model/OrderDto.java src/main/java/org/openapitools/model/OuterCompositeDto.java src/main/java/org/openapitools/model/OuterEnumDto.java +src/main/java/org/openapitools/model/ParentWithNullableDto.java src/main/java/org/openapitools/model/PetDto.java src/main/java/org/openapitools/model/ReadOnlyFirstDto.java src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNamesDto.java diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java index e4f57a07a066..72ec8da42af4 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApi.java @@ -7,6 +7,7 @@ import org.openapitools.model.ApiResponseDto; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullableDto; import org.openapitools.model.ClientDto; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClassDto; @@ -544,6 +545,35 @@ default ResponseEntity testJsonFormData( } + /** + * POST /fake/nullable : test nullable parent property + * + * + * @param childWithNullableDto request body (required) + * @return successful operation (status code 200) + */ + @ApiOperation( + tags = { "fake" }, + value = "test nullable parent property", + nickname = "testNullable", + notes = "" + ) + @ApiResponses({ + @ApiResponse(code = 200, message = "successful operation") + }) + @RequestMapping( + method = RequestMethod.POST, + value = "/fake/nullable", + consumes = { "application/json" } + ) + default ResponseEntity testNullable( + @ApiParam(value = "request body", required = true) @Valid @RequestBody ChildWithNullableDto childWithNullableDto + ) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** * PUT /fake/test-query-parameters * To test the collection format in query parameters diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApiController.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApiController.java index ad3ca0f55b62..47ca2590812e 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApiController.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/api/FakeApiController.java @@ -2,6 +2,7 @@ import org.openapitools.model.ApiResponseDto; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullableDto; import org.openapitools.model.ClientDto; import org.springframework.format.annotation.DateTimeFormat; import org.openapitools.model.FileSchemaTestClassDto; diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java new file mode 100644 index 000000000000..32f4b016fa0e --- /dev/null +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java @@ -0,0 +1,117 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.model.ParentWithNullableDto; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ChildWithNullableDto + */ + + +@JsonTypeName("ChildWithNullable") +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ChildWithNullableDto extends ParentWithNullableDto { + + private String otherProperty; + + public ChildWithNullableDto otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("otherProperty") + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + public ChildWithNullableDto type(TypeEnum type) { + super.setType(type); + return this; + } + + public ChildWithNullableDto nullableProperty(String nullableProperty) { + super.setNullableProperty(nullableProperty); + return this; + } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullableDto childWithNullable = (ChildWithNullableDto) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullableDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java new file mode 100644 index 000000000000..a06f9c5272c5 --- /dev/null +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java @@ -0,0 +1,169 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.time.OffsetDateTime; +import javax.validation.Valid; +import javax.validation.constraints.*; + + +import java.util.*; +import javax.annotation.Generated; + +/** + * ParentWithNullableDto + */ + +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullableDto.class, name = "ChildWithNullable") +}) + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") +public class ParentWithNullableDto { + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private TypeEnum type; + + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullableDto type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + + @ApiModelProperty(value = "") + @JsonProperty("type") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullableDto nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + + @ApiModelProperty(value = "") + @JsonProperty("nullableProperty") + public JsonNullable getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullableDto parentWithNullable = (ParentWithNullableDto) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullableDto {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/springboot/src/main/resources/openapi.yaml b/samples/server/petstore/springboot/src/main/resources/openapi.yaml index 9d672d873dda..6ca7e1db010d 100644 --- a/samples/server/petstore/springboot/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot/src/main/resources/openapi.yaml @@ -986,6 +986,27 @@ paths: x-accepts: application/json x-tags: - tag: fake + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json + x-tags: + - tag: fake /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1883,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean From af078a0079756db97adbf8e88f63b688e66de6b4 Mon Sep 17 00:00:00 2001 From: Martin <2026226+martin-mfg@users.noreply.github.com> Date: Sun, 10 Sep 2023 16:51:03 +0200 Subject: [PATCH 3/7] add nullable case to general test spec --- ...ith-fake-endpoints-models-for-testing.yaml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml index c6091e8cacc0..746d1be1134b 100644 --- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1014,6 +1014,23 @@ paths: type: string description: request body required: true + /fake/nullable: + post: + tags: + - fake + summary: test nullable parent property + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation /fake/body-with-query-params: put: tags: @@ -1826,6 +1843,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + type: object + discriminator: + propertyName: type + properties: + type: + type: string + enum: + - ChildWithNullable + nullableProperty: + type: string + nullable: true + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - type: object + properties: + otherProperty: + type: string StringBooleanMap: additionalProperties: type: boolean From daad938f76144cd33ced684ef362ce0c929c831c Mon Sep 17 00:00:00 2001 From: Martin <2026226+martin-mfg@users.noreply.github.com> Date: Sun, 10 Sep 2023 16:56:06 +0200 Subject: [PATCH 4/7] generate samples for changed general input --- .../petstore/elixir/.openapi-generator/FILES | 2 + .../elixir/lib/openapi_petstore/api/fake.ex | 31 ++ .../model/child_with_nullable.ex | 26 + .../model/parent_with_nullable.ex | 24 + .../mp/.openapi-generator/FILES | 6 + .../mp/docs/ChildWithNullable.md | 13 + .../java-helidon-client/mp/docs/FakeApi.md | 36 ++ .../mp/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 10 + .../client/model/ChildWithNullable.java | 78 +++ .../client/model/ParentWithNullable.java | 123 +++++ .../client/model/ChildWithNullableTest.java | 67 +++ .../client/model/ParentWithNullableTest.java | 60 +++ .../se/.openapi-generator/FILES | 6 + .../se/docs/ChildWithNullable.md | 13 + .../java-helidon-client/se/docs/FakeApi.md | 66 +++ .../se/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 9 + .../openapitools/client/api/FakeApiImpl.java | 40 ++ .../client/model/ChildWithNullable.java | 78 +++ .../client/model/ParentWithNullable.java | 123 +++++ .../client/model/ChildWithNullableTest.java | 67 +++ .../client/model/ParentWithNullableTest.java | 60 +++ .../.openapi-generator/FILES | 6 + .../petstore/java/apache-httpclient/README.md | 3 + .../java/apache-httpclient/api/openapi.yaml | 38 ++ .../docs/ChildWithNullable.md | 13 + .../java/apache-httpclient/docs/FakeApi.md | 66 +++ .../docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 72 +++ .../client/model/ChildWithNullable.java | 208 ++++++++ .../client/model/ParentWithNullable.java | 261 ++++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../java/feign/.openapi-generator/FILES | 4 + .../petstore/java/feign/api/openapi.yaml | 38 ++ .../org/openapitools/client/api/FakeApi.java | 28 + .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 66 +++ .../client/model/ParentWithNullableTest.java | 60 +++ .../java/resteasy/.openapi-generator/FILES | 6 + .../client/petstore/java/resteasy/README.md | 3 + .../petstore/java/resteasy/api/openapi.yaml | 38 ++ .../java/resteasy/docs/ChildWithNullable.md | 13 + .../petstore/java/resteasy/docs/FakeApi.md | 66 +++ .../java/resteasy/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 43 ++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../.openapi-generator/FILES | 6 + .../java/resttemplate-withXml/README.md | 3 + .../resttemplate-withXml/api/openapi.yaml | 38 ++ .../docs/ChildWithNullable.md | 13 + .../java/resttemplate-withXml/docs/FakeApi.md | 66 +++ .../docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 46 ++ .../client/model/ChildWithNullable.java | 150 ++++++ .../client/model/ParentWithNullable.java | 218 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../resttemplate/.openapi-generator/FILES | 6 + .../petstore/java/resttemplate/README.md | 3 + .../java/resttemplate/api/openapi.yaml | 38 ++ .../resttemplate/docs/ChildWithNullable.md | 13 + .../java/resttemplate/docs/FakeApi.md | 66 +++ .../resttemplate/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 46 ++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../java/vertx/.openapi-generator/FILES | 6 + samples/client/petstore/java/vertx/README.md | 3 + .../petstore/java/vertx/api/openapi.yaml | 38 ++ .../java/vertx/docs/ChildWithNullable.md | 13 + .../petstore/java/vertx/docs/FakeApi.md | 66 +++ .../java/vertx/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 5 + .../openapitools/client/api/FakeApiImpl.java | 49 ++ .../client/api/rxjava/FakeApi.java | 46 ++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../.openapi-generator/FILES | 6 + .../petstore/java/webclient-jakarta/README.md | 3 + .../java/webclient-jakarta/api/openapi.yaml | 38 ++ .../docs/ChildWithNullable.md | 13 + .../java/webclient-jakarta/docs/FakeApi.md | 66 +++ .../docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 70 +++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ .../.openapi-generator/FILES | 6 + .../java/webclient-swagger2/README.md | 3 + .../java/webclient-swagger2/api/openapi.yaml | 38 ++ .../docs/ChildWithNullable.md | 13 + .../java/webclient-swagger2/docs/FakeApi.md | 66 +++ .../docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 70 +++ .../client/model/ChildWithNullable.java | 142 +++++ .../client/model/ParentWithNullable.java | 206 ++++++++ .../client/model/ChildWithNullableTest.java | 69 +++ .../client/model/ParentWithNullableTest.java | 63 +++ .../java/webclient/.openapi-generator/FILES | 6 + .../client/petstore/java/webclient/README.md | 3 + .../petstore/java/webclient/api/openapi.yaml | 38 ++ .../java/webclient/docs/ChildWithNullable.md | 13 + .../petstore/java/webclient/docs/FakeApi.md | 66 +++ .../java/webclient/docs/ParentWithNullable.md | 22 + .../org/openapitools/client/api/FakeApi.java | 70 +++ .../client/model/ChildWithNullable.java | 140 +++++ .../client/model/ParentWithNullable.java | 203 ++++++++ .../client/model/ChildWithNullableTest.java | 68 +++ .../client/model/ParentWithNullableTest.java | 62 +++ samples/client/petstore/k6/script.js | 16 + .../petstore/perl/.openapi-generator/FILES | 6 + samples/client/petstore/perl/README.md | 7 + .../petstore/perl/docs/ChildWithNullable.md | 15 + samples/client/petstore/perl/docs/FakeApi.md | 46 ++ .../petstore/perl/docs/ParentWithNullable.md | 16 + .../perl/lib/WWW/OpenAPIClient/FakeApi.pm | 61 +++ .../OpenAPIClient/Object/ChildWithNullable.pm | 255 +++++++++ .../Object/ParentWithNullable.pm | 251 +++++++++ .../petstore/perl/t/ChildWithNullableTest.t | 34 ++ .../petstore/perl/t/ParentWithNullableTest.t | 34 ++ .../.openapi-generator/FILES | 6 + .../php-nextgen/OpenAPIClient-php/README.md | 3 + .../OpenAPIClient-php/docs/Api/FakeApi.md | 56 ++ .../docs/Model/ChildWithNullable.md | 9 + .../docs/Model/ParentWithNullable.md | 10 + .../OpenAPIClient-php/src/Api/FakeApi.php | 231 +++++++++ .../src/Model/ChildWithNullable.php | 403 +++++++++++++++ .../src/Model/ParentWithNullable.php | 485 ++++++++++++++++++ .../tests/Model/ChildWithNullableTest.php | 90 ++++ .../tests/Model/ParentWithNullableTest.php | 99 ++++ .../ruby-autoload/.openapi-generator/FILES | 6 + .../client/petstore/ruby-autoload/README.md | 3 + .../ruby-autoload/docs/ChildWithNullable.md | 18 + .../petstore/ruby-autoload/docs/FakeApi.md | 64 +++ .../ruby-autoload/docs/ParentWithNullable.md | 20 + .../petstore/ruby-autoload/lib/petstore.rb | 2 + .../lib/petstore/api/fake_api.rb | 66 +++ .../petstore/models/child_with_nullable.rb | 247 +++++++++ .../petstore/models/parent_with_nullable.rb | 263 ++++++++++ .../spec/models/child_with_nullable_spec.rb | 34 ++ .../spec/models/parent_with_nullable_spec.rb | 44 ++ .../ruby-faraday/.openapi-generator/FILES | 6 + .../client/petstore/ruby-faraday/README.md | 3 + .../ruby-faraday/docs/ChildWithNullable.md | 18 + .../petstore/ruby-faraday/docs/FakeApi.md | 64 +++ .../ruby-faraday/docs/ParentWithNullable.md | 20 + .../petstore/ruby-faraday/lib/petstore.rb | 2 + .../ruby-faraday/lib/petstore/api/fake_api.rb | 66 +++ .../petstore/models/child_with_nullable.rb | 247 +++++++++ .../petstore/models/parent_with_nullable.rb | 263 ++++++++++ .../spec/models/child_with_nullable_spec.rb | 34 ++ .../spec/models/parent_with_nullable_spec.rb | 44 ++ .../default-v3.0/.openapi-generator/FILES | 2 + .../builds/default-v3.0/apis/FakeApi.ts | 41 ++ .../default-v3.0/models/ChildWithNullable.ts | 74 +++ .../default-v3.0/models/ParentWithNullable.ts | 92 ++++ .../builds/default-v3.0/models/index.ts | 2 + .../.openapi-generator/FILES | 6 + .../README.md | 3 + .../doc/ChildWithNullable.md | 17 + .../doc/FakeApi.md | 43 ++ .../doc/ParentWithNullable.md | 16 + .../lib/openapi.dart | 2 + .../lib/src/api/fake_api.dart | 66 +++ .../lib/src/deserialize.dart | 6 + .../lib/src/model/child_with_nullable.dart | 98 ++++ .../lib/src/model/parent_with_nullable.dart | 79 +++ .../test/child_with_nullable_test.dart | 26 + .../test/parent_with_nullable_test.dart | 21 + .../.openapi-generator/FILES | 6 + .../petstore_client_lib_fake/README.md | 3 + .../doc/ChildWithNullable.md | 17 + .../petstore_client_lib_fake/doc/FakeApi.md | 43 ++ .../doc/ParentWithNullable.md | 16 + .../petstore_client_lib_fake/lib/openapi.dart | 2 + .../lib/src/api/fake_api.dart | 68 +++ .../lib/src/model/child_with_nullable.dart | 156 ++++++ .../lib/src/model/parent_with_nullable.dart | 212 ++++++++ .../lib/src/serializers.dart | 5 + .../test/child_with_nullable_test.dart | 26 + .../test/parent_with_nullable_test.dart | 21 + .../.openapi-generator/FILES | 6 + .../dart2/petstore_client_lib_fake/README.md | 3 + .../doc/ChildWithNullable.md | 17 + .../petstore_client_lib_fake/doc/FakeApi.md | 43 ++ .../doc/ParentWithNullable.md | 16 + .../petstore_client_lib_fake/lib/api.dart | 2 + .../lib/api/fake_api.dart | 50 ++ .../lib/api_client.dart | 4 + .../lib/model/child_with_nullable.dart | 211 ++++++++ .../lib/model/parent_with_nullable.dart | 194 +++++++ .../test/child_with_nullable_test.dart | 37 ++ .../test/parent_with_nullable_test.dart | 32 ++ .../petstore/mysql/.openapi-generator/FILES | 2 + .../mysql/Model/ChildWithNullable.sql | 26 + .../mysql/Model/ParentWithNullable.sql | 26 + .../schema/petstore/mysql/mysql_schema.sql | 19 + .../generated/3_0/.openapi-generator/FILES | 4 + .../cpp-restbed/generated/3_0/api/FakeApi.cpp | 130 +++++ .../cpp-restbed/generated/3_0/api/FakeApi.h | 69 +++ .../generated/3_0/model/ChildWithNullable.cpp | 140 +++++ .../generated/3_0/model/ChildWithNullable.h | 106 ++++ .../3_0/model/ParentWithNullable.cpp | 127 +++++ .../generated/3_0/model/ParentWithNullable.h | 97 ++++ .../mp/.openapi-generator/FILES | 4 + .../petstore/java-helidon-server/mp/README.md | 1 + .../openapitools/server/api/FakeService.java | 6 + .../server/api/FakeServiceImpl.java | 7 + .../server/model/ChildWithNullable.java | 80 +++ .../server/model/ParentWithNullable.java | 149 ++++++ .../src/main/resources/META-INF/openapi.yml | 38 ++ .../server/model/ChildWithNullableTest.java | 62 +++ .../server/model/ParentWithNullableTest.java | 53 ++ .../se/.openapi-generator/FILES | 4 + .../petstore/java-helidon-server/se/README.md | 1 + .../openapitools/server/api/FakeService.java | 10 + .../server/api/FakeServiceImpl.java | 5 + .../server/model/ChildWithNullable.java | 73 +++ .../server/model/ParentWithNullable.java | 125 +++++ .../src/main/resources/META-INF/openapi.yml | 38 ++ .../server/model/ChildWithNullableTest.java | 62 +++ .../server/model/ParentWithNullableTest.java | 53 ++ .../jaxrs-jersey/.openapi-generator/FILES | 2 + .../java/org/openapitools/api/FakeApi.java | 13 + .../org/openapitools/api/FakeApiService.java | 2 + .../openapitools/model/ChildWithNullable.java | 98 ++++ .../model/ParentWithNullable.java | 160 ++++++ .../api/impl/FakeApiServiceImpl.java | 6 + .../php-laravel/.openapi-generator/FILES | 2 + .../app/Http/Controllers/FakeController.php | 24 + .../lib/app/Models/ChildWithNullable.php | 21 + .../lib/app/Models/ParentWithNullable.php | 18 + .../petstore/php-laravel/lib/routes/api.php | 7 + .../lib/app/Http/Controllers/FakeApi.php | 24 + .../petstore/php-lumen/lib/routes/web.php | 7 + 246 files changed, 14516 insertions(+) create mode 100644 samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex create mode 100644 samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex create mode 100644 samples/client/petstore/java-helidon-client/mp/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java-helidon-client/mp/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java-helidon-client/se/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java-helidon-client/se/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/apache-httpclient/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/apache-httpclient/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/resteasy/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/resteasy/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/resttemplate-withXml/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/resttemplate-withXml/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/resttemplate/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/resttemplate/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/vertx/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/vertx/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient-jakarta/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/webclient-jakarta/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient-swagger2/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/webclient-swagger2/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/java/webclient/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java create mode 100644 samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java create mode 100644 samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java create mode 100644 samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java create mode 100644 samples/client/petstore/perl/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/perl/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm create mode 100644 samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm create mode 100644 samples/client/petstore/perl/t/ChildWithNullableTest.t create mode 100644 samples/client/petstore/perl/t/ParentWithNullableTest.t create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ChildWithNullable.md create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ParentWithNullable.md create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ChildWithNullableTest.php create mode 100644 samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ParentWithNullableTest.php create mode 100644 samples/client/petstore/ruby-autoload/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/ruby-autoload/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb create mode 100644 samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb create mode 100644 samples/client/petstore/ruby-autoload/spec/models/child_with_nullable_spec.rb create mode 100644 samples/client/petstore/ruby-autoload/spec/models/parent_with_nullable_spec.rb create mode 100644 samples/client/petstore/ruby-faraday/docs/ChildWithNullable.md create mode 100644 samples/client/petstore/ruby-faraday/docs/ParentWithNullable.md create mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/child_with_nullable.rb create mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/parent_with_nullable.rb create mode 100644 samples/client/petstore/ruby-faraday/spec/models/child_with_nullable_spec.rb create mode 100644 samples/client/petstore/ruby-faraday/spec/models/parent_with_nullable_spec.rb create mode 100644 samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts create mode 100644 samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ChildWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ParentWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/child_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/parent_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ChildWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ParentWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/child_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/parent_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/child_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/parent_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ChildWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ParentWithNullable.md create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/child_with_nullable_test.dart create mode 100644 samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/parent_with_nullable_test.dart create mode 100644 samples/schema/petstore/mysql/Model/ChildWithNullable.sql create mode 100644 samples/schema/petstore/mysql/Model/ParentWithNullable.sql create mode 100644 samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.cpp create mode 100644 samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.h create mode 100644 samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.cpp create mode 100644 samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.h create mode 100644 samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ChildWithNullable.java create mode 100644 samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ParentWithNullable.java create mode 100644 samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java create mode 100644 samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java create mode 100644 samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ChildWithNullable.java create mode 100644 samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ParentWithNullable.java create mode 100644 samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java create mode 100644 samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java create mode 100644 samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ChildWithNullable.java create mode 100644 samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ParentWithNullable.java create mode 100644 samples/server/petstore/php-laravel/lib/app/Models/ChildWithNullable.php create mode 100644 samples/server/petstore/php-laravel/lib/app/Models/ParentWithNullable.php diff --git a/samples/client/petstore/elixir/.openapi-generator/FILES b/samples/client/petstore/elixir/.openapi-generator/FILES index cf3fc36a0ab8..4e11f3ad0744 100644 --- a/samples/client/petstore/elixir/.openapi-generator/FILES +++ b/samples/client/petstore/elixir/.openapi-generator/FILES @@ -24,6 +24,7 @@ lib/openapi_petstore/model/array_test.ex lib/openapi_petstore/model/capitalization.ex lib/openapi_petstore/model/cat.ex lib/openapi_petstore/model/category.ex +lib/openapi_petstore/model/child_with_nullable.ex lib/openapi_petstore/model/class_model.ex lib/openapi_petstore/model/client.ex lib/openapi_petstore/model/deprecated_model.ex @@ -53,6 +54,7 @@ lib/openapi_petstore/model/outer_enum_default_value.ex lib/openapi_petstore/model/outer_enum_integer.ex lib/openapi_petstore/model/outer_enum_integer_default_value.ex lib/openapi_petstore/model/outer_object_with_enum_property.ex +lib/openapi_petstore/model/parent_with_nullable.ex lib/openapi_petstore/model/pet.ex lib/openapi_petstore/model/read_only_first.ex lib/openapi_petstore/model/return.ex diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex index 86607169736b..6cdb560634a2 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex @@ -618,6 +618,37 @@ defmodule OpenapiPetstore.Api.Fake do ]) end + @doc """ + test nullable parent property + + + ### Parameters + + - `connection` (OpenapiPetstore.Connection): Connection to server + - `child_with_nullable` (ChildWithNullable): request body + - `opts` (keyword): Optional parameters + + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure + """ + @spec test_nullable(Tesla.Env.client, OpenapiPetstore.Model.ChildWithNullable.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} + def test_nullable(connection, child_with_nullable, _opts \\ []) do + request = + %{} + |> method(:post) + |> url("/fake/nullable") + |> add_param(:body, :body, child_with_nullable) + |> Enum.into([]) + + connection + |> Connection.request(request) + |> evaluate_response([ + {200, false} + ]) + end + @doc """ To test the collection format in query parameters diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex new file mode 100644 index 000000000000..850ce5cbdf43 --- /dev/null +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/child_with_nullable.ex @@ -0,0 +1,26 @@ +# NOTE: This file is auto generated by OpenAPI Generator 7.0.1-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. + +defmodule OpenapiPetstore.Model.ChildWithNullable do + @moduledoc """ + + """ + + @derive Jason.Encoder + defstruct [ + :type, + :nullableProperty, + :otherProperty + ] + + @type t :: %__MODULE__{ + :type => String.t | nil, + :nullableProperty => String.t | nil, + :otherProperty => String.t | nil + } + + def decode(value) do + value + end +end + diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex new file mode 100644 index 000000000000..8fc6d5113e8e --- /dev/null +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/parent_with_nullable.ex @@ -0,0 +1,24 @@ +# NOTE: This file is auto generated by OpenAPI Generator 7.0.1-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. + +defmodule OpenapiPetstore.Model.ParentWithNullable do + @moduledoc """ + + """ + + @derive Jason.Encoder + defstruct [ + :type, + :nullableProperty + ] + + @type t :: %__MODULE__{ + :type => String.t | nil, + :nullableProperty => String.t | nil + } + + def decode(value) do + value + end +end + diff --git a/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES b/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES index 3355ff7560c8..a94790d3673e 100644 --- a/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES +++ b/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES @@ -9,6 +9,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -44,6 +45,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -74,6 +76,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -106,9 +109,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java-helidon-client/mp/docs/ChildWithNullable.md b/samples/client/petstore/java-helidon-client/mp/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java-helidon-client/mp/docs/FakeApi.md b/samples/client/petstore/java-helidon-client/mp/docs/FakeApi.md index be1544eae6ee..5ad019091529 100644 --- a/samples/client/petstore/java-helidon-client/mp/docs/FakeApi.md +++ b/samples/client/petstore/java-helidon-client/mp/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -640,6 +641,41 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> void testNullable(childWithNullable) + +test nullable parent property + + + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +[**void**](Void.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > void testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java-helidon-client/mp/docs/ParentWithNullable.md b/samples/client/petstore/java-helidon-client/mp/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/api/FakeApi.java index af82256d0d7f..89484f30f6c6 100644 --- a/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/api/FakeApi.java @@ -26,6 +26,7 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -169,6 +170,15 @@ public interface FakeApi { @Consumes({ "application/x-www-form-urlencoded" }) void testJsonFormData(@FormParam("param") String param, @FormParam("param2") String param2) throws ApiException, ProcessingException; + /** + * test nullable parent property + * + */ + @POST + @Path("/nullable") + @Consumes({ "application/json" }) + void testNullable(ChildWithNullable childWithNullable) throws ApiException, ProcessingException; + @PUT @Path("/test-query-parameters") void testQueryParameterCollectionFormat(@QueryParam("pipe") List pipe, @QueryParam("ioutil") List ioutil, @QueryParam("http") List http, @QueryParam("url") List url, @QueryParam("context") List context, @QueryParam("allowEmpty") String allowEmpty, @QueryParam("language") Map language) throws ApiException, ProcessingException; diff --git a/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..90b2f7ceb09b --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,78 @@ +/** + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; + + + + +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + /** + * Get otherProperty + * @return otherProperty + **/ + public String getOtherProperty() { + return otherProperty; + } + + /** + * Set otherProperty + **/ + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..25c24ff86020 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,123 @@ +/** + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.NoSuchElementException; + + + + +public class ParentWithNullable { + +public enum TypeEnum { + + CHILDWITHNULLABLE(String.valueOf("ChildWithNullable")); + + String value; + + TypeEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +} + + private TypeEnum type; + + private String nullableProperty; + + /** + * Get type + * @return type + **/ + public TypeEnum getType() { + return type; + } + + /** + * Set type + **/ + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + public String getNullableProperty() { + return nullableProperty; + } + + /** + * Set nullableProperty + **/ + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..68acb8c52349 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,67 @@ +/** + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..a0fe79ed444b --- /dev/null +++ b/samples/client/petstore/java-helidon-client/mp/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,60 @@ +/** + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.NoSuchElementException; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES b/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES index 4fcd023785c6..abb8b0f182f3 100644 --- a/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES +++ b/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES @@ -9,6 +9,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -44,6 +45,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -83,6 +85,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -115,9 +118,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java-helidon-client/se/docs/ChildWithNullable.md b/samples/client/petstore/java-helidon-client/se/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java-helidon-client/se/docs/FakeApi.md b/samples/client/petstore/java-helidon-client/se/docs/FakeApi.md index 6eb12aee3577..df8b14be8e29 100644 --- a/samples/client/petstore/java-helidon-client/se/docs/FakeApi.md +++ b/samples/client/petstore/java-helidon-client/se/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java-helidon-client/se/docs/ParentWithNullable.md b/samples/client/petstore/java-helidon-client/se/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApi.java index 5e5dec6bfb2c..d1c8dd114ec6 100644 --- a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApi.java @@ -14,6 +14,7 @@ import org.openapitools.client.ApiResponse; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -144,6 +145,14 @@ public interface FakeApi { */ ApiResponse testJsonFormData(String param, String param2); + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @return {@code ApiResponse} + */ + ApiResponse testNullable(ChildWithNullable childWithNullable); + ApiResponse testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, Map language); } diff --git a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApiImpl.java b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApiImpl.java index 9a2849d61ae5..ae2bdc30f22e 100644 --- a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApiImpl.java +++ b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/api/FakeApiImpl.java @@ -30,6 +30,7 @@ import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -75,6 +76,7 @@ public class FakeApiImpl implements FakeApi { protected static final GenericType RESPONSE_TYPE_testGroupParameters = ResponseType.create(Void.class); protected static final GenericType RESPONSE_TYPE_testInlineAdditionalProperties = ResponseType.create(Void.class); protected static final GenericType RESPONSE_TYPE_testJsonFormData = ResponseType.create(Void.class); + protected static final GenericType RESPONSE_TYPE_testNullable = ResponseType.create(Void.class); protected static final GenericType RESPONSE_TYPE_testQueryParameterCollectionFormat = ResponseType.create(Void.class); /** @@ -856,6 +858,44 @@ protected ApiResponse testJsonFormDataSubmit(WebClientRequestBuilder webCl return ApiResponse.create(RESPONSE_TYPE_testJsonFormData, webClientResponse); } + @Override + public ApiResponse testNullable(ChildWithNullable childWithNullable) { + Objects.requireNonNull(childWithNullable, "Required parameter 'childWithNullable' not specified"); + WebClientRequestBuilder webClientRequestBuilder = testNullableRequestBuilder(childWithNullable); + return testNullableSubmit(webClientRequestBuilder, childWithNullable); + } + + /** + * Creates a {@code WebClientRequestBuilder} for the testNullable operation. + * Optional customization point for subclasses. + * + * @param childWithNullable request body (required) + * @return WebClientRequestBuilder for testNullable + */ + protected WebClientRequestBuilder testNullableRequestBuilder(ChildWithNullable childWithNullable) { + WebClientRequestBuilder webClientRequestBuilder = apiClient.webClient() + .method("POST"); + + webClientRequestBuilder.path("/fake/nullable"); + webClientRequestBuilder.contentType(MediaType.APPLICATION_JSON); + webClientRequestBuilder.accept(MediaType.APPLICATION_JSON); + + return webClientRequestBuilder; + } + + /** + * Initiates the request for the testNullable operation. + * Optional customization point for subclasses. + * + * @param webClientRequestBuilder the request builder to use for submitting the request + * @param childWithNullable request body (required) + * @return {@code ApiResponse} for the submitted request + */ + protected ApiResponse testNullableSubmit(WebClientRequestBuilder webClientRequestBuilder, ChildWithNullable childWithNullable) { + Single webClientResponse = webClientRequestBuilder.submit(childWithNullable); + return ApiResponse.create(RESPONSE_TYPE_testNullable, webClientResponse); + } + @Override public ApiResponse testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, Map language) { Objects.requireNonNull(pipe, "Required parameter 'pipe' not specified"); diff --git a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..90b2f7ceb09b --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,78 @@ +/** + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; + + + + +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + /** + * Get otherProperty + * @return otherProperty + **/ + public String getOtherProperty() { + return otherProperty; + } + + /** + * Set otherProperty + **/ + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..25c24ff86020 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,123 @@ +/** + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.NoSuchElementException; + + + + +public class ParentWithNullable { + +public enum TypeEnum { + + CHILDWITHNULLABLE(String.valueOf("ChildWithNullable")); + + String value; + + TypeEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +} + + private TypeEnum type; + + private String nullableProperty; + + /** + * Get type + * @return type + **/ + public TypeEnum getType() { + return type; + } + + /** + * Set type + **/ + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + public String getNullableProperty() { + return nullableProperty; + } + + /** + * Set nullableProperty + **/ + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..68acb8c52349 --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,67 @@ +/** + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..a0fe79ed444b --- /dev/null +++ b/samples/client/petstore/java-helidon-client/se/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,60 @@ +/** + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.NoSuchElementException; + +import org.junit.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES b/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES index bf886d21ded6..ce45083786b7 100644 --- a/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES +++ b/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -99,6 +101,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -131,9 +134,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/apache-httpclient/README.md b/samples/client/petstore/java/apache-httpclient/README.md index 3a2c3df03fa0..400434d7e491 100644 --- a/samples/client/petstore/java/apache-httpclient/README.md +++ b/samples/client/petstore/java/apache-httpclient/README.md @@ -125,6 +125,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -161,6 +162,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -193,6 +195,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/apache-httpclient/api/openapi.yaml b/samples/client/petstore/java/apache-httpclient/api/openapi.yaml index 9f0affe779f0..288d48909023 100644 --- a/samples/client/petstore/java/apache-httpclient/api/openapi.yaml +++ b/samples/client/petstore/java/apache-httpclient/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/apache-httpclient/docs/ChildWithNullable.md b/samples/client/petstore/java/apache-httpclient/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md b/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md index 6eb12aee3577..df8b14be8e29 100644 --- a/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md +++ b/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/apache-httpclient/docs/ParentWithNullable.md b/samples/client/petstore/java/apache-httpclient/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java index 99b71e9b542f..c649052dd866 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java @@ -20,6 +20,7 @@ import org.openapitools.client.Pair; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -1407,6 +1408,77 @@ public void testJsonFormData(String param, String param2, Map ad ); } + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @throws ApiException if fails to make API call + */ + public void testNullable(ChildWithNullable childWithNullable) throws ApiException { + this.testNullable(childWithNullable, Collections.emptyMap()); + } + + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param additionalHeaders additionalHeaders for this call + * @throws ApiException if fails to make API call + */ + public void testNullable(ChildWithNullable childWithNullable, Map additionalHeaders) throws ApiException { + Object localVarPostBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new ApiException(400, "Missing the required parameter 'childWithNullable' when calling testNullable"); + } + + // create path and map variables + String localVarPath = "/fake/nullable"; + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + localVarHeaderParams.putAll(additionalHeaders); + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + apiClient.invokeAPI( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + null + ); + } + /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..6c714ccc5809 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,208 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `type` to the URL query string + if (getType() != null) { + try { + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `nullableProperty` to the URL query string + if (getNullableProperty() != null) { + try { + joiner.add(String.format("%snullableProperty%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNullableProperty()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `otherProperty` to the URL query string + if (getOtherProperty() != null) { + try { + joiner.add(String.format("%sotherProperty%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOtherProperty()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + return joiner.toString(); + } + +} + diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..ff90d3aa9e26 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,261 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `type` to the URL query string + if (getType() != null) { + try { + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `nullableProperty` to the URL query string + if (getNullableProperty() != null) { + try { + joiner.add(String.format("%snullableProperty%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNullableProperty()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + return joiner.toString(); + } + +} + diff --git a/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..2616181bec30 --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..bdd46008b13d --- /dev/null +++ b/samples/client/petstore/java/apache-httpclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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 ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/feign/.openapi-generator/FILES b/samples/client/petstore/java/feign/.openapi-generator/FILES index fae67fe89c06..60ba7d353fe5 100644 --- a/samples/client/petstore/java/feign/.openapi-generator/FILES +++ b/samples/client/petstore/java/feign/.openapi-generator/FILES @@ -48,6 +48,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -80,9 +81,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/feign/api/openapi.yaml b/samples/client/petstore/java/feign/api/openapi.yaml index 9f0affe779f0..288d48909023 100644 --- a/samples/client/petstore/java/feign/api/openapi.yaml +++ b/samples/client/petstore/java/feign/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java index de441d239dac..56dec984095d 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java @@ -5,6 +5,7 @@ import org.openapitools.client.model.ApiResponse; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -839,6 +840,33 @@ public TestGroupParametersQueryParams int64Group(final Long value) { + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + */ + @RequestLine("POST /fake/nullable") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + void testNullable(ChildWithNullable childWithNullable); + + /** + * test nullable parent property + * Similar to testNullable but it also returns the http response headers . + * + * @param childWithNullable request body (required) + */ + @RequestLine("POST /fake/nullable") + @Headers({ + "Content-Type: application/json", + "Accept: application/json", + }) + ApiResponse testNullableWithHttpInfo(ChildWithNullable childWithNullable); + + + /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..808a97496f36 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..b8ad35eda765 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..746a2c9f9b4b --- /dev/null +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,66 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..7a1f1c9d3fc2 --- /dev/null +++ b/samples/client/petstore/java/feign/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,60 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/resteasy/.openapi-generator/FILES b/samples/client/petstore/java/resteasy/.openapi-generator/FILES index 2044e4024911..e62cae5e14c9 100644 --- a/samples/client/petstore/java/resteasy/.openapi-generator/FILES +++ b/samples/client/petstore/java/resteasy/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -100,6 +102,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -132,9 +135,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/resteasy/README.md b/samples/client/petstore/java/resteasy/README.md index 084a6ea31a31..45e1a1c959bf 100644 --- a/samples/client/petstore/java/resteasy/README.md +++ b/samples/client/petstore/java/resteasy/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/resteasy/api/openapi.yaml b/samples/client/petstore/java/resteasy/api/openapi.yaml index 9f0affe779f0..288d48909023 100644 --- a/samples/client/petstore/java/resteasy/api/openapi.yaml +++ b/samples/client/petstore/java/resteasy/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/resteasy/docs/ChildWithNullable.md b/samples/client/petstore/java/resteasy/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java/resteasy/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/resteasy/docs/FakeApi.md b/samples/client/petstore/java/resteasy/docs/FakeApi.md index 6eb12aee3577..df8b14be8e29 100644 --- a/samples/client/petstore/java/resteasy/docs/FakeApi.md +++ b/samples/client/petstore/java/resteasy/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/resteasy/docs/ParentWithNullable.md b/samples/client/petstore/java/resteasy/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java/resteasy/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/FakeApi.java index 73d27c887caf..c9bee15e56f1 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/api/FakeApi.java @@ -8,6 +8,7 @@ import javax.ws.rs.core.GenericType; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -853,6 +854,48 @@ public void testJsonFormData(String param, String param2) throws ApiException { apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); } + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @throws ApiException if fails to make API call + */ + public void testNullable(ChildWithNullable childWithNullable) throws ApiException { + Object localVarPostBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new ApiException(400, "Missing the required parameter 'childWithNullable' when calling testNullable"); + } + + // create path and map variables + String localVarPath = "/fake/nullable".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..808a97496f36 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..b8ad35eda765 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..2616181bec30 --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..bdd46008b13d --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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 ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES index 76a53947ccf2..f38c01458cab 100644 --- a/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -95,6 +97,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -127,9 +130,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/resttemplate-withXml/README.md b/samples/client/petstore/java/resttemplate-withXml/README.md index d450bd82c64f..dc708dba258f 100644 --- a/samples/client/petstore/java/resttemplate-withXml/README.md +++ b/samples/client/petstore/java/resttemplate-withXml/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/resttemplate-withXml/api/openapi.yaml b/samples/client/petstore/java/resttemplate-withXml/api/openapi.yaml index 9f0affe779f0..288d48909023 100644 --- a/samples/client/petstore/java/resttemplate-withXml/api/openapi.yaml +++ b/samples/client/petstore/java/resttemplate-withXml/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/ChildWithNullable.md b/samples/client/petstore/java/resttemplate-withXml/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md b/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md index 6eb12aee3577..df8b14be8e29 100644 --- a/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/ParentWithNullable.md b/samples/client/petstore/java/resttemplate-withXml/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java index ea18b45cd975..0ed0c08ed192 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -971,6 +972,51 @@ public ResponseEntity testJsonFormDataWithHttpInfo(String param, String pa ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI("/fake/jsonFormData", HttpMethod.GET, Collections.emptyMap(), localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body (required) + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public void testNullable(ChildWithNullable childWithNullable) throws RestClientException { + testNullableWithHttpInfo(childWithNullable); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws RestClientException { + Object localVarPostBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'childWithNullable' when calling testNullable"); + } + + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI("/fake/nullable", HttpMethod.POST, Collections.emptyMap(), localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..dba8d12b8e98 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,150 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.dataformat.xml.annotation.*; +import javax.xml.bind.annotation.*; +import javax.xml.bind.annotation.adapters.*; +import io.github.threetenjaxb.core.*; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +@XmlRootElement(name = "ChildWithNullable") +@XmlAccessorType(XmlAccessType.FIELD) +@JacksonXmlRootElement(localName = "ChildWithNullable") +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + @XmlElement(name = "otherProperty") + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "otherProperty") + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "otherProperty") + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..1fef3b6f4404 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,218 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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; +import com.fasterxml.jackson.dataformat.xml.annotation.*; +import javax.xml.bind.annotation.*; +import javax.xml.bind.annotation.adapters.*; +import io.github.threetenjaxb.core.*; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +@XmlRootElement(name = "ParentWithNullable") +@XmlAccessorType(XmlAccessType.FIELD) +@JacksonXmlRootElement(localName = "ParentWithNullable") +public class ParentWithNullable { + /** + * Gets or Sets type + */ + @XmlType(name="TypeEnum") + @XmlEnum(String.class) + public enum TypeEnum { + @XmlEnumValue("ChildWithNullable") + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + @XmlElement(name = "type") + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + @XmlElement(name = "nullableProperty") + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "type") + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "type") + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JacksonXmlProperty(localName = "nullableProperty") + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..2616181bec30 --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..bdd46008b13d --- /dev/null +++ b/samples/client/petstore/java/resttemplate-withXml/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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 ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/resttemplate/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate/.openapi-generator/FILES index 76a53947ccf2..f38c01458cab 100644 --- a/samples/client/petstore/java/resttemplate/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -95,6 +97,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -127,9 +130,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/resttemplate/README.md b/samples/client/petstore/java/resttemplate/README.md index bfd879857cf0..c2f1a0109a69 100644 --- a/samples/client/petstore/java/resttemplate/README.md +++ b/samples/client/petstore/java/resttemplate/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/resttemplate/api/openapi.yaml b/samples/client/petstore/java/resttemplate/api/openapi.yaml index 9f0affe779f0..288d48909023 100644 --- a/samples/client/petstore/java/resttemplate/api/openapi.yaml +++ b/samples/client/petstore/java/resttemplate/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/resttemplate/docs/ChildWithNullable.md b/samples/client/petstore/java/resttemplate/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/resttemplate/docs/FakeApi.md b/samples/client/petstore/java/resttemplate/docs/FakeApi.md index 6eb12aee3577..df8b14be8e29 100644 --- a/samples/client/petstore/java/resttemplate/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/resttemplate/docs/ParentWithNullable.md b/samples/client/petstore/java/resttemplate/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java/resttemplate/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java index ea18b45cd975..0ed0c08ed192 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -971,6 +972,51 @@ public ResponseEntity testJsonFormDataWithHttpInfo(String param, String pa ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI("/fake/jsonFormData", HttpMethod.GET, Collections.emptyMap(), localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body (required) + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public void testNullable(ChildWithNullable childWithNullable) throws RestClientException { + testNullableWithHttpInfo(childWithNullable); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws RestClientException { + Object localVarPostBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'childWithNullable' when calling testNullable"); + } + + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarCookieParams = new LinkedMultiValueMap(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + ParameterizedTypeReference localReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI("/fake/nullable", HttpMethod.POST, Collections.emptyMap(), localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localReturnType); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..808a97496f36 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..b8ad35eda765 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..2616181bec30 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..bdd46008b13d --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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 ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/vertx/.openapi-generator/FILES b/samples/client/petstore/java/vertx/.openapi-generator/FILES index d7d207ca6c3d..734a2b4bd937 100644 --- a/samples/client/petstore/java/vertx/.openapi-generator/FILES +++ b/samples/client/petstore/java/vertx/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -113,6 +115,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -145,9 +148,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/vertx/README.md b/samples/client/petstore/java/vertx/README.md index 883a558aa74e..bc346e08dd23 100644 --- a/samples/client/petstore/java/vertx/README.md +++ b/samples/client/petstore/java/vertx/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/vertx/api/openapi.yaml b/samples/client/petstore/java/vertx/api/openapi.yaml index 9f0affe779f0..288d48909023 100644 --- a/samples/client/petstore/java/vertx/api/openapi.yaml +++ b/samples/client/petstore/java/vertx/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/vertx/docs/ChildWithNullable.md b/samples/client/petstore/java/vertx/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java/vertx/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/vertx/docs/FakeApi.md b/samples/client/petstore/java/vertx/docs/FakeApi.md index a0fb70ef8d4b..d17031d2ac17 100644 --- a/samples/client/petstore/java/vertx/docs/FakeApi.md +++ b/samples/client/petstore/java/vertx/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/vertx/docs/ParentWithNullable.md b/samples/client/petstore/java/vertx/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java/vertx/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApi.java index 43d08fbc79ab..ac4bf8941f67 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ import org.openapitools.client.ApiClient; import io.vertx.core.file.AsyncFile; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -90,6 +91,10 @@ public interface FakeApi { void testJsonFormData(String param, String param2, ApiClient.AuthInfo authInfo, Handler> handler); + void testNullable(ChildWithNullable childWithNullable, Handler> handler); + + void testNullable(ChildWithNullable childWithNullable, ApiClient.AuthInfo authInfo, Handler> handler); + void testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, Map language, Handler> handler); void testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, Map language, ApiClient.AuthInfo authInfo, Handler> handler); diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApiImpl.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApiImpl.java index 4236c2b3287f..34c098a50fb5 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApiImpl.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/FakeApiImpl.java @@ -2,6 +2,7 @@ import io.vertx.core.file.AsyncFile; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -964,6 +965,54 @@ public void testJsonFormData(String param, String param2, ApiClient.AuthInfo aut apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccepts, localVarContentTypes, localVarAuthNames, authInfo, null, resultHandler); } /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param resultHandler Asynchronous result handler + */ + public void testNullable(ChildWithNullable childWithNullable, Handler> resultHandler) { + testNullable(childWithNullable, null, resultHandler); + } + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param authInfo per call authentication override. + * @param resultHandler Asynchronous result handler + */ + public void testNullable(ChildWithNullable childWithNullable, ApiClient.AuthInfo authInfo, Handler> resultHandler) { + Object localVarBody = childWithNullable; + + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + resultHandler.handle(ApiException.fail(400, "Missing the required parameter 'childWithNullable' when calling testNullable")); + return; + } + + // create path and map variables + String localVarPath = "/fake/nullable"; + + // query params + List localVarQueryParams = new ArrayList<>(); + + // header params + MultiMap localVarHeaderParams = MultiMap.caseInsensitiveMultiMap(); + + // cookie params + MultiMap localVarCookieParams = MultiMap.caseInsensitiveMultiMap(); + + // form params + // TODO: sending files within multipart/form-data is not supported yet (because of vertx web-client) + Map localVarFormParams = new HashMap<>(); + + String[] localVarAccepts = { }; + String[] localVarContentTypes = { "application/json" }; + String[] localVarAuthNames = new String[] { }; + + apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccepts, localVarContentTypes, localVarAuthNames, authInfo, null, resultHandler); + } + /** * * To test the collection format in query parameters * @param pipe (required) diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/FakeApi.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/FakeApi.java index 85106635b976..4ae404ab093f 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/FakeApi.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/api/rxjava/FakeApi.java @@ -2,6 +2,7 @@ import io.vertx.core.file.AsyncFile; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -912,6 +913,51 @@ public Single rxTestJsonFormData(String param, String param2, ApiClient.Au )); } /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param resultHandler Asynchronous result handler + */ + public void testNullable(ChildWithNullable childWithNullable, Handler> resultHandler) { + delegate.testNullable(childWithNullable, resultHandler); + } + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param authInfo call specific auth overrides + * @param resultHandler Asynchronous result handler + */ + public void testNullable(ChildWithNullable childWithNullable, ApiClient.AuthInfo authInfo, Handler> resultHandler) { + delegate.testNullable(childWithNullable, authInfo, resultHandler); + } + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @return Asynchronous result handler (RxJava Single) + */ + public Single rxTestNullable(ChildWithNullable childWithNullable) { + return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> + delegate.testNullable(childWithNullable, fut) + )); + } + + /** + * test nullable parent property + * + * @param childWithNullable request body (required) + * @param authInfo call specific auth overrides + * @return Asynchronous result handler (RxJava Single) + */ + public Single rxTestNullable(ChildWithNullable childWithNullable, ApiClient.AuthInfo authInfo) { + return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> + delegate.testNullable(childWithNullable, authInfo, fut) + )); + } + /** * * To test the collection format in query parameters * @param pipe (required) diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..808a97496f36 --- /dev/null +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..b8ad35eda765 --- /dev/null +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..2616181bec30 --- /dev/null +++ b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..bdd46008b13d --- /dev/null +++ b/samples/client/petstore/java/vertx/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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 ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES index 7b091f23a808..7a2d1256298d 100644 --- a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -96,6 +98,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -128,9 +131,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/webclient-jakarta/README.md b/samples/client/petstore/java/webclient-jakarta/README.md index 11cf41560c8c..178a016bffe5 100644 --- a/samples/client/petstore/java/webclient-jakarta/README.md +++ b/samples/client/petstore/java/webclient-jakarta/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/webclient-jakarta/api/openapi.yaml b/samples/client/petstore/java/webclient-jakarta/api/openapi.yaml index 9f0affe779f0..288d48909023 100644 --- a/samples/client/petstore/java/webclient-jakarta/api/openapi.yaml +++ b/samples/client/petstore/java/webclient-jakarta/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/webclient-jakarta/docs/ChildWithNullable.md b/samples/client/petstore/java/webclient-jakarta/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/webclient-jakarta/docs/FakeApi.md b/samples/client/petstore/java/webclient-jakarta/docs/FakeApi.md index 6eb12aee3577..df8b14be8e29 100644 --- a/samples/client/petstore/java/webclient-jakarta/docs/FakeApi.md +++ b/samples/client/petstore/java/webclient-jakarta/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/webclient-jakarta/docs/ParentWithNullable.md b/samples/client/petstore/java/webclient-jakarta/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/api/FakeApi.java index d8ff2b837d4b..35ad9b29bca2 100644 --- a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -1449,6 +1450,75 @@ public Mono> testJsonFormDataWithHttpInfo(String param, Str public ResponseSpec testJsonFormDataWithResponseSpec(String param, String param2) throws WebClientResponseException { return testJsonFormDataRequestCreation(param, param2); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + private ResponseSpec testNullableRequestCreation(ChildWithNullable childWithNullable) throws WebClientResponseException { + Object postBody = childWithNullable; + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new WebClientResponseException("Missing the required parameter 'childWithNullable' when calling testNullable", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); + } + // create path and map variables + final Map pathParams = new HashMap(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap cookieParams = new LinkedMultiValueMap(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI("/fake/nullable", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono testNullable(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).bodyToMono(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono> testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).toEntity(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @return ResponseSpec + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNullable) throws WebClientResponseException { + return testNullableRequestCreation(childWithNullable); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..82378f275fa1 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..89b485dbe703 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @jakarta.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..2616181bec30 --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..bdd46008b13d --- /dev/null +++ b/samples/client/petstore/java/webclient-jakarta/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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 ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES index 7b091f23a808..7a2d1256298d 100644 --- a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -96,6 +98,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -128,9 +131,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/webclient-swagger2/README.md b/samples/client/petstore/java/webclient-swagger2/README.md index 11cf41560c8c..178a016bffe5 100644 --- a/samples/client/petstore/java/webclient-swagger2/README.md +++ b/samples/client/petstore/java/webclient-swagger2/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/webclient-swagger2/api/openapi.yaml b/samples/client/petstore/java/webclient-swagger2/api/openapi.yaml index 9f0affe779f0..288d48909023 100644 --- a/samples/client/petstore/java/webclient-swagger2/api/openapi.yaml +++ b/samples/client/petstore/java/webclient-swagger2/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/webclient-swagger2/docs/ChildWithNullable.md b/samples/client/petstore/java/webclient-swagger2/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/webclient-swagger2/docs/FakeApi.md b/samples/client/petstore/java/webclient-swagger2/docs/FakeApi.md index 6eb12aee3577..df8b14be8e29 100644 --- a/samples/client/petstore/java/webclient-swagger2/docs/FakeApi.md +++ b/samples/client/petstore/java/webclient-swagger2/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/webclient-swagger2/docs/ParentWithNullable.md b/samples/client/petstore/java/webclient-swagger2/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/api/FakeApi.java index a86605d1ae2f..da027dbd509a 100644 --- a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -1449,6 +1450,75 @@ public Mono> testJsonFormDataWithHttpInfo(String param, Str public ResponseSpec testJsonFormDataWithResponseSpec(String param, String param2) throws WebClientResponseException { return testJsonFormDataRequestCreation(param, param2); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + private ResponseSpec testNullableRequestCreation(ChildWithNullable childWithNullable) throws WebClientResponseException { + Object postBody = childWithNullable; + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new WebClientResponseException("Missing the required parameter 'childWithNullable' when calling testNullable", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); + } + // create path and map variables + final Map pathParams = new HashMap(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap cookieParams = new LinkedMultiValueMap(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI("/fake/nullable", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono testNullable(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).bodyToMono(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono> testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).toEntity(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @return ResponseSpec + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNullable) throws WebClientResponseException { + return testNullableRequestCreation(childWithNullable); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..43bf9db8f6fc --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,142 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..023236bc487f --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,206 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +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; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, description = "") + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..445815405cfe --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,69 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..870d9c134597 --- /dev/null +++ b/samples/client/petstore/java/webclient-swagger2/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +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 ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/java/webclient/.openapi-generator/FILES b/samples/client/petstore/java/webclient/.openapi-generator/FILES index 7b091f23a808..7a2d1256298d 100644 --- a/samples/client/petstore/java/webclient/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -50,6 +51,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -96,6 +98,7 @@ src/main/java/org/openapitools/client/model/ArrayTest.java src/main/java/org/openapitools/client/model/Capitalization.java src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/ChildWithNullable.java src/main/java/org/openapitools/client/model/ClassModel.java src/main/java/org/openapitools/client/model/Client.java src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -128,9 +131,12 @@ src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/client/model/OuterEnumInteger.java 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/ParentWithNullable.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/test/java/org/openapitools/client/model/ChildWithNullableTest.java +src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/webclient/README.md b/samples/client/petstore/java/webclient/README.md index 11cf41560c8c..178a016bffe5 100644 --- a/samples/client/petstore/java/webclient/README.md +++ b/samples/client/petstore/java/webclient/README.md @@ -132,6 +132,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store @@ -168,6 +169,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [ChildWithNullable](docs/ChildWithNullable.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [DeprecatedObject](docs/DeprecatedObject.md) @@ -200,6 +202,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](docs/ParentWithNullable.md) - [Pet](docs/Pet.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/java/webclient/api/openapi.yaml b/samples/client/petstore/java/webclient/api/openapi.yaml index 9f0affe779f0..288d48909023 100644 --- a/samples/client/petstore/java/webclient/api/openapi.yaml +++ b/samples/client/petstore/java/webclient/api/openapi.yaml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/client/petstore/java/webclient/docs/ChildWithNullable.md b/samples/client/petstore/java/webclient/docs/ChildWithNullable.md new file mode 100644 index 000000000000..73c0dd6d4737 --- /dev/null +++ b/samples/client/petstore/java/webclient/docs/ChildWithNullable.md @@ -0,0 +1,13 @@ + + +# ChildWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**otherProperty** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/webclient/docs/FakeApi.md b/samples/client/petstore/java/webclient/docs/FakeApi.md index 6eb12aee3577..df8b14be8e29 100644 --- a/samples/client/petstore/java/webclient/docs/FakeApi.md +++ b/samples/client/petstore/java/webclient/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1199,6 +1200,71 @@ No authorization required | **200** | successful operation | - | +## testNullable + +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.FakeApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); + + FakeApi apiInstance = new FakeApi(defaultClient); + ChildWithNullable childWithNullable = new ChildWithNullable(); // ChildWithNullable | request body + try { + apiInstance.testNullable(childWithNullable); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#testNullable"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | successful operation | - | + + ## testQueryParameterCollectionFormat > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/client/petstore/java/webclient/docs/ParentWithNullable.md b/samples/client/petstore/java/webclient/docs/ParentWithNullable.md new file mode 100644 index 000000000000..b8fcf6b42e8f --- /dev/null +++ b/samples/client/petstore/java/webclient/docs/ParentWithNullable.md @@ -0,0 +1,22 @@ + + +# ParentWithNullable + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | [**TypeEnum**](#TypeEnum) | | [optional] | +|**nullableProperty** | **String** | | [optional] | + + + +## Enum: TypeEnum + +| Name | Value | +|---- | -----| +| CHILDWITHNULLABLE | "ChildWithNullable" | + + + diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/api/FakeApi.java index a86605d1ae2f..da027dbd509a 100644 --- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/api/FakeApi.java @@ -3,6 +3,7 @@ import org.openapitools.client.ApiClient; import java.math.BigDecimal; +import org.openapitools.client.model.ChildWithNullable; import org.openapitools.client.model.Client; import org.openapitools.client.model.EnumClass; import org.openapitools.client.model.FakeBigDecimalMap200Response; @@ -1449,6 +1450,75 @@ public Mono> testJsonFormDataWithHttpInfo(String param, Str public ResponseSpec testJsonFormDataWithResponseSpec(String param, String param2) throws WebClientResponseException { return testJsonFormDataRequestCreation(param, param2); } + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + private ResponseSpec testNullableRequestCreation(ChildWithNullable childWithNullable) throws WebClientResponseException { + Object postBody = childWithNullable; + // verify the required parameter 'childWithNullable' is set + if (childWithNullable == null) { + throw new WebClientResponseException("Missing the required parameter 'childWithNullable' when calling testNullable", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); + } + // create path and map variables + final Map pathParams = new HashMap(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap cookieParams = new LinkedMultiValueMap(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI("/fake/nullable", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono testNullable(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).bodyToMono(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public Mono> testNullableWithHttpInfo(ChildWithNullable childWithNullable) throws WebClientResponseException { + ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return testNullableRequestCreation(childWithNullable).toEntity(localVarReturnType); + } + + /** + * test nullable parent property + * + *

200 - successful operation + * @param childWithNullable request body + * @return ResponseSpec + * @throws WebClientResponseException if an error occurs while attempting to invoke the API + */ + public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNullable) throws WebClientResponseException { + return testNullableRequestCreation(childWithNullable); + } /** * * To test the collection format in query parameters diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java new file mode 100644 index 000000000000..808a97496f36 --- /dev/null +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -0,0 +1,140 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) + +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + private String otherProperty; + + public ChildWithNullable() { + + } + + public ChildWithNullable otherProperty(String otherProperty) { + + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getOtherProperty() { + return otherProperty; + } + + + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + @Override + public ChildWithNullable type(TypeEnum type) { + this.setType(type); + return this; + } + + @Override + public ChildWithNullable nullableProperty(String nullableProperty) { + this.setNullableProperty(nullableProperty); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return Objects.equals(this.otherProperty, childWithNullable.otherProperty) && + super.equals(o); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(otherProperty, super.hashCode()); + } + + private static int hashCodeNullable(JsonNullable 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 ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java new file mode 100644 index 000000000000..b8ad35eda765 --- /dev/null +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -0,0 +1,203 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + protected TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + private JsonNullable nullableProperty = JsonNullable.undefined(); + + public ParentWithNullable() { + } + + public ParentWithNullable type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public TypeEnum getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @javax.annotation.Nullable + @JsonIgnore + + public String getNullableProperty() { + return nullableProperty.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public JsonNullable getNullableProperty_JsonNullable() { + return nullableProperty; + } + + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + public void setNullableProperty_JsonNullable(JsonNullable nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = JsonNullable.of(nullableProperty); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(this.type, parentWithNullable.type) && + equalsNullable(this.nullableProperty, parentWithNullable.nullableProperty); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(type, hashCodeNullable(nullableProperty)); + } + + private static int hashCodeNullable(JsonNullable 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 ParentWithNullable {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + +} + diff --git a/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..2616181bec30 --- /dev/null +++ b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ChildWithNullableTest.java @@ -0,0 +1,68 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.client.model.ParentWithNullable; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..bdd46008b13d --- /dev/null +++ b/samples/client/petstore/java/webclient/src/test/java/org/openapitools/client/model/ParentWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * 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.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +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 ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/client/petstore/k6/script.js b/samples/client/petstore/k6/script.js index f657d146f898..1416fe64534b 100644 --- a/samples/client/petstore/k6/script.js +++ b/samples/client/petstore/k6/script.js @@ -158,6 +158,22 @@ export default function() { } }); + group("/fake/nullable", () => { + + // Request No. 1: testNullable + { + let url = BASE_URL + `/fake/nullable`; + // TODO: edit the parameters of the request body. + let body = {"type": "string", "nullableProperty": "string", "otherProperty": "string"}; + let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}}; + let request = http.post(url, JSON.stringify(body), params); + + check(request, { + "successful operation": (r) => r.status === 200 + }); + } + }); + group("/fake_classname_test", () => { // Request No. 1: testClassname diff --git a/samples/client/petstore/perl/.openapi-generator/FILES b/samples/client/petstore/perl/.openapi-generator/FILES index d47a62bb7b31..0f9d770912c9 100644 --- a/samples/client/petstore/perl/.openapi-generator/FILES +++ b/samples/client/petstore/perl/.openapi-generator/FILES @@ -13,6 +13,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -47,6 +48,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -74,6 +76,7 @@ lib/WWW/OpenAPIClient/Object/ArrayTest.pm lib/WWW/OpenAPIClient/Object/Capitalization.pm lib/WWW/OpenAPIClient/Object/Cat.pm lib/WWW/OpenAPIClient/Object/Category.pm +lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm lib/WWW/OpenAPIClient/Object/ClassModel.pm lib/WWW/OpenAPIClient/Object/Client.pm lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm @@ -105,6 +108,7 @@ lib/WWW/OpenAPIClient/Object/OuterEnumDefaultValue.pm lib/WWW/OpenAPIClient/Object/OuterEnumInteger.pm lib/WWW/OpenAPIClient/Object/OuterEnumIntegerDefaultValue.pm lib/WWW/OpenAPIClient/Object/OuterObjectWithEnumProperty.pm +lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm lib/WWW/OpenAPIClient/Object/Pet.pm lib/WWW/OpenAPIClient/Object/ReadOnlyFirst.pm lib/WWW/OpenAPIClient/Object/SingleRefType.pm @@ -116,3 +120,5 @@ lib/WWW/OpenAPIClient/Role.pm lib/WWW/OpenAPIClient/Role/AutoDoc.pm lib/WWW/OpenAPIClient/StoreApi.pm lib/WWW/OpenAPIClient/UserApi.pm +t/ChildWithNullableTest.t +t/ParentWithNullableTest.t diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index dc7daa76c9a9..ca0ebd7ba0ed 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -252,6 +252,7 @@ use WWW::OpenAPIClient::Object::ArrayTest; use WWW::OpenAPIClient::Object::Capitalization; use WWW::OpenAPIClient::Object::Cat; use WWW::OpenAPIClient::Object::Category; +use WWW::OpenAPIClient::Object::ChildWithNullable; use WWW::OpenAPIClient::Object::ClassModel; use WWW::OpenAPIClient::Object::Client; use WWW::OpenAPIClient::Object::DeprecatedObject; @@ -283,6 +284,7 @@ use WWW::OpenAPIClient::Object::OuterEnumDefaultValue; use WWW::OpenAPIClient::Object::OuterEnumInteger; use WWW::OpenAPIClient::Object::OuterEnumIntegerDefaultValue; use WWW::OpenAPIClient::Object::OuterObjectWithEnumProperty; +use WWW::OpenAPIClient::Object::ParentWithNullable; use WWW::OpenAPIClient::Object::Pet; use WWW::OpenAPIClient::Object::ReadOnlyFirst; use WWW::OpenAPIClient::Object::SingleRefType; @@ -319,6 +321,7 @@ use WWW::OpenAPIClient::Object::ArrayTest; use WWW::OpenAPIClient::Object::Capitalization; use WWW::OpenAPIClient::Object::Cat; use WWW::OpenAPIClient::Object::Category; +use WWW::OpenAPIClient::Object::ChildWithNullable; use WWW::OpenAPIClient::Object::ClassModel; use WWW::OpenAPIClient::Object::Client; use WWW::OpenAPIClient::Object::DeprecatedObject; @@ -350,6 +353,7 @@ use WWW::OpenAPIClient::Object::OuterEnumDefaultValue; use WWW::OpenAPIClient::Object::OuterEnumInteger; use WWW::OpenAPIClient::Object::OuterEnumIntegerDefaultValue; use WWW::OpenAPIClient::Object::OuterObjectWithEnumProperty; +use WWW::OpenAPIClient::Object::ParentWithNullable; use WWW::OpenAPIClient::Object::Pet; use WWW::OpenAPIClient::Object::ReadOnlyFirst; use WWW::OpenAPIClient::Object::SingleRefType; @@ -401,6 +405,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_nullable**](docs/FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store @@ -437,6 +442,7 @@ Class | Method | HTTP request | Description - [WWW::OpenAPIClient::Object::Capitalization](docs/Capitalization.md) - [WWW::OpenAPIClient::Object::Cat](docs/Cat.md) - [WWW::OpenAPIClient::Object::Category](docs/Category.md) + - [WWW::OpenAPIClient::Object::ChildWithNullable](docs/ChildWithNullable.md) - [WWW::OpenAPIClient::Object::ClassModel](docs/ClassModel.md) - [WWW::OpenAPIClient::Object::Client](docs/Client.md) - [WWW::OpenAPIClient::Object::DeprecatedObject](docs/DeprecatedObject.md) @@ -468,6 +474,7 @@ Class | Method | HTTP request | Description - [WWW::OpenAPIClient::Object::OuterEnumInteger](docs/OuterEnumInteger.md) - [WWW::OpenAPIClient::Object::OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [WWW::OpenAPIClient::Object::OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [WWW::OpenAPIClient::Object::ParentWithNullable](docs/ParentWithNullable.md) - [WWW::OpenAPIClient::Object::Pet](docs/Pet.md) - [WWW::OpenAPIClient::Object::ReadOnlyFirst](docs/ReadOnlyFirst.md) - [WWW::OpenAPIClient::Object::SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/perl/docs/ChildWithNullable.md b/samples/client/petstore/perl/docs/ChildWithNullable.md new file mode 100644 index 000000000000..81016dd94043 --- /dev/null +++ b/samples/client/petstore/perl/docs/ChildWithNullable.md @@ -0,0 +1,15 @@ +# WWW::OpenAPIClient::Object::ChildWithNullable + +## Load the model package +```perl +use WWW::OpenAPIClient::Object::ChildWithNullable; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**other_property** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/docs/FakeApi.md b/samples/client/petstore/perl/docs/FakeApi.md index 546ef873a8a5..0bd3dce02b7e 100644 --- a/samples/client/petstore/perl/docs/FakeApi.md +++ b/samples/client/petstore/perl/docs/FakeApi.md @@ -26,6 +26,7 @@ Method | HTTP request | Description [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_nullable**](FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | @@ -859,6 +860,51 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_nullable** +> test_nullable(child_with_nullable => $child_with_nullable) + +test nullable parent property + + + +### Example +```perl +use Data::Dumper; +use WWW::OpenAPIClient::FakeApi; +my $api_instance = WWW::OpenAPIClient::FakeApi->new( +); + +my $child_with_nullable = WWW::OpenAPIClient::Object::ChildWithNullable->new(); # ChildWithNullable | request body + +eval { + $api_instance->test_nullable(child_with_nullable => $child_with_nullable); +}; +if ($@) { + warn "Exception when calling FakeApi->test_nullable: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **child_with_nullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_query_parameter_collection_format** > test_query_parameter_collection_format(pipe => $pipe, ioutil => $ioutil, http => $http, url => $url, context => $context, allow_empty => $allow_empty, language => $language) diff --git a/samples/client/petstore/perl/docs/ParentWithNullable.md b/samples/client/petstore/perl/docs/ParentWithNullable.md new file mode 100644 index 000000000000..d59af4c9bfb6 --- /dev/null +++ b/samples/client/petstore/perl/docs/ParentWithNullable.md @@ -0,0 +1,16 @@ +# WWW::OpenAPIClient::Object::ParentWithNullable + +## Load the model package +```perl +use WWW::OpenAPIClient::Object::ParentWithNullable; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | | [optional] +**nullable_property** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm index cdd5fa2cc102..e1a34b971625 100644 --- a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/FakeApi.pm @@ -1421,6 +1421,67 @@ sub test_json_form_data { return; } +# +# test_nullable +# +# test nullable parent property +# +# @param ChildWithNullable $child_with_nullable request body (required) +{ + my $params = { + 'child_with_nullable' => { + data_type => 'ChildWithNullable', + description => 'request body', + required => '1', + }, + }; + __PACKAGE__->method_documentation->{ 'test_nullable' } = { + summary => 'test nullable parent property', + params => $params, + returns => undef, + }; +} +# @return void +# +sub test_nullable { + my ($self, %args) = @_; + + # verify the required parameter 'child_with_nullable' is set + unless (exists $args{'child_with_nullable'}) { + croak("Missing the required parameter 'child_with_nullable' when calling test_nullable"); + } + + # parse inputs + my $_resource_path = '/fake/nullable'; + + my $_method = 'POST'; + my $query_params = {}; + my $header_params = {}; + my $form_params = {}; + + # 'Accept' and 'Content-Type' header + my $_header_accept = $self->{api_client}->select_header_accept(); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json'); + + my $_body_data; + # body params + if ( exists $args{'child_with_nullable'}) { + $_body_data = $args{'child_with_nullable'}; + } + + # authentication setting, if any + my $auth_settings = [qw()]; + + # make the API Call + $self->{api_client}->call_api($_resource_path, $_method, + $query_params, $form_params, + $header_params, $_body_data, $auth_settings); + return; +} + # # test_query_parameter_collection_format # diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm new file mode 100644 index 000000000000..cc553f3c22f1 --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm @@ -0,0 +1,255 @@ +=begin comment + +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 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +package WWW::OpenAPIClient::Object::ChildWithNullable; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + +use WWW::OpenAPIClient::Object::ParentWithNullable; + +use base ("Class::Accessor", "Class::Data::Inheritable", "WWW::OpenAPIClient::Object::ParentWithNullable"); + +# +# +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. +# REF: https://openapi-generator.tech +# + +=begin comment + +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 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('openapi_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new plain object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + $self->init(%args); + + return $self; +} + +# initialize the object +sub init +{ + my ($self, %args) = @_; + + foreach my $attribute (keys %{$self->attribute_map}) { + my $args_key = $self->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } + + # initialize parent object ParentWithNullable + $self->WWW::OpenAPIClient::Object::ParentWithNullable::init(%args); +} + +# return perl hash +sub to_hash { + my $self = shift; + my $_hash = decode_json(JSON->new->convert_blessed->encode($self)); + + # call ParentWithNullable to_hash and then combine hash + $_hash = { %$_hash, %$self->WWW::OpenAPIClient::Object::ParentWithNullable::to_hash }; + + return $_hash; +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + my $_json_attribute = $self->attribute_map->{$_key}; + my $_type = $self->openapi_types->{$_key}; + my $_value = $self->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + $_data->{$_json_attribute} = [ map { $self->_to_json_primitives($_subclass, $_) } @$_value ]; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$_value}) { + $_hash{$_key} = $self->_to_json_primitives($_subclass, $_element); + } + $_data->{$_json_attribute} = \%_hash; + } elsif ( grep( /^$_type$/, ('int', 'double', 'string', 'boolean', 'DATE', 'DATE_TIME'))) { + $_data->{$_json_attribute} = $self->_to_json_primitives($_type, $_value); + } else { + $_data->{$_json_attribute} = $_value; + } + } + } + + # combine parent (ParentWithNullable) TO_JSON + $_data = { %$_data, %$self->WWW::OpenAPIClient::Object::ParentWithNullable::TO_JSON }; + + return $_data; +} + +# to_json non-array data +sub _to_json_primitives { + my ($self, $type, $data) = @_; + if ( grep( /^$type$/, ('int', 'double'))) { + # https://metacpan.org/pod/JSON#simple-scalars + # numify it, ensuring it will be dumped as a number + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + # https://metacpan.org/pod/JSON#simple-scalars + # stringified + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + # https://metacpan.org/pod/JSON#JSON::true,-JSON::false,-JSON::null + return $data ? \1 : \0; + } elsif ($type eq 'DATE') { + return undef unless defined $data; + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Eymd($optional_separator),-$dt-%3Emdy(...),-$dt-%3Edmy(...) + return $data->ymd; + } + return $data .q(); + } elsif ($type eq 'DATE_TIME') { + return undef unless defined $data; + # the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Erfc3339 + return $data->rfc3339; + } + return $data .q(); + } else { # hash (model), In this case, the TO_JSON of the $data object is executed + return $data; + } +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use openapi_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->openapi_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) { + $_hash{$_key} = $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \%_hash; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + # call parent (ParentWithNullable) from_hash + $self->WWW::OpenAPIClient::Object::ParentWithNullable::from_hash($hash); + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if (grep( /^$type$/ , ('DATE_TIME', 'DATE'))) { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double'))) { + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + return !!$data; + } else { # hash(model) + my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + +__PACKAGE__->class_documentation({description => '', + class => 'ChildWithNullable', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'other_property' => { + datatype => 'string', + base_name => 'otherProperty', + description => '', + format => '', + read_only => '', + }, +}); + +__PACKAGE__->openapi_types( { + 'other_property' => 'string' +} ); + +__PACKAGE__->attribute_map( { + 'other_property' => 'otherProperty' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm new file mode 100644 index 000000000000..41e0c7927f2e --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ParentWithNullable.pm @@ -0,0 +1,251 @@ +=begin comment + +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 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +package WWW::OpenAPIClient::Object::ParentWithNullable; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + + +use base ("Class::Accessor", "Class::Data::Inheritable"); + +# +# +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. +# REF: https://openapi-generator.tech +# + +=begin comment + +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 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('openapi_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new plain object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + $self->init(%args); + + return $self; +} + +# initialize the object +sub init +{ + my ($self, %args) = @_; + + foreach my $attribute (keys %{$self->attribute_map}) { + my $args_key = $self->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } +} + +# return perl hash +sub to_hash { + my $self = shift; + my $_hash = decode_json(JSON->new->convert_blessed->encode($self)); + + return $_hash; +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + my $_json_attribute = $self->attribute_map->{$_key}; + my $_type = $self->openapi_types->{$_key}; + my $_value = $self->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + $_data->{$_json_attribute} = [ map { $self->_to_json_primitives($_subclass, $_) } @$_value ]; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$_value}) { + $_hash{$_key} = $self->_to_json_primitives($_subclass, $_element); + } + $_data->{$_json_attribute} = \%_hash; + } elsif ( grep( /^$_type$/, ('int', 'double', 'string', 'boolean', 'DATE', 'DATE_TIME'))) { + $_data->{$_json_attribute} = $self->_to_json_primitives($_type, $_value); + } else { + $_data->{$_json_attribute} = $_value; + } + } + } + + return $_data; +} + +# to_json non-array data +sub _to_json_primitives { + my ($self, $type, $data) = @_; + if ( grep( /^$type$/, ('int', 'double'))) { + # https://metacpan.org/pod/JSON#simple-scalars + # numify it, ensuring it will be dumped as a number + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + # https://metacpan.org/pod/JSON#simple-scalars + # stringified + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + # https://metacpan.org/pod/JSON#JSON::true,-JSON::false,-JSON::null + return $data ? \1 : \0; + } elsif ($type eq 'DATE') { + return undef unless defined $data; + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Eymd($optional_separator),-$dt-%3Emdy(...),-$dt-%3Edmy(...) + return $data->ymd; + } + return $data .q(); + } elsif ($type eq 'DATE_TIME') { + return undef unless defined $data; + # the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Erfc3339 + return $data->rfc3339; + } + return $data .q(); + } else { # hash (model), In this case, the TO_JSON of the $data object is executed + return $data; + } +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use openapi_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->openapi_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) { + $_hash{$_key} = $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \%_hash; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if (grep( /^$type$/ , ('DATE_TIME', 'DATE'))) { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double'))) { + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + return !!$data; + } else { # hash(model) + my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + +__PACKAGE__->class_documentation({description => '', + class => 'ParentWithNullable', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'type' => { + datatype => 'string', + base_name => 'type', + description => '', + format => '', + read_only => '', + }, + 'nullable_property' => { + datatype => 'string', + base_name => 'nullableProperty', + description => '', + format => '', + read_only => '', + }, +}); + +__PACKAGE__->openapi_types( { + 'type' => 'string', + 'nullable_property' => 'string' +} ); + +__PACKAGE__->attribute_map( { + 'type' => 'type', + 'nullable_property' => 'nullableProperty' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/t/ChildWithNullableTest.t b/samples/client/petstore/perl/t/ChildWithNullableTest.t new file mode 100644 index 000000000000..2823fc4b3ccb --- /dev/null +++ b/samples/client/petstore/perl/t/ChildWithNullableTest.t @@ -0,0 +1,34 @@ +=begin comment + +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 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the OpenAPI Generator +# Please update the test cases below to test the model. +# Ref: https://openapi-generator.tech +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::OpenAPIClient::Object::ChildWithNullable'); + +# uncomment below and update the test +#my $instance = WWW::OpenAPIClient::Object::ChildWithNullable->new(); +# +#isa_ok($instance, 'WWW::OpenAPIClient::Object::ChildWithNullable'); + diff --git a/samples/client/petstore/perl/t/ParentWithNullableTest.t b/samples/client/petstore/perl/t/ParentWithNullableTest.t new file mode 100644 index 000000000000..8ee9800aa3c3 --- /dev/null +++ b/samples/client/petstore/perl/t/ParentWithNullableTest.t @@ -0,0 +1,34 @@ +=begin comment + +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 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the OpenAPI Generator +# Please update the test cases below to test the model. +# Ref: https://openapi-generator.tech +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::OpenAPIClient::Object::ParentWithNullable'); + +# uncomment below and update the test +#my $instance = WWW::OpenAPIClient::Object::ParentWithNullable->new(); +# +#isa_ok($instance, 'WWW::OpenAPIClient::Object::ParentWithNullable'); + diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES b/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES index 35ba332017ce..f368009974a2 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES @@ -21,6 +21,7 @@ docs/Model/ArrayTest.md docs/Model/Capitalization.md docs/Model/Cat.md docs/Model/Category.md +docs/Model/ChildWithNullable.md docs/Model/ClassModel.md docs/Model/Client.md docs/Model/DeprecatedObject.md @@ -52,6 +53,7 @@ docs/Model/OuterEnumDefaultValue.md docs/Model/OuterEnumInteger.md docs/Model/OuterEnumIntegerDefaultValue.md docs/Model/OuterObjectWithEnumProperty.md +docs/Model/ParentWithNullable.md docs/Model/Pet.md docs/Model/ReadOnlyFirst.md docs/Model/SingleRefType.md @@ -80,6 +82,7 @@ src/Model/ArrayTest.php src/Model/Capitalization.php src/Model/Cat.php src/Model/Category.php +src/Model/ChildWithNullable.php src/Model/ClassModel.php src/Model/Client.php src/Model/DeprecatedObject.php @@ -112,6 +115,7 @@ src/Model/OuterEnumDefaultValue.php src/Model/OuterEnumInteger.php src/Model/OuterEnumIntegerDefaultValue.php src/Model/OuterObjectWithEnumProperty.php +src/Model/ParentWithNullable.php src/Model/Pet.php src/Model/ReadOnlyFirst.php src/Model/SingleRefType.php @@ -119,3 +123,5 @@ src/Model/SpecialModelName.php src/Model/Tag.php src/Model/User.php src/ObjectSerializer.php +tests/Model/ChildWithNullableTest.php +tests/Model/ParentWithNullableTest.php diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/README.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/README.md index 1daef015371b..86e65006e96a 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/README.md +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/README.md @@ -90,6 +90,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](docs/Api/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](docs/Api/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](docs/Api/FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](docs/Api/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store @@ -126,6 +127,7 @@ Class | Method | HTTP request | Description - [Capitalization](docs/Model/Capitalization.md) - [Cat](docs/Model/Cat.md) - [Category](docs/Model/Category.md) +- [ChildWithNullable](docs/Model/ChildWithNullable.md) - [ClassModel](docs/Model/ClassModel.md) - [Client](docs/Model/Client.md) - [DeprecatedObject](docs/Model/DeprecatedObject.md) @@ -157,6 +159,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](docs/Model/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](docs/Model/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](docs/Model/OuterObjectWithEnumProperty.md) +- [ParentWithNullable](docs/Model/ParentWithNullable.md) - [Pet](docs/Model/Pet.md) - [ReadOnlyFirst](docs/Model/ReadOnlyFirst.md) - [SingleRefType](docs/Model/SingleRefType.md) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/FakeApi.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/FakeApi.md index 6de683cdd9c0..67f8694a75f6 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/FakeApi.md +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to http://petstore.swagger.io:80/v2, except if the operati | [**testGroupParameters()**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**testInlineAdditionalProperties()**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**testJsonFormData()**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**testNullable()**](FakeApi.md#testNullable) | **POST** /fake/nullable | test nullable parent property | | [**testQueryParameterCollectionFormat()**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | | @@ -1032,6 +1033,61 @@ No authorization required [[Back to Model list]](../../README.md#models) [[Back to README]](../../README.md) +## `testNullable()` + +```php +testNullable($child_with_nullable) +``` + +test nullable parent property + + + +### Example + +```php +testNullable($child_with_nullable); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testNullable: ', $e->getMessage(), PHP_EOL; +} +``` + +### Parameters + +| Name | Type | Description | Notes | +| ------------- | ------------- | ------------- | ------------- | +| **child_with_nullable** | [**\OpenAPI\Client\Model\ChildWithNullable**](../Model/ChildWithNullable.md)| request body | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: `application/json` +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) +[[Back to Model list]](../../README.md#models) +[[Back to README]](../../README.md) + ## `testQueryParameterCollectionFormat()` ```php diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ChildWithNullable.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ChildWithNullable.md new file mode 100644 index 000000000000..be4cea23a36e --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ChildWithNullable.md @@ -0,0 +1,9 @@ +# # ChildWithNullable + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**other_property** | **string** | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ParentWithNullable.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ParentWithNullable.md new file mode 100644 index 000000000000..8f8080ef1411 --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/ParentWithNullable.md @@ -0,0 +1,10 @@ +# # ParentWithNullable + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **string** | | [optional] +**nullable_property** | **string** | | [optional] + +[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php index f42c0d5d2587..b2b16d68aef4 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php @@ -123,6 +123,9 @@ class FakeApi 'testJsonFormData' => [ 'application/x-www-form-urlencoded', ], + 'testNullable' => [ + 'application/json', + ], 'testQueryParameterCollectionFormat' => [ 'application/json', ], @@ -4803,6 +4806,234 @@ public function testJsonFormDataRequest($param, $param2, string $contentType = s ); } + /** + * Operation testNullable + * + * test nullable parent property + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function testNullable($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + $this->testNullableWithHttpInfo($child_with_nullable, $contentType); + } + + /** + * Operation testNullableWithHttpInfo + * + * test nullable parent property + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function testNullableWithHttpInfo($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + $request = $this->testNullableRequest($child_with_nullable, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation testNullableAsync + * + * test nullable parent property + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testNullableAsync($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + return $this->testNullableAsyncWithHttpInfo($child_with_nullable, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testNullableAsyncWithHttpInfo + * + * test nullable parent property + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testNullableAsyncWithHttpInfo($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + $returnType = ''; + $request = $this->testNullableRequest($child_with_nullable, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testNullable' + * + * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function testNullableRequest($child_with_nullable, string $contentType = self::contentTypes['testNullable'][0]) + { + + // verify the required parameter 'child_with_nullable' is set + if ($child_with_nullable === null || (is_array($child_with_nullable) && count($child_with_nullable) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $child_with_nullable when calling testNullable' + ); + } + + + $resourcePath = '/fake/nullable'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + + + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($child_with_nullable)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($child_with_nullable)); + } else { + $httpBody = $child_with_nullable; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; + foreach ($formParamValueItems as $formParamValueItem) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValueItem + ]; + } + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'POST', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Operation testQueryParameterCollectionFormat * diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php new file mode 100644 index 000000000000..11a3dd4a614a --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php @@ -0,0 +1,403 @@ + + */ +class ChildWithNullable extends ParentWithNullable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ChildWithNullable'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'other_property' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'other_property' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'other_property' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes + parent::openAPITypes(); + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats + parent::openAPIFormats(); + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables + parent::openAPINullables(); + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'other_property' => 'otherProperty' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'other_property' => 'setOtherProperty' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'other_property' => 'getOtherProperty' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return parent::attributeMap() + self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return parent::setters() + self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return parent::getters() + self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + parent::__construct($data); + + $this->setIfExists('other_property', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = parent::listInvalidProperties(); + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets other_property + * + * @return string|null + */ + public function getOtherProperty() + { + return $this->container['other_property']; + } + + /** + * Sets other_property + * + * @param string|null $other_property other_property + * + * @return self + */ + public function setOtherProperty($other_property) + { + if (is_null($other_property)) { + throw new \InvalidArgumentException('non-nullable other_property cannot be null'); + } + $this->container['other_property'] = $other_property; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php new file mode 100644 index 000000000000..83f01e1ac7af --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php @@ -0,0 +1,485 @@ + + */ +class ParentWithNullable implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = 'type'; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'ParentWithNullable'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'type' => 'string', + 'nullable_property' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'type' => null, + 'nullable_property' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'type' => false, + 'nullable_property' => true + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'type' => 'type', + 'nullable_property' => 'nullableProperty' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'type' => 'setType', + 'nullable_property' => 'setNullableProperty' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'type' => 'getType', + 'nullable_property' => 'getNullableProperty' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + public const TYPE_CHILD_WITH_NULLABLE = 'ChildWithNullable'; + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getTypeAllowableValues() + { + return [ + self::TYPE_CHILD_WITH_NULLABLE, + ]; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->setIfExists('type', $data ?? [], null); + $this->setIfExists('nullable_property', $data ?? [], null); + + // Initialize discriminator property with the model name. + $this->container['type'] = static::$openAPIModelName; + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getTypeAllowableValues(); + if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value '%s' for 'type', must be one of '%s'", + $this->container['type'], + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets type + * + * @return string|null + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string|null $type type + * + * @return self + */ + public function setType($type) + { + if (is_null($type)) { + throw new \InvalidArgumentException('non-nullable type cannot be null'); + } + $allowedValues = $this->getTypeAllowableValues(); + if (!in_array($type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value '%s' for 'type', must be one of '%s'", + $type, + implode("', '", $allowedValues) + ) + ); + } + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets nullable_property + * + * @return string|null + */ + public function getNullableProperty() + { + return $this->container['nullable_property']; + } + + /** + * Sets nullable_property + * + * @param string|null $nullable_property nullable_property + * + * @return self + */ + public function setNullableProperty($nullable_property) + { + if (is_null($nullable_property)) { + array_push($this->openAPINullablesSetToNull, 'nullable_property'); + } else { + $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); + $index = array_search('nullable_property', $nullablesSetToNull); + if ($index !== FALSE) { + unset($nullablesSetToNull[$index]); + $this->setOpenAPINullablesSetToNull($nullablesSetToNull); + } + } + $this->container['nullable_property'] = $nullable_property; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ChildWithNullableTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ChildWithNullableTest.php new file mode 100644 index 000000000000..ec5f69960a56 --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ChildWithNullableTest.php @@ -0,0 +1,90 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "other_property" + */ + public function testPropertyOtherProperty() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ParentWithNullableTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ParentWithNullableTest.php new file mode 100644 index 000000000000..05f491afca8b --- /dev/null +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Model/ParentWithNullableTest.php @@ -0,0 +1,99 @@ +markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "type" + */ + public function testPropertyType() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } + + /** + * Test attribute "nullable_property" + */ + public function testPropertyNullableProperty() + { + // TODO: implement + $this->markTestIncomplete('Not implemented'); + } +} diff --git a/samples/client/petstore/ruby-autoload/.openapi-generator/FILES b/samples/client/petstore/ruby-autoload/.openapi-generator/FILES index ed16a1e03d1c..401ceae858c9 100644 --- a/samples/client/petstore/ruby-autoload/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-autoload/.openapi-generator/FILES @@ -17,6 +17,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -51,6 +52,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -82,6 +84,7 @@ lib/petstore/models/array_test.rb lib/petstore/models/capitalization.rb lib/petstore/models/cat.rb lib/petstore/models/category.rb +lib/petstore/models/child_with_nullable.rb lib/petstore/models/class_model.rb lib/petstore/models/client.rb lib/petstore/models/deprecated_object.rb @@ -113,6 +116,7 @@ lib/petstore/models/outer_enum_default_value.rb lib/petstore/models/outer_enum_integer.rb lib/petstore/models/outer_enum_integer_default_value.rb lib/petstore/models/outer_object_with_enum_property.rb +lib/petstore/models/parent_with_nullable.rb lib/petstore/models/pet.rb lib/petstore/models/read_only_first.rb lib/petstore/models/single_ref_type.rb @@ -123,4 +127,6 @@ lib/petstore/version.rb petstore.gemspec spec/api_client_spec.rb spec/configuration_spec.rb +spec/models/child_with_nullable_spec.rb +spec/models/parent_with_nullable_spec.rb spec/spec_helper.rb diff --git a/samples/client/petstore/ruby-autoload/README.md b/samples/client/petstore/ruby-autoload/README.md index 24656471c4bc..ee269a91bf61 100644 --- a/samples/client/petstore/ruby-autoload/README.md +++ b/samples/client/petstore/ruby-autoload/README.md @@ -94,6 +94,7 @@ Class | Method | HTTP request | Description *Petstore::FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *Petstore::FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *Petstore::FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*Petstore::FakeApi* | [**test_nullable**](docs/FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property *Petstore::FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *Petstore::FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store @@ -131,6 +132,7 @@ Class | Method | HTTP request | Description - [Petstore::Capitalization](docs/Capitalization.md) - [Petstore::Cat](docs/Cat.md) - [Petstore::Category](docs/Category.md) + - [Petstore::ChildWithNullable](docs/ChildWithNullable.md) - [Petstore::ClassModel](docs/ClassModel.md) - [Petstore::Client](docs/Client.md) - [Petstore::DeprecatedObject](docs/DeprecatedObject.md) @@ -162,6 +164,7 @@ Class | Method | HTTP request | Description - [Petstore::OuterEnumInteger](docs/OuterEnumInteger.md) - [Petstore::OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [Petstore::OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [Petstore::ParentWithNullable](docs/ParentWithNullable.md) - [Petstore::Pet](docs/Pet.md) - [Petstore::ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Petstore::SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/ruby-autoload/docs/ChildWithNullable.md b/samples/client/petstore/ruby-autoload/docs/ChildWithNullable.md new file mode 100644 index 000000000000..3e6ffffc4d30 --- /dev/null +++ b/samples/client/petstore/ruby-autoload/docs/ChildWithNullable.md @@ -0,0 +1,18 @@ +# Petstore::ChildWithNullable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **other_property** | **String** | | [optional] | + +## Example + +```ruby +require 'petstore' + +instance = Petstore::ChildWithNullable.new( + other_property: null +) +``` + diff --git a/samples/client/petstore/ruby-autoload/docs/FakeApi.md b/samples/client/petstore/ruby-autoload/docs/FakeApi.md index 505e754f5ed4..3980b6c60d27 100644 --- a/samples/client/petstore/ruby-autoload/docs/FakeApi.md +++ b/samples/client/petstore/ruby-autoload/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**test_nullable**](FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property | | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | | @@ -1181,6 +1182,69 @@ No authorization required - **Accept**: Not defined +## test_nullable + +> test_nullable(child_with_nullable) + +test nullable parent property + + + +### Examples + +```ruby +require 'time' +require 'petstore' + +api_instance = Petstore::FakeApi.new +child_with_nullable = Petstore::ChildWithNullable.new # ChildWithNullable | request body + +begin + # test nullable parent property + api_instance.test_nullable(child_with_nullable) +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_nullable: #{e}" +end +``` + +#### Using the test_nullable_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> test_nullable_with_http_info(child_with_nullable) + +```ruby +begin + # test nullable parent property + data, status_code, headers = api_instance.test_nullable_with_http_info(child_with_nullable) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_nullable_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **child_with_nullable** | [**ChildWithNullable**](ChildWithNullable.md) | request body | | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + ## test_query_parameter_collection_format > test_query_parameter_collection_format(pipe, ioutil, http, url, context, allow_empty, opts) diff --git a/samples/client/petstore/ruby-autoload/docs/ParentWithNullable.md b/samples/client/petstore/ruby-autoload/docs/ParentWithNullable.md new file mode 100644 index 000000000000..0c77bf999dcb --- /dev/null +++ b/samples/client/petstore/ruby-autoload/docs/ParentWithNullable.md @@ -0,0 +1,20 @@ +# Petstore::ParentWithNullable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | | [optional] | +| **nullable_property** | **String** | | [optional] | + +## Example + +```ruby +require 'petstore' + +instance = Petstore::ParentWithNullable.new( + type: null, + nullable_property: null +) +``` + diff --git a/samples/client/petstore/ruby-autoload/lib/petstore.rb b/samples/client/petstore/ruby-autoload/lib/petstore.rb index 4fc54294b592..c4354c2b3123 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore.rb @@ -27,6 +27,7 @@ Petstore.autoload :Capitalization, 'petstore/models/capitalization' Petstore.autoload :Cat, 'petstore/models/cat' Petstore.autoload :Category, 'petstore/models/category' +Petstore.autoload :ChildWithNullable, 'petstore/models/child_with_nullable' Petstore.autoload :ClassModel, 'petstore/models/class_model' Petstore.autoload :Client, 'petstore/models/client' Petstore.autoload :DeprecatedObject, 'petstore/models/deprecated_object' @@ -58,6 +59,7 @@ Petstore.autoload :OuterEnumInteger, 'petstore/models/outer_enum_integer' Petstore.autoload :OuterEnumIntegerDefaultValue, 'petstore/models/outer_enum_integer_default_value' Petstore.autoload :OuterObjectWithEnumProperty, 'petstore/models/outer_object_with_enum_property' +Petstore.autoload :ParentWithNullable, 'petstore/models/parent_with_nullable' Petstore.autoload :Pet, 'petstore/models/pet' Petstore.autoload :ReadOnlyFirst, 'petstore/models/read_only_first' Petstore.autoload :SingleRefType, 'petstore/models/single_ref_type' diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby-autoload/lib/petstore/api/fake_api.rb index 554b0a48bc05..06e12cd00e55 100644 --- a/samples/client/petstore/ruby-autoload/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby-autoload/lib/petstore/api/fake_api.rb @@ -1294,6 +1294,72 @@ def test_json_form_data_with_http_info(param, param2, opts = {}) return data, status_code, headers end + # test nullable parent property + # + # @param child_with_nullable [ChildWithNullable] request body + # @param [Hash] opts the optional parameters + # @return [nil] + def test_nullable(child_with_nullable, opts = {}) + test_nullable_with_http_info(child_with_nullable, opts) + nil + end + + # test nullable parent property + # + # @param child_with_nullable [ChildWithNullable] request body + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def test_nullable_with_http_info(child_with_nullable, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_nullable ...' + end + # verify the required parameter 'child_with_nullable' is set + if @api_client.config.client_side_validation && child_with_nullable.nil? + fail ArgumentError, "Missing the required parameter 'child_with_nullable' when calling FakeApi.test_nullable" + end + # resource path + local_var_path = '/fake/nullable' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(child_with_nullable) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"FakeApi.test_nullable", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_nullable\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # To test the collection format in query parameters # @param pipe [Array] # @param ioutil [Array] diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb new file mode 100644 index 000000000000..e4027d5a7a0f --- /dev/null +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/child_with_nullable.rb @@ -0,0 +1,247 @@ +=begin +#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 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class ChildWithNullable < ParentWithNullable + attr_accessor :other_property + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'other_property' => :'otherProperty' + } + end + + # Returns all the JSON keys this model knows about, including the ones defined in its parent(s) + def self.acceptable_attributes + attribute_map.values.concat(superclass.acceptable_attributes) + end + + # Attribute type mapping. + def self.openapi_types + { + :'other_property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ParentWithNullable' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ChildWithNullable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ChildWithNullable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + # call parent's initialize + super(attributes) + + if attributes.key?(:'other_property') + self.other_property = attributes[:'other_property'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = super + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true && super + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + other_property == o.other_property && super(o) + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [other_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + super(attributes) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = super + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb new file mode 100644 index 000000000000..80d5b087caa7 --- /dev/null +++ b/samples/client/petstore/ruby-autoload/lib/petstore/models/parent_with_nullable.rb @@ -0,0 +1,263 @@ +=begin +#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 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class ParentWithNullable + attr_accessor :type + + attr_accessor :nullable_property + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'nullable_property' => :'nullableProperty' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'nullable_property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'nullable_property' + ]) + end + + # discriminator's property name in OpenAPI v3 + def self.openapi_discriminator_name + :'type' + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ParentWithNullable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ParentWithNullable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'nullable_property') + self.nullable_property = attributes[:'nullable_property'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["ChildWithNullable"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["ChildWithNullable"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + nullable_property == o.nullable_property + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, nullable_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby-autoload/spec/models/child_with_nullable_spec.rb b/samples/client/petstore/ruby-autoload/spec/models/child_with_nullable_spec.rb new file mode 100644 index 000000000000..2858c0502dbb --- /dev/null +++ b/samples/client/petstore/ruby-autoload/spec/models/child_with_nullable_spec.rb @@ -0,0 +1,34 @@ +=begin +#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 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ChildWithNullable +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Petstore::ChildWithNullable do + let(:instance) { Petstore::ChildWithNullable.new } + + describe 'test an instance of ChildWithNullable' do + it 'should create an instance of ChildWithNullable' do + expect(instance).to be_instance_of(Petstore::ChildWithNullable) + end + end + describe 'test attribute "other_property"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + +end diff --git a/samples/client/petstore/ruby-autoload/spec/models/parent_with_nullable_spec.rb b/samples/client/petstore/ruby-autoload/spec/models/parent_with_nullable_spec.rb new file mode 100644 index 000000000000..763820497048 --- /dev/null +++ b/samples/client/petstore/ruby-autoload/spec/models/parent_with_nullable_spec.rb @@ -0,0 +1,44 @@ +=begin +#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 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ParentWithNullable +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Petstore::ParentWithNullable do + let(:instance) { Petstore::ParentWithNullable.new } + + describe 'test an instance of ParentWithNullable' do + it 'should create an instance of ParentWithNullable' do + expect(instance).to be_instance_of(Petstore::ParentWithNullable) + end + end + describe 'test attribute "type"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["ChildWithNullable"]) + # validator.allowable_values.each do |value| + # expect { instance.type = value }.not_to raise_error + # end + end + end + + describe 'test attribute "nullable_property"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + +end diff --git a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES index ed16a1e03d1c..401ceae858c9 100644 --- a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES @@ -17,6 +17,7 @@ docs/ArrayTest.md docs/Capitalization.md docs/Cat.md docs/Category.md +docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md @@ -51,6 +52,7 @@ docs/OuterEnumDefaultValue.md docs/OuterEnumInteger.md docs/OuterEnumIntegerDefaultValue.md docs/OuterObjectWithEnumProperty.md +docs/ParentWithNullable.md docs/Pet.md docs/PetApi.md docs/ReadOnlyFirst.md @@ -82,6 +84,7 @@ lib/petstore/models/array_test.rb lib/petstore/models/capitalization.rb lib/petstore/models/cat.rb lib/petstore/models/category.rb +lib/petstore/models/child_with_nullable.rb lib/petstore/models/class_model.rb lib/petstore/models/client.rb lib/petstore/models/deprecated_object.rb @@ -113,6 +116,7 @@ lib/petstore/models/outer_enum_default_value.rb lib/petstore/models/outer_enum_integer.rb lib/petstore/models/outer_enum_integer_default_value.rb lib/petstore/models/outer_object_with_enum_property.rb +lib/petstore/models/parent_with_nullable.rb lib/petstore/models/pet.rb lib/petstore/models/read_only_first.rb lib/petstore/models/single_ref_type.rb @@ -123,4 +127,6 @@ lib/petstore/version.rb petstore.gemspec spec/api_client_spec.rb spec/configuration_spec.rb +spec/models/child_with_nullable_spec.rb +spec/models/parent_with_nullable_spec.rb spec/spec_helper.rb diff --git a/samples/client/petstore/ruby-faraday/README.md b/samples/client/petstore/ruby-faraday/README.md index 24656471c4bc..ee269a91bf61 100644 --- a/samples/client/petstore/ruby-faraday/README.md +++ b/samples/client/petstore/ruby-faraday/README.md @@ -94,6 +94,7 @@ Class | Method | HTTP request | Description *Petstore::FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *Petstore::FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *Petstore::FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*Petstore::FakeApi* | [**test_nullable**](docs/FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property *Petstore::FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *Petstore::FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store @@ -131,6 +132,7 @@ Class | Method | HTTP request | Description - [Petstore::Capitalization](docs/Capitalization.md) - [Petstore::Cat](docs/Cat.md) - [Petstore::Category](docs/Category.md) + - [Petstore::ChildWithNullable](docs/ChildWithNullable.md) - [Petstore::ClassModel](docs/ClassModel.md) - [Petstore::Client](docs/Client.md) - [Petstore::DeprecatedObject](docs/DeprecatedObject.md) @@ -162,6 +164,7 @@ Class | Method | HTTP request | Description - [Petstore::OuterEnumInteger](docs/OuterEnumInteger.md) - [Petstore::OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md) - [Petstore::OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md) + - [Petstore::ParentWithNullable](docs/ParentWithNullable.md) - [Petstore::Pet](docs/Pet.md) - [Petstore::ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Petstore::SingleRefType](docs/SingleRefType.md) diff --git a/samples/client/petstore/ruby-faraday/docs/ChildWithNullable.md b/samples/client/petstore/ruby-faraday/docs/ChildWithNullable.md new file mode 100644 index 000000000000..3e6ffffc4d30 --- /dev/null +++ b/samples/client/petstore/ruby-faraday/docs/ChildWithNullable.md @@ -0,0 +1,18 @@ +# Petstore::ChildWithNullable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **other_property** | **String** | | [optional] | + +## Example + +```ruby +require 'petstore' + +instance = Petstore::ChildWithNullable.new( + other_property: null +) +``` + diff --git a/samples/client/petstore/ruby-faraday/docs/FakeApi.md b/samples/client/petstore/ruby-faraday/docs/FakeApi.md index 505e754f5ed4..3980b6c60d27 100644 --- a/samples/client/petstore/ruby-faraday/docs/FakeApi.md +++ b/samples/client/petstore/ruby-faraday/docs/FakeApi.md @@ -21,6 +21,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) | | [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties | | [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data | +| [**test_nullable**](FakeApi.md#test_nullable) | **POST** /fake/nullable | test nullable parent property | | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | | @@ -1181,6 +1182,69 @@ No authorization required - **Accept**: Not defined +## test_nullable + +> test_nullable(child_with_nullable) + +test nullable parent property + + + +### Examples + +```ruby +require 'time' +require 'petstore' + +api_instance = Petstore::FakeApi.new +child_with_nullable = Petstore::ChildWithNullable.new # ChildWithNullable | request body + +begin + # test nullable parent property + api_instance.test_nullable(child_with_nullable) +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_nullable: #{e}" +end +``` + +#### Using the test_nullable_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> test_nullable_with_http_info(child_with_nullable) + +```ruby +begin + # test nullable parent property + data, status_code, headers = api_instance.test_nullable_with_http_info(child_with_nullable) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Petstore::ApiError => e + puts "Error when calling FakeApi->test_nullable_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **child_with_nullable** | [**ChildWithNullable**](ChildWithNullable.md) | request body | | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + ## test_query_parameter_collection_format > test_query_parameter_collection_format(pipe, ioutil, http, url, context, allow_empty, opts) diff --git a/samples/client/petstore/ruby-faraday/docs/ParentWithNullable.md b/samples/client/petstore/ruby-faraday/docs/ParentWithNullable.md new file mode 100644 index 000000000000..0c77bf999dcb --- /dev/null +++ b/samples/client/petstore/ruby-faraday/docs/ParentWithNullable.md @@ -0,0 +1,20 @@ +# Petstore::ParentWithNullable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | | [optional] | +| **nullable_property** | **String** | | [optional] | + +## Example + +```ruby +require 'petstore' + +instance = Petstore::ParentWithNullable.new( + type: null, + nullable_property: null +) +``` + diff --git a/samples/client/petstore/ruby-faraday/lib/petstore.rb b/samples/client/petstore/ruby-faraday/lib/petstore.rb index 2a1517673953..6c6330b609ea 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore.rb @@ -56,6 +56,7 @@ require 'petstore/models/outer_enum_integer' require 'petstore/models/outer_enum_integer_default_value' require 'petstore/models/outer_object_with_enum_property' +require 'petstore/models/parent_with_nullable' require 'petstore/models/pet' require 'petstore/models/read_only_first' require 'petstore/models/single_ref_type' @@ -63,6 +64,7 @@ require 'petstore/models/tag' require 'petstore/models/user' require 'petstore/models/cat' +require 'petstore/models/child_with_nullable' require 'petstore/models/dog' # APIs diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb index 554b0a48bc05..06e12cd00e55 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore/api/fake_api.rb @@ -1294,6 +1294,72 @@ def test_json_form_data_with_http_info(param, param2, opts = {}) return data, status_code, headers end + # test nullable parent property + # + # @param child_with_nullable [ChildWithNullable] request body + # @param [Hash] opts the optional parameters + # @return [nil] + def test_nullable(child_with_nullable, opts = {}) + test_nullable_with_http_info(child_with_nullable, opts) + nil + end + + # test nullable parent property + # + # @param child_with_nullable [ChildWithNullable] request body + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def test_nullable_with_http_info(child_with_nullable, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_nullable ...' + end + # verify the required parameter 'child_with_nullable' is set + if @api_client.config.client_side_validation && child_with_nullable.nil? + fail ArgumentError, "Missing the required parameter 'child_with_nullable' when calling FakeApi.test_nullable" + end + # resource path + local_var_path = '/fake/nullable' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(child_with_nullable) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"FakeApi.test_nullable", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_nullable\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # To test the collection format in query parameters # @param pipe [Array] # @param ioutil [Array] diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/child_with_nullable.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/child_with_nullable.rb new file mode 100644 index 000000000000..e4027d5a7a0f --- /dev/null +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/child_with_nullable.rb @@ -0,0 +1,247 @@ +=begin +#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 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class ChildWithNullable < ParentWithNullable + attr_accessor :other_property + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'other_property' => :'otherProperty' + } + end + + # Returns all the JSON keys this model knows about, including the ones defined in its parent(s) + def self.acceptable_attributes + attribute_map.values.concat(superclass.acceptable_attributes) + end + + # Attribute type mapping. + def self.openapi_types + { + :'other_property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ParentWithNullable' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ChildWithNullable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ChildWithNullable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + # call parent's initialize + super(attributes) + + if attributes.key?(:'other_property') + self.other_property = attributes[:'other_property'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = super + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true && super + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + other_property == o.other_property && super(o) + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [other_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + super(attributes) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = super + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/parent_with_nullable.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/parent_with_nullable.rb new file mode 100644 index 000000000000..80d5b087caa7 --- /dev/null +++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/parent_with_nullable.rb @@ -0,0 +1,263 @@ +=begin +#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 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'date' +require 'time' + +module Petstore + class ParentWithNullable + attr_accessor :type + + attr_accessor :nullable_property + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'nullable_property' => :'nullableProperty' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'nullable_property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'nullable_property' + ]) + end + + # discriminator's property name in OpenAPI v3 + def self.openapi_discriminator_name + :'type' + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ParentWithNullable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ParentWithNullable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'nullable_property') + self.nullable_property = attributes[:'nullable_property'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["ChildWithNullable"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["ChildWithNullable"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + nullable_property == o.nullable_property + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, nullable_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Petstore.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/samples/client/petstore/ruby-faraday/spec/models/child_with_nullable_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/child_with_nullable_spec.rb new file mode 100644 index 000000000000..2858c0502dbb --- /dev/null +++ b/samples/client/petstore/ruby-faraday/spec/models/child_with_nullable_spec.rb @@ -0,0 +1,34 @@ +=begin +#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 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ChildWithNullable +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Petstore::ChildWithNullable do + let(:instance) { Petstore::ChildWithNullable.new } + + describe 'test an instance of ChildWithNullable' do + it 'should create an instance of ChildWithNullable' do + expect(instance).to be_instance_of(Petstore::ChildWithNullable) + end + end + describe 'test attribute "other_property"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + +end diff --git a/samples/client/petstore/ruby-faraday/spec/models/parent_with_nullable_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/parent_with_nullable_spec.rb new file mode 100644 index 000000000000..763820497048 --- /dev/null +++ b/samples/client/petstore/ruby-faraday/spec/models/parent_with_nullable_spec.rb @@ -0,0 +1,44 @@ +=begin +#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 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ParentWithNullable +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe Petstore::ParentWithNullable do + let(:instance) { Petstore::ParentWithNullable.new } + + describe 'test an instance of ParentWithNullable' do + it 'should create an instance of ParentWithNullable' do + expect(instance).to be_instance_of(Petstore::ParentWithNullable) + end + end + describe 'test attribute "type"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["ChildWithNullable"]) + # validator.allowable_values.each do |value| + # expect { instance.type = value }.not_to raise_error + # end + end + end + + describe 'test attribute "nullable_property"' do + it 'should work' do + # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ + end + end + +end diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES b/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES index 0015dca0c838..ac49dcd75a09 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/.openapi-generator/FILES @@ -16,6 +16,7 @@ models/ArrayTest.ts models/Capitalization.ts models/Cat.ts models/Category.ts +models/ChildWithNullable.ts models/ClassModel.ts models/Client.ts models/DeprecatedObject.ts @@ -47,6 +48,7 @@ models/OuterEnumDefaultValue.ts models/OuterEnumInteger.ts models/OuterEnumIntegerDefaultValue.ts models/OuterObjectWithEnumProperty.ts +models/ParentWithNullable.ts models/Pet.ts models/ReadOnlyFirst.ts models/Return.ts diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts index 0d9ea6361d7c..06eb695d3fa6 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts @@ -15,6 +15,7 @@ import * as runtime from '../runtime'; import type { + ChildWithNullable, Client, EnumClass, FakeBigDecimalMap200Response, @@ -26,6 +27,8 @@ import type { User, } from '../models/index'; import { + ChildWithNullableFromJSON, + ChildWithNullableToJSON, ClientFromJSON, ClientToJSON, EnumClassFromJSON, @@ -136,6 +139,10 @@ export interface TestJsonFormDataRequest { param2: string; } +export interface TestNullableRequest { + childWithNullable: ChildWithNullable; +} + export interface TestQueryParameterCollectionFormatRequest { pipe: Array; ioutil: Array; @@ -901,6 +908,40 @@ export class FakeApi extends runtime.BaseAPI { await this.testJsonFormDataRaw(requestParameters, initOverrides); } + /** + * + * test nullable parent property + */ + async testNullableRaw(requestParameters: TestNullableRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.childWithNullable === null || requestParameters.childWithNullable === undefined) { + throw new runtime.RequiredError('childWithNullable','Required parameter requestParameters.childWithNullable was null or undefined when calling testNullable.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/fake/nullable`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: ChildWithNullableToJSON(requestParameters.childWithNullable), + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * + * test nullable parent property + */ + async testNullable(requestParameters: TestNullableRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.testNullableRaw(requestParameters, initOverrides); + } + /** * To test the collection format in query parameters */ diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts new file mode 100644 index 000000000000..4f53b0070e4b --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ChildWithNullable.ts @@ -0,0 +1,74 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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. + */ + +import { exists, mapValues } from '../runtime'; +import type { ParentWithNullable } from './ParentWithNullable'; +import { + ParentWithNullableFromJSON, + ParentWithNullableFromJSONTyped, + ParentWithNullableToJSON, +} from './ParentWithNullable'; + +/** + * + * @export + * @interface ChildWithNullable + */ +export interface ChildWithNullable extends ParentWithNullable { + /** + * + * @type {string} + * @memberof ChildWithNullable + */ + otherProperty?: string; +} + + + +/** + * Check if a given object implements the ChildWithNullable interface. + */ +export function instanceOfChildWithNullable(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function ChildWithNullableFromJSON(json: any): ChildWithNullable { + return ChildWithNullableFromJSONTyped(json, false); +} + +export function ChildWithNullableFromJSONTyped(json: any, ignoreDiscriminator: boolean): ChildWithNullable { + if ((json === undefined) || (json === null)) { + return json; + } + return { + ...ParentWithNullableFromJSONTyped(json, ignoreDiscriminator), + 'otherProperty': !exists(json, 'otherProperty') ? undefined : json['otherProperty'], + }; +} + +export function ChildWithNullableToJSON(value?: ChildWithNullable | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + ...ParentWithNullableToJSON(value), + 'otherProperty': value.otherProperty, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts new file mode 100644 index 000000000000..67c7574c229d --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts @@ -0,0 +1,92 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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. + */ + +import { exists, mapValues } from '../runtime'; +import { + ChildWithNullableFromJSONTyped +} from './index'; + +/** + * + * @export + * @interface ParentWithNullable + */ +export interface ParentWithNullable { + /** + * + * @type {string} + * @memberof ParentWithNullable + */ + type?: ParentWithNullableTypeEnum; + /** + * + * @type {string} + * @memberof ParentWithNullable + */ + nullableProperty?: string | null; +} + + +/** + * @export + */ +export const ParentWithNullableTypeEnum = { + ChildWithNullable: 'ChildWithNullable' +} as const; +export type ParentWithNullableTypeEnum = typeof ParentWithNullableTypeEnum[keyof typeof ParentWithNullableTypeEnum]; + + +/** + * Check if a given object implements the ParentWithNullable interface. + */ +export function instanceOfParentWithNullable(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function ParentWithNullableFromJSON(json: any): ParentWithNullable { + return ParentWithNullableFromJSONTyped(json, false); +} + +export function ParentWithNullableFromJSONTyped(json: any, ignoreDiscriminator: boolean): ParentWithNullable { + if ((json === undefined) || (json === null)) { + return json; + } + if (!ignoreDiscriminator) { + if (json['type'] === 'ChildWithNullable') { + return ChildWithNullableFromJSONTyped(json, true); + } + } + return { + + 'type': !exists(json, 'type') ? undefined : json['type'], + 'nullableProperty': !exists(json, 'nullableProperty') ? undefined : json['nullableProperty'], + }; +} + +export function ParentWithNullableToJSON(value?: ParentWithNullable | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'type': value.type, + 'nullableProperty': value.nullableProperty, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts index 20b510f62cbf..1789038a2d95 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/index.ts @@ -9,6 +9,7 @@ export * from './ArrayTest'; export * from './Capitalization'; export * from './Cat'; export * from './Category'; +export * from './ChildWithNullable'; export * from './ClassModel'; export * from './Client'; export * from './DeprecatedObject'; @@ -40,6 +41,7 @@ export * from './OuterEnumDefaultValue'; export * from './OuterEnumInteger'; export * from './OuterEnumIntegerDefaultValue'; export * from './OuterObjectWithEnumProperty'; +export * from './ParentWithNullable'; export * from './Pet'; export * from './ReadOnlyFirst'; export * from './Return'; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES index fd331c256c8c..bed568d3b7ff 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES @@ -13,6 +13,7 @@ doc/ArrayTest.md doc/Capitalization.md doc/Cat.md doc/Category.md +doc/ChildWithNullable.md doc/ClassModel.md doc/DefaultApi.md doc/DeprecatedObject.md @@ -47,6 +48,7 @@ doc/OuterEnumDefaultValue.md doc/OuterEnumInteger.md doc/OuterEnumIntegerDefaultValue.md doc/OuterObjectWithEnumProperty.md +doc/ParentWithNullable.md doc/Pet.md doc/PetApi.md doc/ReadOnlyFirst.md @@ -81,6 +83,7 @@ lib/src/model/array_test.dart lib/src/model/capitalization.dart lib/src/model/cat.dart lib/src/model/category.dart +lib/src/model/child_with_nullable.dart lib/src/model/class_model.dart lib/src/model/deprecated_object.dart lib/src/model/dog.dart @@ -112,6 +115,7 @@ lib/src/model/outer_enum_default_value.dart lib/src/model/outer_enum_integer.dart lib/src/model/outer_enum_integer_default_value.dart lib/src/model/outer_object_with_enum_property.dart +lib/src/model/parent_with_nullable.dart lib/src/model/pet.dart lib/src/model/read_only_first.dart lib/src/model/single_ref_type.dart @@ -119,3 +123,5 @@ lib/src/model/special_model_name.dart lib/src/model/tag.dart lib/src/model/user.dart pubspec.yaml +test/child_with_nullable_test.dart +test/parent_with_nullable_test.dart diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md index 8506db54bbfc..42ba566440d4 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md @@ -84,6 +84,7 @@ Class | Method | HTTP request | Description [*FakeApi*](doc/FakeApi.md) | [**testGroupParameters**](doc/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [*FakeApi*](doc/FakeApi.md) | [**testInlineAdditionalProperties**](doc/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [*FakeApi*](doc/FakeApi.md) | [**testJsonFormData**](doc/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[*FakeApi*](doc/FakeApi.md) | [**testNullable**](doc/FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [*FakeApi*](doc/FakeApi.md) | [**testQueryParameterCollectionFormat**](doc/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | [*FakeClassnameTags123Api*](doc/FakeClassnameTags123Api.md) | [**testClassname**](doc/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case [*PetApi*](doc/PetApi.md) | [**addPet**](doc/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store @@ -121,6 +122,7 @@ Class | Method | HTTP request | Description - [Capitalization](doc/Capitalization.md) - [Cat](doc/Cat.md) - [Category](doc/Category.md) + - [ChildWithNullable](doc/ChildWithNullable.md) - [ClassModel](doc/ClassModel.md) - [DeprecatedObject](doc/DeprecatedObject.md) - [Dog](doc/Dog.md) @@ -152,6 +154,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](doc/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](doc/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](doc/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](doc/ParentWithNullable.md) - [Pet](doc/Pet.md) - [ReadOnlyFirst](doc/ReadOnlyFirst.md) - [SingleRefType](doc/SingleRefType.md) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ChildWithNullable.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ChildWithNullable.md new file mode 100644 index 000000000000..770494fcf4cc --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ChildWithNullable.md @@ -0,0 +1,17 @@ +# openapi.model.ChildWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] +**otherProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/FakeApi.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/FakeApi.md index 1587283037ec..41328617a637 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/FakeApi.md @@ -26,6 +26,7 @@ Method | HTTP request | Description [**testGroupParameters**](FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[**testNullable**](FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [**testQueryParameterCollectionFormat**](FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | @@ -800,6 +801,48 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **testNullable** +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example +```dart +import 'package:openapi/api.dart'; + +final api = Openapi().getFakeApi(); +final ChildWithNullable childWithNullable = ; // ChildWithNullable | request body + +try { + api.testNullable(childWithNullable); +} catch on DioException (e) { + print('Exception when calling FakeApi->testNullable: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **testQueryParameterCollectionFormat** > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ParentWithNullable.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ParentWithNullable.md new file mode 100644 index 000000000000..17aa5ca02941 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/ParentWithNullable.md @@ -0,0 +1,16 @@ +# openapi.model.ParentWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/openapi.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/openapi.dart index 48d2103d57d9..81f241899a7d 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/openapi.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/openapi.dart @@ -26,6 +26,7 @@ export 'package:openapi/src/model/array_test.dart'; export 'package:openapi/src/model/capitalization.dart'; export 'package:openapi/src/model/cat.dart'; export 'package:openapi/src/model/category.dart'; +export 'package:openapi/src/model/child_with_nullable.dart'; export 'package:openapi/src/model/class_model.dart'; export 'package:openapi/src/model/deprecated_object.dart'; export 'package:openapi/src/model/dog.dart'; @@ -57,6 +58,7 @@ export 'package:openapi/src/model/outer_enum_default_value.dart'; export 'package:openapi/src/model/outer_enum_integer.dart'; export 'package:openapi/src/model/outer_enum_integer_default_value.dart'; export 'package:openapi/src/model/outer_object_with_enum_property.dart'; +export 'package:openapi/src/model/parent_with_nullable.dart'; export 'package:openapi/src/model/pet.dart'; export 'package:openapi/src/model/read_only_first.dart'; export 'package:openapi/src/model/single_ref_type.dart'; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart index a6dd002c83cb..8335114effdc 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart @@ -9,6 +9,7 @@ import 'dart:convert'; import 'package:openapi/src/deserialize.dart'; import 'package:dio/dio.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; import 'package:openapi/src/model/fake_big_decimal_map200_response.dart'; import 'package:openapi/src/model/file_schema_test_class.dart'; import 'package:openapi/src/model/health_check_result.dart'; @@ -1377,6 +1378,71 @@ _bodyData=jsonEncode(requestBody); return _response; } + /// test nullable parent property + /// + /// + /// Parameters: + /// * [childWithNullable] - request body + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] + /// Throws [DioException] if API call or serialization fails + Future> testNullable({ + required ChildWithNullable childWithNullable, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/fake/nullable'; + final _options = Options( + method: r'POST', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { +_bodyData=jsonEncode(childWithNullable); + } catch(error, stackTrace) { + throw DioException( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioExceptionType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + return _response; + } + /// testQueryParameterCollectionFormat /// To test the collection format in query parameters /// diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart index 8babb656e60e..6a8bc0d47040 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart @@ -8,6 +8,7 @@ import 'package:openapi/src/model/array_test.dart'; import 'package:openapi/src/model/capitalization.dart'; import 'package:openapi/src/model/cat.dart'; import 'package:openapi/src/model/category.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; import 'package:openapi/src/model/class_model.dart'; import 'package:openapi/src/model/deprecated_object.dart'; import 'package:openapi/src/model/dog.dart'; @@ -34,6 +35,7 @@ import 'package:openapi/src/model/object_with_deprecated_fields.dart'; import 'package:openapi/src/model/order.dart'; import 'package:openapi/src/model/outer_composite.dart'; import 'package:openapi/src/model/outer_object_with_enum_property.dart'; +import 'package:openapi/src/model/parent_with_nullable.dart'; import 'package:openapi/src/model/pet.dart'; import 'package:openapi/src/model/read_only_first.dart'; import 'package:openapi/src/model/special_model_name.dart'; @@ -78,6 +80,8 @@ final _regMap = RegExp(r'^Map$'); return Cat.fromJson(value as Map) as ReturnType; case 'Category': return Category.fromJson(value as Map) as ReturnType; + case 'ChildWithNullable': + return ChildWithNullable.fromJson(value as Map) as ReturnType; case 'ClassModel': return ClassModel.fromJson(value as Map) as ReturnType; case 'DeprecatedObject': @@ -145,6 +149,8 @@ final _regMap = RegExp(r'^Map$'); case 'OuterObjectWithEnumProperty': return OuterObjectWithEnumProperty.fromJson(value as Map) as ReturnType; + case 'ParentWithNullable': + return ParentWithNullable.fromJson(value as Map) as ReturnType; case 'Pet': return Pet.fromJson(value as Map) as ReturnType; case 'ReadOnlyFirst': diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart new file mode 100644 index 000000000000..674a58ca893e --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart @@ -0,0 +1,98 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:openapi/src/model/parent_with_nullable.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'child_with_nullable.g.dart'; + +// ignore_for_file: unused_import + + +@JsonSerializable( + checked: true, + createToJson: true, + disallowUnrecognizedKeys: false, + explicitToJson: true, +) +class ChildWithNullable { + /// Returns a new [ChildWithNullable] instance. + ChildWithNullable({ + + this.type, + + this.nullableProperty, + + this.otherProperty, + }); + + @JsonKey( + + name: r'type', + required: false, + includeIfNull: false + ) + + + final ChildWithNullableTypeEnum? type; + + + + @JsonKey( + + name: r'nullableProperty', + required: false, + includeIfNull: false + ) + + + final String? nullableProperty; + + + + @JsonKey( + + name: r'otherProperty', + required: false, + includeIfNull: false + ) + + + final String? otherProperty; + + + + @override + bool operator ==(Object other) => identical(this, other) || other is ChildWithNullable && + other.type == type && + other.nullableProperty == nullableProperty && + other.otherProperty == otherProperty; + + @override + int get hashCode => + type.hashCode + + (nullableProperty == null ? 0 : nullableProperty.hashCode) + + otherProperty.hashCode; + + factory ChildWithNullable.fromJson(Map json) => _$ChildWithNullableFromJson(json); + + Map toJson() => _$ChildWithNullableToJson(this); + + @override + String toString() { + return toJson().toString(); + } + +} + + +enum ChildWithNullableTypeEnum { + @JsonValue(r'ChildWithNullable') + childWithNullable, + @JsonValue(r'unknown_default_open_api') + unknownDefaultOpenApi, +} + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart new file mode 100644 index 000000000000..0490c4b2b078 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart @@ -0,0 +1,79 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:json_annotation/json_annotation.dart'; + +part 'parent_with_nullable.g.dart'; + + +@JsonSerializable( + checked: true, + createToJson: true, + disallowUnrecognizedKeys: false, + explicitToJson: true, +) +class ParentWithNullable { + /// Returns a new [ParentWithNullable] instance. + ParentWithNullable({ + + this.type, + + this.nullableProperty, + }); + + @JsonKey( + + name: r'type', + required: false, + includeIfNull: false + ) + + + final ParentWithNullableTypeEnum? type; + + + + @JsonKey( + + name: r'nullableProperty', + required: false, + includeIfNull: false + ) + + + final String? nullableProperty; + + + + @override + bool operator ==(Object other) => identical(this, other) || other is ParentWithNullable && + other.type == type && + other.nullableProperty == nullableProperty; + + @override + int get hashCode => + type.hashCode + + (nullableProperty == null ? 0 : nullableProperty.hashCode); + + factory ParentWithNullable.fromJson(Map json) => _$ParentWithNullableFromJson(json); + + Map toJson() => _$ParentWithNullableToJson(this); + + @override + String toString() { + return toJson().toString(); + } + +} + + +enum ParentWithNullableTypeEnum { + @JsonValue(r'ChildWithNullable') + childWithNullable, + @JsonValue(r'unknown_default_open_api') + unknownDefaultOpenApi, +} + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/child_with_nullable_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/child_with_nullable_test.dart new file mode 100644 index 000000000000..ce2afd9a8a6e --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/child_with_nullable_test.dart @@ -0,0 +1,26 @@ +import 'package:test/test.dart'; +import 'package:openapi/openapi.dart'; + +// tests for ChildWithNullable +void main() { + final ChildWithNullable? instance = /* ChildWithNullable(...) */ null; + // TODO add properties to the entity + + group(ChildWithNullable, () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + // String otherProperty + test('to test the property `otherProperty`', () async { + // TODO + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/parent_with_nullable_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/parent_with_nullable_test.dart new file mode 100644 index 000000000000..b501d4220624 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/test/parent_with_nullable_test.dart @@ -0,0 +1,21 @@ +import 'package:test/test.dart'; +import 'package:openapi/openapi.dart'; + +// tests for ParentWithNullable +void main() { + final ParentWithNullable? instance = /* ParentWithNullable(...) */ null; + // TODO add properties to the entity + + group(ParentWithNullable, () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES index 1172e4bb425f..ec17d50cd6e1 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES @@ -12,6 +12,7 @@ doc/ArrayTest.md doc/Capitalization.md doc/Cat.md doc/Category.md +doc/ChildWithNullable.md doc/ClassModel.md doc/DefaultApi.md doc/DeprecatedObject.md @@ -46,6 +47,7 @@ doc/OuterEnumDefaultValue.md doc/OuterEnumInteger.md doc/OuterEnumIntegerDefaultValue.md doc/OuterObjectWithEnumProperty.md +doc/ParentWithNullable.md doc/Pet.md doc/PetApi.md doc/ReadOnlyFirst.md @@ -81,6 +83,7 @@ lib/src/model/array_test.dart lib/src/model/capitalization.dart lib/src/model/cat.dart lib/src/model/category.dart +lib/src/model/child_with_nullable.dart lib/src/model/class_model.dart lib/src/model/date.dart lib/src/model/deprecated_object.dart @@ -113,6 +116,7 @@ lib/src/model/outer_enum_default_value.dart lib/src/model/outer_enum_integer.dart lib/src/model/outer_enum_integer_default_value.dart lib/src/model/outer_object_with_enum_property.dart +lib/src/model/parent_with_nullable.dart lib/src/model/pet.dart lib/src/model/read_only_first.dart lib/src/model/single_ref_type.dart @@ -121,3 +125,5 @@ lib/src/model/tag.dart lib/src/model/user.dart lib/src/serializers.dart pubspec.yaml +test/child_with_nullable_test.dart +test/parent_with_nullable_test.dart diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md index db7ed486d769..489ec4bec47b 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/README.md @@ -83,6 +83,7 @@ Class | Method | HTTP request | Description [*FakeApi*](doc/FakeApi.md) | [**testGroupParameters**](doc/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [*FakeApi*](doc/FakeApi.md) | [**testInlineAdditionalProperties**](doc/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [*FakeApi*](doc/FakeApi.md) | [**testJsonFormData**](doc/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[*FakeApi*](doc/FakeApi.md) | [**testNullable**](doc/FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [*FakeApi*](doc/FakeApi.md) | [**testQueryParameterCollectionFormat**](doc/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | [*FakeClassnameTags123Api*](doc/FakeClassnameTags123Api.md) | [**testClassname**](doc/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case [*PetApi*](doc/PetApi.md) | [**addPet**](doc/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store @@ -120,6 +121,7 @@ Class | Method | HTTP request | Description - [Capitalization](doc/Capitalization.md) - [Cat](doc/Cat.md) - [Category](doc/Category.md) + - [ChildWithNullable](doc/ChildWithNullable.md) - [ClassModel](doc/ClassModel.md) - [DeprecatedObject](doc/DeprecatedObject.md) - [Dog](doc/Dog.md) @@ -151,6 +153,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](doc/OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](doc/OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](doc/OuterObjectWithEnumProperty.md) + - [ParentWithNullable](doc/ParentWithNullable.md) - [Pet](doc/Pet.md) - [ReadOnlyFirst](doc/ReadOnlyFirst.md) - [SingleRefType](doc/SingleRefType.md) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ChildWithNullable.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ChildWithNullable.md new file mode 100644 index 000000000000..770494fcf4cc --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ChildWithNullable.md @@ -0,0 +1,17 @@ +# openapi.model.ChildWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] +**otherProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md index da73b9acb516..5caf751f1f49 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/FakeApi.md @@ -26,6 +26,7 @@ Method | HTTP request | Description [**testGroupParameters**](FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[**testNullable**](FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [**testQueryParameterCollectionFormat**](FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | @@ -800,6 +801,48 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **testNullable** +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example +```dart +import 'package:openapi/api.dart'; + +final api = Openapi().getFakeApi(); +final ChildWithNullable childWithNullable = ; // ChildWithNullable | request body + +try { + api.testNullable(childWithNullable); +} catch on DioException (e) { + print('Exception when calling FakeApi->testNullable: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **testQueryParameterCollectionFormat** > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ParentWithNullable.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ParentWithNullable.md new file mode 100644 index 000000000000..17aa5ca02941 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/ParentWithNullable.md @@ -0,0 +1,16 @@ +# openapi.model.ParentWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/openapi.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/openapi.dart index 76140c466d31..1c2b397af324 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/openapi.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/openapi.dart @@ -27,6 +27,7 @@ export 'package:openapi/src/model/array_test.dart'; export 'package:openapi/src/model/capitalization.dart'; export 'package:openapi/src/model/cat.dart'; export 'package:openapi/src/model/category.dart'; +export 'package:openapi/src/model/child_with_nullable.dart'; export 'package:openapi/src/model/class_model.dart'; export 'package:openapi/src/model/deprecated_object.dart'; export 'package:openapi/src/model/dog.dart'; @@ -58,6 +59,7 @@ export 'package:openapi/src/model/outer_enum_default_value.dart'; export 'package:openapi/src/model/outer_enum_integer.dart'; export 'package:openapi/src/model/outer_enum_integer_default_value.dart'; export 'package:openapi/src/model/outer_object_with_enum_property.dart'; +export 'package:openapi/src/model/parent_with_nullable.dart'; export 'package:openapi/src/model/pet.dart'; export 'package:openapi/src/model/read_only_first.dart'; export 'package:openapi/src/model/single_ref_type.dart'; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api/fake_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api/fake_api.dart index de710128f4ba..da3ce4b07687 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api/fake_api.dart @@ -10,6 +10,7 @@ import 'package:dio/dio.dart'; import 'dart:typed_data'; import 'package:built_collection/built_collection.dart'; import 'package:openapi/src/api_util.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; import 'package:openapi/src/model/date.dart'; import 'package:openapi/src/model/fake_big_decimal_map200_response.dart'; import 'package:openapi/src/model/file_schema_test_class.dart'; @@ -1446,6 +1447,73 @@ class FakeApi { return _response; } + /// test nullable parent property + /// + /// + /// Parameters: + /// * [childWithNullable] - request body + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] + /// Throws [DioException] if API call or serialization fails + Future> testNullable({ + required ChildWithNullable childWithNullable, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/fake/nullable'; + final _options = Options( + method: r'POST', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + const _type = FullType(ChildWithNullable); + _bodyData = _serializers.serialize(childWithNullable, specifiedType: _type); + + } catch(error, stackTrace) { + throw DioException( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioExceptionType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + return _response; + } + /// testQueryParameterCollectionFormat /// To test the collection format in query parameters /// diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/child_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/child_with_nullable.dart new file mode 100644 index 000000000000..8e40eb1d2371 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/child_with_nullable.dart @@ -0,0 +1,156 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:openapi/src/model/parent_with_nullable.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'child_with_nullable.g.dart'; + +/// ChildWithNullable +/// +/// Properties: +/// * [type] +/// * [nullableProperty] +/// * [otherProperty] +@BuiltValue() +abstract class ChildWithNullable implements ParentWithNullable, Built { + @BuiltValueField(wireName: r'otherProperty') + String? get otherProperty; + + ChildWithNullable._(); + + factory ChildWithNullable([void updates(ChildWithNullableBuilder b)]) = _$ChildWithNullable; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(ChildWithNullableBuilder b) => b..type=b.discriminatorValue; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ChildWithNullableSerializer(); +} + +class _$ChildWithNullableSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [ChildWithNullable, _$ChildWithNullable]; + + @override + final String wireName = r'ChildWithNullable'; + + Iterable _serializeProperties( + Serializers serializers, + ChildWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + if (object.type != null) { + yield r'type'; + yield serializers.serialize( + object.type, + specifiedType: const FullType(ParentWithNullableTypeEnum), + ); + } + if (object.nullableProperty != null) { + yield r'nullableProperty'; + yield serializers.serialize( + object.nullableProperty, + specifiedType: const FullType.nullable(String), + ); + } + if (object.otherProperty != null) { + yield r'otherProperty'; + yield serializers.serialize( + object.otherProperty, + specifiedType: const FullType(String), + ); + } + } + + @override + Object serialize( + Serializers serializers, + ChildWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required ChildWithNullableBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'type': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(ParentWithNullableTypeEnum), + ) as ParentWithNullableTypeEnum; + result.type = valueDes; + break; + case r'nullableProperty': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType.nullable(String), + ) as String?; + if (valueDes == null) continue; + result.nullableProperty = valueDes; + break; + case r'otherProperty': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.otherProperty = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + ChildWithNullable deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = ChildWithNullableBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + +class ChildWithNullableTypeEnum extends EnumClass { + + @BuiltValueEnumConst(wireName: r'ChildWithNullable') + static const ChildWithNullableTypeEnum childWithNullable = _$childWithNullableTypeEnum_childWithNullable; + @BuiltValueEnumConst(wireName: r'unknown_default_open_api', fallback: true) + static const ChildWithNullableTypeEnum unknownDefaultOpenApi = _$childWithNullableTypeEnum_unknownDefaultOpenApi; + + static Serializer get serializer => _$childWithNullableTypeEnumSerializer; + + const ChildWithNullableTypeEnum._(String name): super(name); + + static BuiltSet get values => _$childWithNullableTypeEnumValues; + static ChildWithNullableTypeEnum valueOf(String name) => _$childWithNullableTypeEnumValueOf(name); +} + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/parent_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/parent_with_nullable.dart new file mode 100644 index 000000000000..bf1252135cd9 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/parent_with_nullable.dart @@ -0,0 +1,212 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'parent_with_nullable.g.dart'; + +/// ParentWithNullable +/// +/// Properties: +/// * [type] +/// * [nullableProperty] +@BuiltValue(instantiable: false) +abstract class ParentWithNullable { + @BuiltValueField(wireName: r'type') + ParentWithNullableTypeEnum? get type; + // enum typeEnum { ChildWithNullable, }; + + @BuiltValueField(wireName: r'nullableProperty') + String? get nullableProperty; + + static const String discriminatorFieldName = r'type'; + + static const Map discriminatorMapping = { + r'ChildWithNullable': ChildWithNullable, + }; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ParentWithNullableSerializer(); +} + +extension ParentWithNullableDiscriminatorExt on ParentWithNullable { + String? get discriminatorValue { + if (this is ChildWithNullable) { + return r'ChildWithNullable'; + } + return null; + } +} +extension ParentWithNullableBuilderDiscriminatorExt on ParentWithNullableBuilder { + String? get discriminatorValue { + if (this is ChildWithNullableBuilder) { + return r'ChildWithNullable'; + } + return null; + } +} + +class _$ParentWithNullableSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [ParentWithNullable]; + + @override + final String wireName = r'ParentWithNullable'; + + Iterable _serializeProperties( + Serializers serializers, + ParentWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + if (object.type != null) { + yield r'type'; + yield serializers.serialize( + object.type, + specifiedType: const FullType(ParentWithNullableTypeEnum), + ); + } + if (object.nullableProperty != null) { + yield r'nullableProperty'; + yield serializers.serialize( + object.nullableProperty, + specifiedType: const FullType.nullable(String), + ); + } + } + + @override + Object serialize( + Serializers serializers, + ParentWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) { + if (object is ChildWithNullable) { + return serializers.serialize(object, specifiedType: FullType(ChildWithNullable))!; + } + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + @override + ParentWithNullable deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final serializedList = (serialized as Iterable).toList(); + final discIndex = serializedList.indexOf(ParentWithNullable.discriminatorFieldName) + 1; + final discValue = serializers.deserialize(serializedList[discIndex], specifiedType: FullType(String)) as String; + switch (discValue) { + case r'ChildWithNullable': + return serializers.deserialize(serialized, specifiedType: FullType(ChildWithNullable)) as ChildWithNullable; + default: + return serializers.deserialize(serialized, specifiedType: FullType($ParentWithNullable)) as $ParentWithNullable; + } + } +} + +/// a concrete implementation of [ParentWithNullable], since [ParentWithNullable] is not instantiable +@BuiltValue(instantiable: true) +abstract class $ParentWithNullable implements ParentWithNullable, Built<$ParentWithNullable, $ParentWithNullableBuilder> { + $ParentWithNullable._(); + + factory $ParentWithNullable([void Function($ParentWithNullableBuilder)? updates]) = _$$ParentWithNullable; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults($ParentWithNullableBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer<$ParentWithNullable> get serializer => _$$ParentWithNullableSerializer(); +} + +class _$$ParentWithNullableSerializer implements PrimitiveSerializer<$ParentWithNullable> { + @override + final Iterable types = const [$ParentWithNullable, _$$ParentWithNullable]; + + @override + final String wireName = r'$ParentWithNullable'; + + @override + Object serialize( + Serializers serializers, + $ParentWithNullable object, { + FullType specifiedType = FullType.unspecified, + }) { + return serializers.serialize(object, specifiedType: FullType(ParentWithNullable))!; + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required ParentWithNullableBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'type': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(ParentWithNullableTypeEnum), + ) as ParentWithNullableTypeEnum; + result.type = valueDes; + break; + case r'nullableProperty': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType.nullable(String), + ) as String?; + if (valueDes == null) continue; + result.nullableProperty = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + $ParentWithNullable deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = $ParentWithNullableBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + +class ParentWithNullableTypeEnum extends EnumClass { + + @BuiltValueEnumConst(wireName: r'ChildWithNullable') + static const ParentWithNullableTypeEnum childWithNullable = _$parentWithNullableTypeEnum_childWithNullable; + @BuiltValueEnumConst(wireName: r'unknown_default_open_api', fallback: true) + static const ParentWithNullableTypeEnum unknownDefaultOpenApi = _$parentWithNullableTypeEnum_unknownDefaultOpenApi; + + static Serializer get serializer => _$parentWithNullableTypeEnumSerializer; + + const ParentWithNullableTypeEnum._(String name): super(name); + + static BuiltSet get values => _$parentWithNullableTypeEnumValues; + static ParentWithNullableTypeEnum valueOf(String name) => _$parentWithNullableTypeEnumValueOf(name); +} + diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart index ca163ddac102..d4d742a42c2b 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/serializers.dart @@ -24,6 +24,7 @@ import 'package:openapi/src/model/array_test.dart'; import 'package:openapi/src/model/capitalization.dart'; import 'package:openapi/src/model/cat.dart'; import 'package:openapi/src/model/category.dart'; +import 'package:openapi/src/model/child_with_nullable.dart'; import 'package:openapi/src/model/class_model.dart'; import 'package:openapi/src/model/deprecated_object.dart'; import 'package:openapi/src/model/dog.dart'; @@ -55,6 +56,7 @@ import 'package:openapi/src/model/outer_enum_default_value.dart'; import 'package:openapi/src/model/outer_enum_integer.dart'; import 'package:openapi/src/model/outer_enum_integer_default_value.dart'; import 'package:openapi/src/model/outer_object_with_enum_property.dart'; +import 'package:openapi/src/model/parent_with_nullable.dart'; import 'package:openapi/src/model/pet.dart'; import 'package:openapi/src/model/read_only_first.dart'; import 'package:openapi/src/model/single_ref_type.dart'; @@ -75,6 +77,7 @@ part 'serializers.g.dart'; Capitalization, Cat, Category, + ChildWithNullable, ClassModel, DeprecatedObject, Dog, @@ -106,6 +109,7 @@ part 'serializers.g.dart'; OuterEnumInteger, OuterEnumIntegerDefaultValue, OuterObjectWithEnumProperty, + ParentWithNullable,$ParentWithNullable, Pet, ReadOnlyFirst, SingleRefType, @@ -147,6 +151,7 @@ Serializers serializers = (_$serializers.toBuilder() () => ListBuilder(), ) ..add(Animal.serializer) + ..add(ParentWithNullable.serializer) ..add(const OneOfSerializer()) ..add(const AnyOfSerializer()) ..add(const DateSerializer()) diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/child_with_nullable_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/child_with_nullable_test.dart new file mode 100644 index 000000000000..88361dff20e1 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/child_with_nullable_test.dart @@ -0,0 +1,26 @@ +import 'package:test/test.dart'; +import 'package:openapi/openapi.dart'; + +// tests for ChildWithNullable +void main() { + final instance = ChildWithNullableBuilder(); + // TODO add properties to the builder and call build() + + group(ChildWithNullable, () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + // String otherProperty + test('to test the property `otherProperty`', () async { + // TODO + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/parent_with_nullable_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/parent_with_nullable_test.dart new file mode 100644 index 000000000000..68edeb52bc26 --- /dev/null +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/test/parent_with_nullable_test.dart @@ -0,0 +1,21 @@ +import 'package:test/test.dart'; +import 'package:openapi/openapi.dart'; + +// tests for ParentWithNullable +void main() { + //final instance = ParentWithNullableBuilder(); + // TODO add properties to the builder and call build() + + group(ParentWithNullable, () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + }); +} diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES index 727a5ef352b4..b948518e8604 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES @@ -13,6 +13,7 @@ doc/ArrayTest.md doc/Capitalization.md doc/Cat.md doc/Category.md +doc/ChildWithNullable.md doc/ClassModel.md doc/DefaultApi.md doc/DeprecatedObject.md @@ -47,6 +48,7 @@ doc/OuterEnumDefaultValue.md doc/OuterEnumInteger.md doc/OuterEnumIntegerDefaultValue.md doc/OuterObjectWithEnumProperty.md +doc/ParentWithNullable.md doc/Pet.md doc/PetApi.md doc/ReadOnlyFirst.md @@ -83,6 +85,7 @@ lib/model/array_test.dart lib/model/capitalization.dart lib/model/cat.dart lib/model/category.dart +lib/model/child_with_nullable.dart lib/model/class_model.dart lib/model/deprecated_object.dart lib/model/dog.dart @@ -114,6 +117,7 @@ lib/model/outer_enum_default_value.dart lib/model/outer_enum_integer.dart lib/model/outer_enum_integer_default_value.dart lib/model/outer_object_with_enum_property.dart +lib/model/parent_with_nullable.dart lib/model/pet.dart lib/model/read_only_first.dart lib/model/single_ref_type.dart @@ -121,3 +125,5 @@ lib/model/special_model_name.dart lib/model/tag.dart lib/model/user.dart pubspec.yaml +test/child_with_nullable_test.dart +test/parent_with_nullable_test.dart diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md index 940295f3df91..9d0fed4ca854 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/README.md @@ -77,6 +77,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testGroupParameters**](doc//FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**testInlineAdditionalProperties**](doc//FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**testJsonFormData**](doc//FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**testNullable**](doc//FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property *FakeApi* | [**testQueryParameterCollectionFormat**](doc//FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | *FakeClassnameTags123Api* | [**testClassname**](doc//FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](doc//PetApi.md#addpet) | **POST** /pet | Add a new pet to the store @@ -114,6 +115,7 @@ Class | Method | HTTP request | Description - [Capitalization](doc//Capitalization.md) - [Cat](doc//Cat.md) - [Category](doc//Category.md) + - [ChildWithNullable](doc//ChildWithNullable.md) - [ClassModel](doc//ClassModel.md) - [DeprecatedObject](doc//DeprecatedObject.md) - [Dog](doc//Dog.md) @@ -145,6 +147,7 @@ Class | Method | HTTP request | Description - [OuterEnumInteger](doc//OuterEnumInteger.md) - [OuterEnumIntegerDefaultValue](doc//OuterEnumIntegerDefaultValue.md) - [OuterObjectWithEnumProperty](doc//OuterObjectWithEnumProperty.md) + - [ParentWithNullable](doc//ParentWithNullable.md) - [Pet](doc//Pet.md) - [ReadOnlyFirst](doc//ReadOnlyFirst.md) - [SingleRefType](doc//SingleRefType.md) diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ChildWithNullable.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ChildWithNullable.md new file mode 100644 index 000000000000..770494fcf4cc --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ChildWithNullable.md @@ -0,0 +1,17 @@ +# openapi.model.ChildWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] +**otherProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md index 5998db8502da..ee87ce7bafd2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/FakeApi.md @@ -26,6 +26,7 @@ Method | HTTP request | Description [**testGroupParameters**](FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +[**testNullable**](FakeApi.md#testnullable) | **POST** /fake/nullable | test nullable parent property [**testQueryParameterCollectionFormat**](FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters | @@ -806,6 +807,48 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **testNullable** +> testNullable(childWithNullable) + +test nullable parent property + + + +### Example +```dart +import 'package:openapi/api.dart'; + +final api_instance = FakeApi(); +final childWithNullable = ChildWithNullable(); // ChildWithNullable | request body + +try { + api_instance.testNullable(childWithNullable); +} catch (e) { + print('Exception when calling FakeApi->testNullable: $e\n'); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **childWithNullable** | [**ChildWithNullable**](ChildWithNullable.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **testQueryParameterCollectionFormat** > testQueryParameterCollectionFormat(pipe, ioutil, http, url, context, allowEmpty, language) diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ParentWithNullable.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ParentWithNullable.md new file mode 100644 index 000000000000..17aa5ca02941 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/ParentWithNullable.md @@ -0,0 +1,16 @@ +# openapi.model.ParentWithNullable + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **String** | | [optional] +**nullableProperty** | **String** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart index c48f9bf6a260..167a8a32b6cd 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart @@ -46,6 +46,7 @@ part 'model/array_test.dart'; part 'model/capitalization.dart'; part 'model/cat.dart'; part 'model/category.dart'; +part 'model/child_with_nullable.dart'; part 'model/class_model.dart'; part 'model/deprecated_object.dart'; part 'model/dog.dart'; @@ -77,6 +78,7 @@ part 'model/outer_enum_default_value.dart'; part 'model/outer_enum_integer.dart'; part 'model/outer_enum_integer_default_value.dart'; part 'model/outer_object_with_enum_property.dart'; +part 'model/parent_with_nullable.dart'; part 'model/pet.dart'; part 'model/read_only_first.dart'; part 'model/single_ref_type.dart'; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart index f808cb0cf33f..2873d1bcd75a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart @@ -1131,6 +1131,56 @@ class FakeApi { } } + /// test nullable parent property + /// + /// + /// + /// Note: This method returns the HTTP [Response]. + /// + /// Parameters: + /// + /// * [ChildWithNullable] childWithNullable (required): + /// request body + Future testNullableWithHttpInfo(ChildWithNullable childWithNullable,) async { + // ignore: prefer_const_declarations + final path = r'/fake/nullable'; + + // ignore: prefer_final_locals + Object? postBody = childWithNullable; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + const contentTypes = ['application/json']; + + + return apiClient.invokeAPI( + path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentTypes.isEmpty ? null : contentTypes.first, + ); + } + + /// test nullable parent property + /// + /// + /// + /// Parameters: + /// + /// * [ChildWithNullable] childWithNullable (required): + /// request body + Future testNullable(ChildWithNullable childWithNullable,) async { + final response = await testNullableWithHttpInfo(childWithNullable,); + if (response.statusCode >= HttpStatus.badRequest) { + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); + } + } + /// To test the collection format in query parameters /// /// Note: This method returns the HTTP [Response]. diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart index d494ed9f13fb..7f4bd6b05679 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart @@ -202,6 +202,8 @@ class ApiClient { return Cat.fromJson(value); case 'Category': return Category.fromJson(value); + case 'ChildWithNullable': + return ChildWithNullable.fromJson(value); case 'ClassModel': return ClassModel.fromJson(value); case 'DeprecatedObject': @@ -264,6 +266,8 @@ class ApiClient { return OuterEnumIntegerDefaultValueTypeTransformer().decode(value); case 'OuterObjectWithEnumProperty': return OuterObjectWithEnumProperty.fromJson(value); + case 'ParentWithNullable': + return ParentWithNullable.fromJson(value); case 'Pet': return Pet.fromJson(value); case 'ReadOnlyFirst': diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart new file mode 100644 index 000000000000..7ade7785fc73 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/child_with_nullable.dart @@ -0,0 +1,211 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +part of openapi.api; + +class ChildWithNullable { + /// Returns a new [ChildWithNullable] instance. + ChildWithNullable({ + this.type, + this.nullableProperty, + this.otherProperty, + }); + + ChildWithNullableTypeEnum? type; + + String? nullableProperty; + + /// + /// Please note: This property should have been non-nullable! Since the specification file + /// does not include a default value (using the "default:" property), however, the generated + /// source code must fall back to having a nullable type. + /// Consider adding a "default:" property in the specification file to hide this note. + /// + String? otherProperty; + + @override + bool operator ==(Object other) => identical(this, other) || other is ChildWithNullable && + other.type == type && + other.nullableProperty == nullableProperty && + other.otherProperty == otherProperty; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (type == null ? 0 : type!.hashCode) + + (nullableProperty == null ? 0 : nullableProperty!.hashCode) + + (otherProperty == null ? 0 : otherProperty!.hashCode); + + @override + String toString() => 'ChildWithNullable[type=$type, nullableProperty=$nullableProperty, otherProperty=$otherProperty]'; + + Map toJson() { + final json = {}; + if (this.type != null) { + json[r'type'] = this.type; + } else { + json[r'type'] = null; + } + if (this.nullableProperty != null) { + json[r'nullableProperty'] = this.nullableProperty; + } else { + json[r'nullableProperty'] = null; + } + if (this.otherProperty != null) { + json[r'otherProperty'] = this.otherProperty; + } else { + json[r'otherProperty'] = null; + } + return json; + } + + /// Returns a new [ChildWithNullable] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ChildWithNullable? fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + + // Ensure that the map contains the required keys. + // Note 1: the values aren't checked for validity beyond being non-null. + // Note 2: this code is stripped in release mode! + assert(() { + requiredKeys.forEach((key) { + assert(json.containsKey(key), 'Required key "ChildWithNullable[$key]" is missing from JSON.'); + assert(json[key] != null, 'Required key "ChildWithNullable[$key]" has a null value in JSON.'); + }); + return true; + }()); + + return ChildWithNullable( + type: ChildWithNullableTypeEnum.fromJson(json[r'type']), + nullableProperty: mapValueOfType(json, r'nullableProperty'), + otherProperty: mapValueOfType(json, r'otherProperty'), + ); + } + return null; + } + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ChildWithNullable.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } + + static Map mapFromJson(dynamic json) { + final map = {}; + if (json is Map && json.isNotEmpty) { + json = json.cast(); // ignore: parameter_assignments + for (final entry in json.entries) { + final value = ChildWithNullable.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of ChildWithNullable-objects as value to a dart map + static Map> mapListFromJson(dynamic json, {bool growable = false,}) { + final map = >{}; + if (json is Map && json.isNotEmpty) { + // ignore: parameter_assignments + json = json.cast(); + for (final entry in json.entries) { + map[entry.key] = ChildWithNullable.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + }; +} + + +class ChildWithNullableTypeEnum { + /// Instantiate a new enum with the provided [value]. + const ChildWithNullableTypeEnum._(this.value); + + /// The underlying value of this enum member. + final String value; + + @override + String toString() => value; + + String toJson() => value; + + static const childWithNullable = ChildWithNullableTypeEnum._(r'ChildWithNullable'); + + /// List of all possible values in this [enum][ChildWithNullableTypeEnum]. + static const values = [ + childWithNullable, + ]; + + static ChildWithNullableTypeEnum? fromJson(dynamic value) => ChildWithNullableTypeEnumTypeTransformer().decode(value); + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ChildWithNullableTypeEnum.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } +} + +/// Transformation class that can [encode] an instance of [ChildWithNullableTypeEnum] to String, +/// and [decode] dynamic data back to [ChildWithNullableTypeEnum]. +class ChildWithNullableTypeEnumTypeTransformer { + factory ChildWithNullableTypeEnumTypeTransformer() => _instance ??= const ChildWithNullableTypeEnumTypeTransformer._(); + + const ChildWithNullableTypeEnumTypeTransformer._(); + + String encode(ChildWithNullableTypeEnum data) => data.value; + + /// Decodes a [dynamic value][data] to a ChildWithNullableTypeEnum. + /// + /// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully, + /// then null is returned. However, if [allowNull] is false and the [dynamic value][data] + /// cannot be decoded successfully, then an [UnimplementedError] is thrown. + /// + /// The [allowNull] is very handy when an API changes and a new enum value is added or removed, + /// and users are still using an old app with the old code. + ChildWithNullableTypeEnum? decode(dynamic data, {bool allowNull = true}) { + if (data != null) { + switch (data) { + case r'ChildWithNullable': return ChildWithNullableTypeEnum.childWithNullable; + default: + if (!allowNull) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } + } + return null; + } + + /// Singleton [ChildWithNullableTypeEnumTypeTransformer] instance. + static ChildWithNullableTypeEnumTypeTransformer? _instance; +} + + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart new file mode 100644 index 000000000000..24f4ee75874e --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/parent_with_nullable.dart @@ -0,0 +1,194 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +part of openapi.api; + +class ParentWithNullable { + /// Returns a new [ParentWithNullable] instance. + ParentWithNullable({ + this.type, + this.nullableProperty, + }); + + ParentWithNullableTypeEnum? type; + + String? nullableProperty; + + @override + bool operator ==(Object other) => identical(this, other) || other is ParentWithNullable && + other.type == type && + other.nullableProperty == nullableProperty; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (type == null ? 0 : type!.hashCode) + + (nullableProperty == null ? 0 : nullableProperty!.hashCode); + + @override + String toString() => 'ParentWithNullable[type=$type, nullableProperty=$nullableProperty]'; + + Map toJson() { + final json = {}; + if (this.type != null) { + json[r'type'] = this.type; + } else { + json[r'type'] = null; + } + if (this.nullableProperty != null) { + json[r'nullableProperty'] = this.nullableProperty; + } else { + json[r'nullableProperty'] = null; + } + return json; + } + + /// Returns a new [ParentWithNullable] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ParentWithNullable? fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + + // Ensure that the map contains the required keys. + // Note 1: the values aren't checked for validity beyond being non-null. + // Note 2: this code is stripped in release mode! + assert(() { + requiredKeys.forEach((key) { + assert(json.containsKey(key), 'Required key "ParentWithNullable[$key]" is missing from JSON.'); + assert(json[key] != null, 'Required key "ParentWithNullable[$key]" has a null value in JSON.'); + }); + return true; + }()); + + return ParentWithNullable( + type: ParentWithNullableTypeEnum.fromJson(json[r'type']), + nullableProperty: mapValueOfType(json, r'nullableProperty'), + ); + } + return null; + } + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ParentWithNullable.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } + + static Map mapFromJson(dynamic json) { + final map = {}; + if (json is Map && json.isNotEmpty) { + json = json.cast(); // ignore: parameter_assignments + for (final entry in json.entries) { + final value = ParentWithNullable.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of ParentWithNullable-objects as value to a dart map + static Map> mapListFromJson(dynamic json, {bool growable = false,}) { + final map = >{}; + if (json is Map && json.isNotEmpty) { + // ignore: parameter_assignments + json = json.cast(); + for (final entry in json.entries) { + map[entry.key] = ParentWithNullable.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + }; +} + + +class ParentWithNullableTypeEnum { + /// Instantiate a new enum with the provided [value]. + const ParentWithNullableTypeEnum._(this.value); + + /// The underlying value of this enum member. + final String value; + + @override + String toString() => value; + + String toJson() => value; + + static const childWithNullable = ParentWithNullableTypeEnum._(r'ChildWithNullable'); + + /// List of all possible values in this [enum][ParentWithNullableTypeEnum]. + static const values = [ + childWithNullable, + ]; + + static ParentWithNullableTypeEnum? fromJson(dynamic value) => ParentWithNullableTypeEnumTypeTransformer().decode(value); + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ParentWithNullableTypeEnum.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } +} + +/// Transformation class that can [encode] an instance of [ParentWithNullableTypeEnum] to String, +/// and [decode] dynamic data back to [ParentWithNullableTypeEnum]. +class ParentWithNullableTypeEnumTypeTransformer { + factory ParentWithNullableTypeEnumTypeTransformer() => _instance ??= const ParentWithNullableTypeEnumTypeTransformer._(); + + const ParentWithNullableTypeEnumTypeTransformer._(); + + String encode(ParentWithNullableTypeEnum data) => data.value; + + /// Decodes a [dynamic value][data] to a ParentWithNullableTypeEnum. + /// + /// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully, + /// then null is returned. However, if [allowNull] is false and the [dynamic value][data] + /// cannot be decoded successfully, then an [UnimplementedError] is thrown. + /// + /// The [allowNull] is very handy when an API changes and a new enum value is added or removed, + /// and users are still using an old app with the old code. + ParentWithNullableTypeEnum? decode(dynamic data, {bool allowNull = true}) { + if (data != null) { + switch (data) { + case r'ChildWithNullable': return ParentWithNullableTypeEnum.childWithNullable; + default: + if (!allowNull) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } + } + return null; + } + + /// Singleton [ParentWithNullableTypeEnumTypeTransformer] instance. + static ParentWithNullableTypeEnumTypeTransformer? _instance; +} + + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/child_with_nullable_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/child_with_nullable_test.dart new file mode 100644 index 000000000000..30d4588bd807 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/child_with_nullable_test.dart @@ -0,0 +1,37 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for ChildWithNullable +void main() { + // final instance = ChildWithNullable(); + + group('test ChildWithNullable', () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + // String otherProperty + test('to test the property `otherProperty`', () async { + // TODO + }); + + + }); + +} diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/parent_with_nullable_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/parent_with_nullable_test.dart new file mode 100644 index 000000000000..3d16052226f6 --- /dev/null +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/test/parent_with_nullable_test.dart @@ -0,0 +1,32 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for ParentWithNullable +void main() { + // final instance = ParentWithNullable(); + + group('test ParentWithNullable', () { + // String type + test('to test the property `type`', () async { + // TODO + }); + + // String nullableProperty + test('to test the property `nullableProperty`', () async { + // TODO + }); + + + }); + +} diff --git a/samples/schema/petstore/mysql/.openapi-generator/FILES b/samples/schema/petstore/mysql/.openapi-generator/FILES index 0a914acd736d..a70d72bf53b9 100644 --- a/samples/schema/petstore/mysql/.openapi-generator/FILES +++ b/samples/schema/petstore/mysql/.openapi-generator/FILES @@ -9,6 +9,7 @@ Model/ArrayTest.sql Model/Capitalization.sql Model/Cat.sql Model/Category.sql +Model/ChildWithNullable.sql Model/ClassModel.sql Model/Client.sql Model/DeprecatedObject.sql @@ -38,6 +39,7 @@ Model/OuterEnumDefaultValue.sql Model/OuterEnumInteger.sql Model/OuterEnumIntegerDefaultValue.sql Model/OuterObjectWithEnumProperty.sql +Model/ParentWithNullable.sql Model/Pet.sql Model/ReadOnlyFirst.sql Model/Return.sql diff --git a/samples/schema/petstore/mysql/Model/ChildWithNullable.sql b/samples/schema/petstore/mysql/Model/ChildWithNullable.sql new file mode 100644 index 000000000000..1ebeb48d32a1 --- /dev/null +++ b/samples/schema/petstore/mysql/Model/ChildWithNullable.sql @@ -0,0 +1,26 @@ +-- +-- OpenAPI Petstore. +-- Prepared SQL queries for 'ChildWithNullable' definition. +-- + + +-- +-- SELECT template for table `ChildWithNullable` +-- +SELECT `type`, `nullableProperty`, `otherProperty` FROM `ChildWithNullable` WHERE 1; + +-- +-- INSERT template for table `ChildWithNullable` +-- +INSERT INTO `ChildWithNullable`(`type`, `nullableProperty`, `otherProperty`) VALUES (?, ?, ?); + +-- +-- UPDATE template for table `ChildWithNullable` +-- +UPDATE `ChildWithNullable` SET `type` = ?, `nullableProperty` = ?, `otherProperty` = ? WHERE 1; + +-- +-- DELETE template for table `ChildWithNullable` +-- +DELETE FROM `ChildWithNullable` WHERE 0; + diff --git a/samples/schema/petstore/mysql/Model/ParentWithNullable.sql b/samples/schema/petstore/mysql/Model/ParentWithNullable.sql new file mode 100644 index 000000000000..bea4e901ca04 --- /dev/null +++ b/samples/schema/petstore/mysql/Model/ParentWithNullable.sql @@ -0,0 +1,26 @@ +-- +-- OpenAPI Petstore. +-- Prepared SQL queries for 'ParentWithNullable' definition. +-- + + +-- +-- SELECT template for table `ParentWithNullable` +-- +SELECT `type`, `nullableProperty` FROM `ParentWithNullable` WHERE 1; + +-- +-- INSERT template for table `ParentWithNullable` +-- +INSERT INTO `ParentWithNullable`(`type`, `nullableProperty`) VALUES (?, ?); + +-- +-- UPDATE template for table `ParentWithNullable` +-- +UPDATE `ParentWithNullable` SET `type` = ?, `nullableProperty` = ? WHERE 1; + +-- +-- DELETE template for table `ParentWithNullable` +-- +DELETE FROM `ParentWithNullable` WHERE 0; + diff --git a/samples/schema/petstore/mysql/mysql_schema.sql b/samples/schema/petstore/mysql/mysql_schema.sql index 46629b427305..30257267116c 100644 --- a/samples/schema/petstore/mysql/mysql_schema.sql +++ b/samples/schema/petstore/mysql/mysql_schema.sql @@ -110,6 +110,16 @@ CREATE TABLE IF NOT EXISTS `Category` ( `name` TEXT NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `ChildWithNullable` generated from model 'ChildWithNullable' +-- + +CREATE TABLE IF NOT EXISTS `ChildWithNullable` ( + `type` ENUM('ChildWithNullable') DEFAULT NULL, + `nullableProperty` TEXT DEFAULT NULL, + `otherProperty` TEXT DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `ClassModel` generated from model 'ClassModel' -- Model for testing model with \"_class\" property @@ -363,6 +373,15 @@ CREATE TABLE IF NOT EXISTS `OuterObjectWithEnumProperty` ( `value` TEXT NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `ParentWithNullable` generated from model 'ParentWithNullable' +-- + +CREATE TABLE IF NOT EXISTS `ParentWithNullable` ( + `type` ENUM('ChildWithNullable') DEFAULT NULL, + `nullableProperty` TEXT DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `Pet` generated from model 'Pet' -- diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/.openapi-generator/FILES b/samples/server/petstore/cpp-restbed/generated/3_0/.openapi-generator/FILES index 538c54f0c20a..97c17ae836fb 100644 --- a/samples/server/petstore/cpp-restbed/generated/3_0/.openapi-generator/FILES +++ b/samples/server/petstore/cpp-restbed/generated/3_0/.openapi-generator/FILES @@ -37,6 +37,8 @@ model/Cat.cpp model/Cat.h model/Category.cpp model/Category.h +model/ChildWithNullable.cpp +model/ChildWithNullable.h model/ClassModel.cpp model/ClassModel.h model/Client.cpp @@ -93,6 +95,8 @@ model/OuterEnumIntegerDefaultValue.cpp model/OuterEnumIntegerDefaultValue.h model/OuterObjectWithEnumProperty.cpp model/OuterObjectWithEnumProperty.h +model/ParentWithNullable.cpp +model/ParentWithNullable.h model/Pet.cpp model/Pet.h model/ReadOnlyFirst.cpp diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp b/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp index c0cf18be8bd3..28c0d4e0ba3a 100644 --- a/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp +++ b/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp @@ -1903,6 +1903,119 @@ std::string FakeJsonFormDataResource::extractFormParamsFromBody(const std::strin } return ""; } +FakeNullableResource::FakeNullableResource(const std::string& context /* = "/v2" */) +{ + this->set_path(context + "/fake/nullable"); + this->set_method_handler("POST", + std::bind(&FakeNullableResource::handler_POST_internal, this, + std::placeholders::_1)); +} + +std::pair FakeNullableResource::handleFakeApiException(const FakeApiException& e) +{ + return std::make_pair(e.getStatus(), e.what()); +} + +std::pair FakeNullableResource::handleStdException(const std::exception& e) +{ + return std::make_pair(500, e.what()); +} + +std::pair FakeNullableResource::handleUnspecifiedException() +{ + return std::make_pair(500, "Unknown exception occurred"); +} + +void FakeNullableResource::setResponseHeader(const std::shared_ptr& session, const std::string& header) +{ + session->set_header(header, ""); +} + +void FakeNullableResource::returnResponse(const std::shared_ptr& session, const int status, const std::string& result, std::multimap& responseHeaders) +{ + responseHeaders.insert(std::make_pair("Connection", "close")); + session->close(status, result, responseHeaders); +} + +void FakeNullableResource::defaultSessionClose(const std::shared_ptr& session, const int status, const std::string& result) +{ + session->close(status, result, { {"Connection", "close"} }); +} + +void FakeNullableResource::handler_POST_internal(const std::shared_ptr session) +{ + const auto request = session->get_request(); + // body params or form params here from the body content string + std::string bodyContent = extractBodyContent(session); + auto childWithNullable = extractJsonModelBodyParam(bodyContent); + + int status_code = 500; + std::string result = ""; + + try { + status_code = + handler_POST(childWithNullable); + } + catch(const FakeApiException& e) { + std::tie(status_code, result) = handleFakeApiException(e); + } + catch(const std::exception& e) { + std::tie(status_code, result) = handleStdException(e); + } + catch(...) { + std::tie(status_code, result) = handleUnspecifiedException(); + } + + std::multimap< std::string, std::string > responseHeaders {}; + static const std::vector contentTypes{ + "application/json" + }; + static const std::string acceptTypes{ + "application/json, " + }; + + if (status_code == 200) { + responseHeaders.insert(std::make_pair("Content-Type", selectPreferredContentType(contentTypes))); + if (!acceptTypes.empty()) { + responseHeaders.insert(std::make_pair("Accept", acceptTypes)); + } + + returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders); + return; + } + defaultSessionClose(session, status_code, result); +} + + +int FakeNullableResource::handler_POST( + ChildWithNullable & childWithNullable) +{ + return handler_POST_func(childWithNullable); +} + + +std::string FakeNullableResource::extractBodyContent(const std::shared_ptr& session) { + const auto request = session->get_request(); + int content_length = request->get_header("Content-Length", 0); + std::string bodyContent; + session->fetch(content_length, + [&bodyContent](const std::shared_ptr session, + const restbed::Bytes &body) { + bodyContent = restbed::String::format( + "%.*s\n", (int)body.size(), body.data()); + }); + return bodyContent; +} + +std::string FakeNullableResource::extractFormParamsFromBody(const std::string& paramName, const std::string& body) { + const auto uri = restbed::Uri("urlencoded?" + body, true); + const auto params = uri.get_query_parameters(); + const auto result = params.find(paramName); + if (result != params.cend()) { + return result->second; + } + return ""; +} FakeTest_query_parametersResource::FakeTest_query_parametersResource(const std::string& context /* = "/v2" */) { this->set_path(context + "/fake/test-query-parameters"); @@ -2140,6 +2253,12 @@ std::shared_ptr FakeApi::getFakeJson } return m_spFakeJsonFormDataResource; } +std::shared_ptr FakeApi::getFakeNullableResource() { + if (!m_spFakeNullableResource) { + setResource(std::make_shared()); + } + return m_spFakeNullableResource; +} std::shared_ptr FakeApi::getFakeTest_query_parametersResource() { if (!m_spFakeTest_query_parametersResource) { setResource(std::make_shared()); @@ -2202,6 +2321,10 @@ void FakeApi::setResource(std::shared_ptrpublish(m_spFakeJsonFormDataResource); } +void FakeApi::setResource(std::shared_ptr resource) { + m_spFakeNullableResource = resource; + m_service->publish(m_spFakeNullableResource); +} void FakeApi::setResource(std::shared_ptr resource) { m_spFakeTest_query_parametersResource = resource; m_service->publish(m_spFakeTest_query_parametersResource); @@ -2262,6 +2385,10 @@ void FakeApi::setFakeApiFakeJsonFormDataResource(std::shared_ptrpublish(m_spFakeJsonFormDataResource); } +void FakeApi::setFakeApiFakeNullableResource(std::shared_ptr spFakeNullableResource) { + m_spFakeNullableResource = spFakeNullableResource; + m_service->publish(m_spFakeNullableResource); +} void FakeApi::setFakeApiFakeTest_query_parametersResource(std::shared_ptr spFakeTest_query_parametersResource) { m_spFakeTest_query_parametersResource = spFakeTest_query_parametersResource; m_service->publish(m_spFakeTest_query_parametersResource); @@ -2311,6 +2438,9 @@ void FakeApi::publishDefaultResources() { if (!m_spFakeJsonFormDataResource) { setResource(std::make_shared()); } + if (!m_spFakeNullableResource) { + setResource(std::make_shared()); + } if (!m_spFakeTest_query_parametersResource) { setResource(std::make_shared()); } diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h b/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h index 17f76507ffb9..46dc5181826c 100644 --- a/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h +++ b/samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h @@ -31,6 +31,7 @@ #include #include +#include "ChildWithNullable.h" #include "Client.h" #include "EnumClass.h" #include "FakeBigDecimalMap_200_response.h" @@ -960,6 +961,68 @@ class FakeJsonFormDataResource: public restbed::Resource void handler_GET_internal(const std::shared_ptr session); }; +/// +/// test nullable parent property +/// +/// +/// +/// +class FakeNullableResource: public restbed::Resource +{ +public: + FakeNullableResource(const std::string& context = "/v2"); + virtual ~FakeNullableResource() = default; + + FakeNullableResource( + const FakeNullableResource& other) = default; // copy constructor + FakeNullableResource(FakeNullableResource&& other) noexcept = default; // move constructor + + FakeNullableResource& operator=(const FakeNullableResource& other) = default; // copy assignment + FakeNullableResource& operator=(FakeNullableResource&& other) noexcept = default; // move assignment + + ///////////////////////////////////////////////////// + // Set these to implement the server functionality // + ///////////////////////////////////////////////////// + std::function handler_POST_func = + [](ChildWithNullable &) -> int + { throw FakeApiException(501, "Not implemented"); }; + + +protected: + ////////////////////////////////////////////////////////// + // As an alternative to setting the `std::function`s // + // override these to implement the server functionality // + ////////////////////////////////////////////////////////// + + virtual int handler_POST( + ChildWithNullable & childWithNullable); + + +protected: + ////////////////////////////////////// + // Override these for customization // + ////////////////////////////////////// + + virtual std::string extractBodyContent(const std::shared_ptr& session); + virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body); + + virtual std::pair handleFakeApiException(const FakeApiException& e); + virtual std::pair handleStdException(const std::exception& e); + virtual std::pair handleUnspecifiedException(); + + virtual void setResponseHeader(const std::shared_ptr& session, + const std::string& header); + + virtual void returnResponse(const std::shared_ptr& session, + const int status, const std::string& result, std::multimap& contentType); + virtual void defaultSessionClose(const std::shared_ptr& session, + const int status, const std::string& result); + +private: + void handler_POST_internal(const std::shared_ptr session); +}; + /// /// /// @@ -1038,6 +1101,7 @@ using FakeApiFakeBody_with_query_paramsResource [[deprecated]] = FakeApiResource using FakeApiFakeResource [[deprecated]] = FakeApiResources::FakeResource; using FakeApiFakeInline_additionalPropertiesResource [[deprecated]] = FakeApiResources::FakeInline_additionalPropertiesResource; using FakeApiFakeJsonFormDataResource [[deprecated]] = FakeApiResources::FakeJsonFormDataResource; +using FakeApiFakeNullableResource [[deprecated]] = FakeApiResources::FakeNullableResource; using FakeApiFakeTest_query_parametersResource [[deprecated]] = FakeApiResources::FakeTest_query_parametersResource; // @@ -1063,6 +1127,7 @@ class FakeApi std::shared_ptr getFakeResource(); std::shared_ptr getFakeInline_additionalPropertiesResource(); std::shared_ptr getFakeJsonFormDataResource(); + std::shared_ptr getFakeNullableResource(); std::shared_ptr getFakeTest_query_parametersResource(); void setResource(std::shared_ptr resource); @@ -1079,6 +1144,7 @@ class FakeApi void setResource(std::shared_ptr resource); void setResource(std::shared_ptr resource); void setResource(std::shared_ptr resource); + void setResource(std::shared_ptr resource); void setResource(std::shared_ptr resource); [[deprecated("use setResource()")]] virtual void setFakeApiFakeBigDecimalMapResource(std::shared_ptr spFakeApiFakeBigDecimalMapResource); @@ -1109,6 +1175,8 @@ class FakeApi [[deprecated("use setResource()")]] virtual void setFakeApiFakeJsonFormDataResource(std::shared_ptr spFakeApiFakeJsonFormDataResource); [[deprecated("use setResource()")]] + virtual void setFakeApiFakeNullableResource(std::shared_ptr spFakeApiFakeNullableResource); + [[deprecated("use setResource()")]] virtual void setFakeApiFakeTest_query_parametersResource(std::shared_ptr spFakeApiFakeTest_query_parametersResource); virtual void publishDefaultResources(); @@ -1130,6 +1198,7 @@ class FakeApi std::shared_ptr m_spFakeResource; std::shared_ptr m_spFakeInline_additionalPropertiesResource; std::shared_ptr m_spFakeJsonFormDataResource; + std::shared_ptr m_spFakeNullableResource; std::shared_ptr m_spFakeTest_query_parametersResource; private: diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.cpp b/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.cpp new file mode 100644 index 000000000000..48dd4b6314b3 --- /dev/null +++ b/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.cpp @@ -0,0 +1,140 @@ +/** + * 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 7.0.1-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "ChildWithNullable.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "helpers.h" + +using boost::property_tree::ptree; +using boost::property_tree::read_json; +using boost::property_tree::write_json; + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +ChildWithNullable::ChildWithNullable(boost::property_tree::ptree const& pt) +{ + fromPropertyTree(pt); +} + + +std::string ChildWithNullable::toJsonString(bool prettyJson /* = false */) const +{ + std::stringstream ss; + write_json(ss, this->toPropertyTree(), prettyJson); + // workaround inspired by: https://stackoverflow.com/a/56395440 + std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\""); + std::string result = std::regex_replace(ss.str(), reg, "$1"); + return result; +} + +void ChildWithNullable::fromJsonString(std::string const& jsonString) +{ + std::stringstream ss(jsonString); + ptree pt; + read_json(ss,pt); + this->fromPropertyTree(pt); +} + +ptree ChildWithNullable::toPropertyTree() const +{ + ptree pt; + ptree tmp_node; + pt.put("type", m_Type); + pt.put("nullableProperty", m_NullableProperty); + pt.put("otherProperty", m_OtherProperty); + return pt; +} + +void ChildWithNullable::fromPropertyTree(ptree const &pt) +{ + ptree tmp_node; + setType(pt.get("type", "")); + m_NullableProperty = pt.get("nullableProperty", ""); + m_OtherProperty = pt.get("otherProperty", ""); +} + +std::string ChildWithNullable::getType() const +{ + return m_Type; +} + +void ChildWithNullable::setType(std::string value) +{ + static const std::array allowedValues = { + "ChildWithNullable" + }; + + if (std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end()) { + m_Type = value; + } else { + throw std::runtime_error("Value " + boost::lexical_cast(value) + " not allowed"); + } +} + + +std::string ChildWithNullable::getNullableProperty() const +{ + return m_NullableProperty; +} + +void ChildWithNullable::setNullableProperty(std::string value) +{ + m_NullableProperty = value; +} + + +std::string ChildWithNullable::getOtherProperty() const +{ + return m_OtherProperty; +} + +void ChildWithNullable::setOtherProperty(std::string value) +{ + m_OtherProperty = value; +} + + + +std::vector createChildWithNullableVectorFromJsonString(const std::string& json) +{ + std::stringstream sstream(json); + boost::property_tree::ptree pt; + boost::property_tree::json_parser::read_json(sstream,pt); + + auto vec = std::vector(); + for (const auto& child: pt) { + vec.emplace_back(ChildWithNullable(child.second)); + } + + return vec; +} + +} +} +} +} + diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.h b/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.h new file mode 100644 index 000000000000..7044b8204ee0 --- /dev/null +++ b/samples/server/petstore/cpp-restbed/generated/3_0/model/ChildWithNullable.h @@ -0,0 +1,106 @@ +/** + * 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 7.0.1-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * ChildWithNullable.h + * + * + */ + +#ifndef ChildWithNullable_H_ +#define ChildWithNullable_H_ + + + +#include "ParentWithNullable.h" +#include +#include +#include +#include +#include +#include "ParentWithNullable.h" +#include "helpers.h" + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +/// +/// +/// +class ChildWithNullable : public ParentWithNullable +{ +public: + ChildWithNullable() = default; + explicit ChildWithNullable(boost::property_tree::ptree const& pt); + virtual ~ChildWithNullable() = default; + + ChildWithNullable(const ChildWithNullable& other) = default; // copy constructor + ChildWithNullable(ChildWithNullable&& other) noexcept = default; // move constructor + + ChildWithNullable& operator=(const ChildWithNullable& other) = default; // copy assignment + ChildWithNullable& operator=(ChildWithNullable&& other) noexcept = default; // move assignment + + std::string toJsonString(bool prettyJson = false) const; + void fromJsonString(std::string const& jsonString); + boost::property_tree::ptree toPropertyTree() const; + void fromPropertyTree(boost::property_tree::ptree const& pt); + + + ///////////////////////////////////////////// + /// ChildWithNullable members + + /// + /// + /// + std::string getType() const; + void setType(std::string value); + + /// + /// + /// + std::string getNullableProperty() const; + void setNullableProperty(std::string value); + + /// + /// + /// + std::string getOtherProperty() const; + void setOtherProperty(std::string value); + +protected: + std::string m_Type = ""; + std::string m_NullableProperty = ""; + std::string m_OtherProperty = ""; +}; + +std::vector createChildWithNullableVectorFromJsonString(const std::string& json); + +template<> +inline boost::property_tree::ptree toPt(const ChildWithNullable& val) { + return val.toPropertyTree(); +} + +template<> +inline ChildWithNullable fromPt(const boost::property_tree::ptree& pt) { + ChildWithNullable ret; + ret.fromPropertyTree(pt); + return ret; +} + +} +} +} +} + +#endif /* ChildWithNullable_H_ */ diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.cpp b/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.cpp new file mode 100644 index 000000000000..28226e76d8a9 --- /dev/null +++ b/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.cpp @@ -0,0 +1,127 @@ +/** + * 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 7.0.1-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +#include "ParentWithNullable.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "helpers.h" + +using boost::property_tree::ptree; +using boost::property_tree::read_json; +using boost::property_tree::write_json; + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +ParentWithNullable::ParentWithNullable(boost::property_tree::ptree const& pt) +{ + fromPropertyTree(pt); +} + + +std::string ParentWithNullable::toJsonString(bool prettyJson /* = false */) const +{ + std::stringstream ss; + write_json(ss, this->toPropertyTree(), prettyJson); + // workaround inspired by: https://stackoverflow.com/a/56395440 + std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\""); + std::string result = std::regex_replace(ss.str(), reg, "$1"); + return result; +} + +void ParentWithNullable::fromJsonString(std::string const& jsonString) +{ + std::stringstream ss(jsonString); + ptree pt; + read_json(ss,pt); + this->fromPropertyTree(pt); +} + +ptree ParentWithNullable::toPropertyTree() const +{ + ptree pt; + ptree tmp_node; + pt.put("type", m_Type); + pt.put("nullableProperty", m_NullableProperty); + return pt; +} + +void ParentWithNullable::fromPropertyTree(ptree const &pt) +{ + ptree tmp_node; + setType(pt.get("type", "")); + m_NullableProperty = pt.get("nullableProperty", ""); +} + +std::string ParentWithNullable::getType() const +{ + return m_Type; +} + +void ParentWithNullable::setType(std::string value) +{ + static const std::array allowedValues = { + "ChildWithNullable" + }; + + if (std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end()) { + m_Type = value; + } else { + throw std::runtime_error("Value " + boost::lexical_cast(value) + " not allowed"); + } +} + + +std::string ParentWithNullable::getNullableProperty() const +{ + return m_NullableProperty; +} + +void ParentWithNullable::setNullableProperty(std::string value) +{ + m_NullableProperty = value; +} + + + +std::vector createParentWithNullableVectorFromJsonString(const std::string& json) +{ + std::stringstream sstream(json); + boost::property_tree::ptree pt; + boost::property_tree::json_parser::read_json(sstream,pt); + + auto vec = std::vector(); + for (const auto& child: pt) { + vec.emplace_back(ParentWithNullable(child.second)); + } + + return vec; +} + +} +} +} +} + diff --git a/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.h b/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.h new file mode 100644 index 000000000000..adb872bbee33 --- /dev/null +++ b/samples/server/petstore/cpp-restbed/generated/3_0/model/ParentWithNullable.h @@ -0,0 +1,97 @@ +/** + * 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 7.0.1-SNAPSHOT. + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/* + * ParentWithNullable.h + * + * + */ + +#ifndef ParentWithNullable_H_ +#define ParentWithNullable_H_ + + + +#include +#include +#include +#include +#include +#include "helpers.h" + +namespace org { +namespace openapitools { +namespace server { +namespace model { + +/// +/// +/// +class ParentWithNullable +{ +public: + ParentWithNullable() = default; + explicit ParentWithNullable(boost::property_tree::ptree const& pt); + virtual ~ParentWithNullable() = default; + + ParentWithNullable(const ParentWithNullable& other) = default; // copy constructor + ParentWithNullable(ParentWithNullable&& other) noexcept = default; // move constructor + + ParentWithNullable& operator=(const ParentWithNullable& other) = default; // copy assignment + ParentWithNullable& operator=(ParentWithNullable&& other) noexcept = default; // move assignment + + std::string toJsonString(bool prettyJson = false) const; + void fromJsonString(std::string const& jsonString); + boost::property_tree::ptree toPropertyTree() const; + void fromPropertyTree(boost::property_tree::ptree const& pt); + + + ///////////////////////////////////////////// + /// ParentWithNullable members + + /// + /// + /// + std::string getType() const; + void setType(std::string value); + + /// + /// + /// + std::string getNullableProperty() const; + void setNullableProperty(std::string value); + +protected: + std::string m_Type = ""; + std::string m_NullableProperty = ""; +}; + +std::vector createParentWithNullableVectorFromJsonString(const std::string& json); + +template<> +inline boost::property_tree::ptree toPt(const ParentWithNullable& val) { + return val.toPropertyTree(); +} + +template<> +inline ParentWithNullable fromPt(const boost::property_tree::ptree& pt) { + ParentWithNullable ret; + ret.fromPropertyTree(pt); + return ret; +} + +} +} +} +} + +#endif /* ParentWithNullable_H_ */ diff --git a/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES b/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES index 5aaf8ee8e3aa..4c9047e40495 100644 --- a/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES +++ b/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES @@ -26,6 +26,7 @@ src/main/java/org/openapitools/server/model/ArrayTest.java src/main/java/org/openapitools/server/model/Capitalization.java src/main/java/org/openapitools/server/model/Cat.java src/main/java/org/openapitools/server/model/Category.java +src/main/java/org/openapitools/server/model/ChildWithNullable.java src/main/java/org/openapitools/server/model/ClassModel.java src/main/java/org/openapitools/server/model/Client.java src/main/java/org/openapitools/server/model/DeprecatedObject.java @@ -58,6 +59,7 @@ src/main/java/org/openapitools/server/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/server/model/OuterEnumInteger.java src/main/java/org/openapitools/server/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/server/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/server/model/ParentWithNullable.java src/main/java/org/openapitools/server/model/Pet.java src/main/java/org/openapitools/server/model/ReadOnlyFirst.java src/main/java/org/openapitools/server/model/SingleRefType.java @@ -69,3 +71,5 @@ src/main/resources/META-INF/beans.xml src/main/resources/META-INF/microprofile-config.properties src/main/resources/META-INF/openapi.yml src/main/resources/logging.properties +src/test/java/org/openapitools/server/model/ChildWithNullableTest.java +src/test/java/org/openapitools/server/model/ParentWithNullableTest.java diff --git a/samples/server/petstore/java-helidon-server/mp/README.md b/samples/server/petstore/java-helidon-server/mp/README.md index 8f4d37807e6d..5fcf51dcd376 100644 --- a/samples/server/petstore/java-helidon-server/mp/README.md +++ b/samples/server/petstore/java-helidon-server/mp/README.md @@ -30,6 +30,7 @@ curl -X GET http://petstore.swagger.io:80/v2 curl -X DELETE http://petstore.swagger.io:80/v2 curl -X POST http://petstore.swagger.io:80/v2/inline-additionalProperties curl -X GET http://petstore.swagger.io:80/v2/jsonFormData +curl -X POST http://petstore.swagger.io:80/v2/nullable curl -X PUT http://petstore.swagger.io:80/v2/test-query-parameters curl -X PATCH http://petstore.swagger.io:80/v2 curl -X POST http://petstore.swagger.io:80/v2/pet diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeService.java b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeService.java index 83b858b3d8a4..fdc92a3bb8d9 100644 --- a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeService.java +++ b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeService.java @@ -13,6 +13,7 @@ package org.openapitools.server.api; import java.math.BigDecimal; +import org.openapitools.server.model.ChildWithNullable; import org.openapitools.server.model.Client; import org.openapitools.server.model.EnumClass; import org.openapitools.server.model.FakeBigDecimalMap200Response; @@ -126,6 +127,11 @@ public interface FakeService { @Consumes({ "application/x-www-form-urlencoded" }) void testJsonFormData(@FormParam(value = "param") String param, @FormParam(value = "param2") String param2); + @POST + @Path("/nullable") + @Consumes({ "application/json" }) + void testNullable(@Valid @NotNull ChildWithNullable childWithNullable); + @PUT @Path("/test-query-parameters") void testQueryParameterCollectionFormat(@QueryParam("pipe") @NotNull List pipe, @QueryParam("ioutil") @NotNull List ioutil, @QueryParam("http") @NotNull List http, @QueryParam("url") @NotNull List url, @QueryParam("context") @NotNull List context, @QueryParam("allowEmpty") @NotNull String allowEmpty, @QueryParam("language") Map language); diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeServiceImpl.java b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeServiceImpl.java index e20e96c568b7..74dae73bfa08 100644 --- a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeServiceImpl.java +++ b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/api/FakeServiceImpl.java @@ -13,6 +13,7 @@ package org.openapitools.server.api; import java.math.BigDecimal; +import org.openapitools.server.model.ChildWithNullable; import org.openapitools.server.model.Client; import org.openapitools.server.model.EnumClass; import org.openapitools.server.model.FakeBigDecimalMap200Response; @@ -160,6 +161,12 @@ public void testInlineAdditionalProperties(@Valid @NotNull Map r public void testJsonFormData(@FormParam(value = "param") String param,@FormParam(value = "param2") String param2) { } + @POST + @Path("/nullable") + @Consumes({ "application/json" }) + public void testNullable(@Valid @NotNull ChildWithNullable childWithNullable) { + } + @PUT @Path("/test-query-parameters") public void testQueryParameterCollectionFormat(@QueryParam("pipe") @NotNull List pipe,@QueryParam("ioutil") @NotNull List ioutil,@QueryParam("http") @NotNull List http,@QueryParam("url") @NotNull List url,@QueryParam("context") @NotNull List context,@QueryParam("allowEmpty") @NotNull String allowEmpty,@QueryParam("language") Map language) { diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ChildWithNullable.java b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ChildWithNullable.java new file mode 100644 index 000000000000..abe443a27f85 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ChildWithNullable.java @@ -0,0 +1,80 @@ +/* + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.server.model.ParentWithNullable; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + /** + * Get otherProperty + * @return otherProperty + **/ + public String getOtherProperty() { + return otherProperty; + } + + /** + * Set otherProperty + **/ + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ParentWithNullable.java b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ParentWithNullable.java new file mode 100644 index 000000000000..beb88e89ed56 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/mp/src/main/java/org/openapitools/server/model/ParentWithNullable.java @@ -0,0 +1,149 @@ +/* + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + +public class ParentWithNullable { + +public enum TypeEnum { + + CHILDWITHNULLABLE(String.valueOf("ChildWithNullable")); + + + private String value; + + TypeEnum (String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + /** + * Convert a String into String, as specified in the + * See JAX RS 2.0 Specification, section 3.2, p. 12 + */ + public static TypeEnum fromString(String s) { + for (TypeEnum b : TypeEnum.values()) { + // using Objects.toString() to be safe if value type non-object type + // because types like 'int' etc. will be auto-boxed + if (java.util.Objects.toString(b.value).equals(s)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected string value '" + s + "'"); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private TypeEnum type; + + private String nullableProperty; + + /** + * Get type + * @return type + **/ + public TypeEnum getType() { + return type; + } + + /** + * Set type + **/ + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + public String getNullableProperty() { + return nullableProperty; + } + + /** + * Set nullableProperty + **/ + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-helidon-server/mp/src/main/resources/META-INF/openapi.yml b/samples/server/petstore/java-helidon-server/mp/src/main/resources/META-INF/openapi.yml index 66bea57fa648..59328fa022de 100644 --- a/samples/server/petstore/java-helidon-server/mp/src/main/resources/META-INF/openapi.yml +++ b/samples/server/petstore/java-helidon-server/mp/src/main/resources/META-INF/openapi.yml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java b/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..6246621383e2 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.server.model.ParentWithNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java b/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..466dc910f557 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/mp/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java @@ -0,0 +1,53 @@ +/* + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES b/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES index c3c751515ab3..e08b2b4d0111 100644 --- a/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES +++ b/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES @@ -27,6 +27,7 @@ src/main/java/org/openapitools/server/model/ArrayTest.java src/main/java/org/openapitools/server/model/Capitalization.java src/main/java/org/openapitools/server/model/Cat.java src/main/java/org/openapitools/server/model/Category.java +src/main/java/org/openapitools/server/model/ChildWithNullable.java src/main/java/org/openapitools/server/model/ClassModel.java src/main/java/org/openapitools/server/model/Client.java src/main/java/org/openapitools/server/model/DeprecatedObject.java @@ -59,6 +60,7 @@ src/main/java/org/openapitools/server/model/OuterEnumDefaultValue.java src/main/java/org/openapitools/server/model/OuterEnumInteger.java src/main/java/org/openapitools/server/model/OuterEnumIntegerDefaultValue.java src/main/java/org/openapitools/server/model/OuterObjectWithEnumProperty.java +src/main/java/org/openapitools/server/model/ParentWithNullable.java src/main/java/org/openapitools/server/model/Pet.java src/main/java/org/openapitools/server/model/ReadOnlyFirst.java src/main/java/org/openapitools/server/model/SingleRefType.java @@ -70,3 +72,5 @@ src/main/resources/META-INF/openapi.yml src/main/resources/application.yaml src/main/resources/logging.properties src/test/java/org/openapitools/server/MainTest.java +src/test/java/org/openapitools/server/model/ChildWithNullableTest.java +src/test/java/org/openapitools/server/model/ParentWithNullableTest.java diff --git a/samples/server/petstore/java-helidon-server/se/README.md b/samples/server/petstore/java-helidon-server/se/README.md index 6bf2ea9caa79..3eda86a8663a 100644 --- a/samples/server/petstore/java-helidon-server/se/README.md +++ b/samples/server/petstore/java-helidon-server/se/README.md @@ -30,6 +30,7 @@ curl -X GET http://petstore.swagger.io:80/v2/fake curl -X DELETE http://petstore.swagger.io:80/v2/fake curl -X POST http://petstore.swagger.io:80/v2/fake/inline-additionalProperties curl -X GET http://petstore.swagger.io:80/v2/fake/jsonFormData +curl -X POST http://petstore.swagger.io:80/v2/fake/nullable curl -X PUT http://petstore.swagger.io:80/v2/fake/test-query-parameters curl -X PATCH http://petstore.swagger.io:80/v2/fake_classname_test curl -X POST http://petstore.swagger.io:80/v2/pet diff --git a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeService.java b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeService.java index bdcf915f1b5a..16e4aa15e8ba 100644 --- a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeService.java +++ b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeService.java @@ -1,6 +1,7 @@ package org.openapitools.server.api; import java.math.BigDecimal; +import org.openapitools.server.model.ChildWithNullable; import org.openapitools.server.model.Client; import org.openapitools.server.model.EnumClass; import org.openapitools.server.model.FakeBigDecimalMap200Response; @@ -48,6 +49,7 @@ default void update(Routing.Rules rules) { rules.delete("/fake", this::testGroupParameters); rules.post("/fake/inline-additionalProperties", this::testInlineAdditionalProperties); rules.get("/fake/jsonFormData", this::testJsonFormData); + rules.post("/fake/nullable", Handler.create(ChildWithNullable.class, this::testNullable)); rules.put("/fake/test-query-parameters", this::testQueryParameterCollectionFormat); } @@ -177,6 +179,14 @@ default void update(Routing.Rules rules) { */ void testJsonFormData(ServerRequest request, ServerResponse response); + /** + * POST /fake/nullable : test nullable parent property. + * @param request the server request + * @param response the server response + * @param childWithNullable request body + */ + void testNullable(ServerRequest request, ServerResponse response, ChildWithNullable childWithNullable); + /** * PUT /fake/test-query-parameters. * @param request the server request diff --git a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeServiceImpl.java b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeServiceImpl.java index 05a148cdbcc1..11eb9fb2c68b 100644 --- a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeServiceImpl.java +++ b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/api/FakeServiceImpl.java @@ -1,6 +1,7 @@ package org.openapitools.server.api; import java.math.BigDecimal; +import org.openapitools.server.model.ChildWithNullable; import org.openapitools.server.model.Client; import org.openapitools.server.model.EnumClass; import org.openapitools.server.model.FakeBigDecimalMap200Response; @@ -97,6 +98,10 @@ public void testJsonFormData(ServerRequest request, ServerResponse response) { response.status(HTTP_CODE_NOT_IMPLEMENTED).send(); } + public void testNullable(ServerRequest request, ServerResponse response, ChildWithNullable childWithNullable) { + response.status(HTTP_CODE_NOT_IMPLEMENTED).send(); + } + public void testQueryParameterCollectionFormat(ServerRequest request, ServerResponse response) { response.status(HTTP_CODE_NOT_IMPLEMENTED).send(); } diff --git a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ChildWithNullable.java b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ChildWithNullable.java new file mode 100644 index 000000000000..aced0bb7a9ef --- /dev/null +++ b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ChildWithNullable.java @@ -0,0 +1,73 @@ +package org.openapitools.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.server.model.ParentWithNullable; + + + +public class ChildWithNullable extends ParentWithNullable { + + private String otherProperty; + + /** + * Default constructor. + */ + public ChildWithNullable() { + // JSON-B / Jackson + } + + /** + * Create ChildWithNullable. + * + * @param otherProperty otherProperty + */ + public ChildWithNullable( + String otherProperty + ) { + this.otherProperty = otherProperty; + } + + + + /** + * Get otherProperty + * @return otherProperty + */ + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ParentWithNullable.java b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ParentWithNullable.java new file mode 100644 index 000000000000..22a7bc13fce2 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/se/src/main/java/org/openapitools/server/model/ParentWithNullable.java @@ -0,0 +1,125 @@ +package org.openapitools.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; + + + +public class ParentWithNullable { + + + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + + @JsonCreator + public static TypeEnum fromValue(String text) { + for (TypeEnum b : TypeEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + text + "'"); + } + } + + + private TypeEnum type; + private String nullableProperty; + + /** + * Default constructor. + */ + public ParentWithNullable() { + // JSON-B / Jackson + } + + /** + * Create ParentWithNullable. + * + * @param type type + * @param nullableProperty nullableProperty + */ + public ParentWithNullable( + TypeEnum type, + String nullableProperty + ) { + this.type = type; + this.nullableProperty = nullableProperty; + } + + + + /** + * Get type + * @return type + */ + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + /** + * Get nullableProperty + * @return nullableProperty + */ + public String getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/java-helidon-server/se/src/main/resources/META-INF/openapi.yml b/samples/server/petstore/java-helidon-server/se/src/main/resources/META-INF/openapi.yml index 66bea57fa648..59328fa022de 100644 --- a/samples/server/petstore/java-helidon-server/se/src/main/resources/META-INF/openapi.yml +++ b/samples/server/petstore/java-helidon-server/se/src/main/resources/META-INF/openapi.yml @@ -1031,6 +1031,25 @@ paths: - fake x-content-type: application/json x-accepts: application/json + /fake/nullable: + post: + description: "" + operationId: testNullable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChildWithNullable' + description: request body + required: true + responses: + "200": + description: successful operation + summary: test nullable parent property + tags: + - fake + x-content-type: application/json + x-accepts: application/json /fake/body-with-query-params: put: operationId: testBodyWithQueryParams @@ -1862,6 +1881,25 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + ParentWithNullable: + discriminator: + propertyName: type + properties: + type: + enum: + - ChildWithNullable + type: string + nullableProperty: + nullable: true + type: string + type: object + ChildWithNullable: + allOf: + - $ref: '#/components/schemas/ParentWithNullable' + - properties: + otherProperty: + type: string + type: object StringBooleanMap: additionalProperties: type: boolean diff --git a/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java b/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java new file mode 100644 index 000000000000..6246621383e2 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ChildWithNullableTest.java @@ -0,0 +1,62 @@ +/* + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.server.model.ParentWithNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ChildWithNullable + */ +public class ChildWithNullableTest { + private final ChildWithNullable model = new ChildWithNullable(); + + /** + * Model tests for ChildWithNullable + */ + @Test + public void testChildWithNullable() { + // TODO: test ChildWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + + /** + * Test the property 'otherProperty' + */ + @Test + public void otherPropertyTest() { + // TODO: test otherProperty + } + +} diff --git a/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java b/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java new file mode 100644 index 000000000000..466dc910f557 --- /dev/null +++ b/samples/server/petstore/java-helidon-server/se/src/test/java/org/openapitools/server/model/ParentWithNullableTest.java @@ -0,0 +1,53 @@ +/* + * 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.server.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import org.openapitools.jackson.nullable.JsonNullable; +import org.junit.jupiter.api.Test; + +/** + * Model tests for ParentWithNullable + */ +public class ParentWithNullableTest { + private final ParentWithNullable model = new ParentWithNullable(); + + /** + * Model tests for ParentWithNullable + */ + @Test + public void testParentWithNullable() { + // TODO: test ParentWithNullable + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'nullableProperty' + */ + @Test + public void nullablePropertyTest() { + // TODO: test nullableProperty + } + +} diff --git a/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES b/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES index c991a1e399e1..d76f1d408ebd 100644 --- a/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES +++ b/samples/server/petstore/jaxrs-jersey/.openapi-generator/FILES @@ -30,6 +30,7 @@ src/gen/java/org/openapitools/model/ArrayTest.java src/gen/java/org/openapitools/model/Capitalization.java src/gen/java/org/openapitools/model/Cat.java src/gen/java/org/openapitools/model/Category.java +src/gen/java/org/openapitools/model/ChildWithNullable.java src/gen/java/org/openapitools/model/ClassModel.java src/gen/java/org/openapitools/model/Client.java src/gen/java/org/openapitools/model/DeprecatedObject.java @@ -62,6 +63,7 @@ src/gen/java/org/openapitools/model/OuterEnumDefaultValue.java src/gen/java/org/openapitools/model/OuterEnumInteger.java src/gen/java/org/openapitools/model/OuterEnumIntegerDefaultValue.java src/gen/java/org/openapitools/model/OuterObjectWithEnumProperty.java +src/gen/java/org/openapitools/model/ParentWithNullable.java src/gen/java/org/openapitools/model/Pet.java src/gen/java/org/openapitools/model/ReadOnlyFirst.java src/gen/java/org/openapitools/model/SingleRefType.java diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java index b65155e0d453..6ec67df2d1a6 100644 --- a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApi.java @@ -7,6 +7,7 @@ import io.swagger.jaxrs.*; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import java.util.Date; import org.openapitools.model.EnumClass; @@ -280,6 +281,18 @@ public Response testJsonFormData(@ApiParam(value = "field1", required=true) @Fo throws NotFoundException { return delegate.testJsonFormData(param, param2, securityContext); } + @javax.ws.rs.POST + @Path("/nullable") + @Consumes({ "application/json" }) + + @io.swagger.annotations.ApiOperation(value = "test nullable parent property", notes = "", response = Void.class, tags={ "fake", }) + @io.swagger.annotations.ApiResponses(value = { + @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) + }) + public Response testNullable(@ApiParam(value = "request body", required = true) @NotNull @Valid ChildWithNullable childWithNullable,@Context SecurityContext securityContext) + throws NotFoundException { + return delegate.testNullable(childWithNullable, securityContext); + } @javax.ws.rs.PUT @Path("/test-query-parameters") diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java index 8fbf2434e379..6675105bdc60 100644 --- a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/api/FakeApiService.java @@ -5,6 +5,7 @@ import org.glassfish.jersey.media.multipart.FormDataBodyPart; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import java.util.Date; import org.openapitools.model.EnumClass; @@ -46,6 +47,7 @@ public abstract class FakeApiService { public abstract Response testGroupParameters( @NotNull Integer requiredStringGroup, @NotNull Boolean requiredBooleanGroup, @NotNull Long requiredInt64Group,Integer stringGroup,Boolean booleanGroup,Long int64Group,SecurityContext securityContext) throws NotFoundException; public abstract Response testInlineAdditionalProperties(Map requestBody,SecurityContext securityContext) throws NotFoundException; public abstract Response testJsonFormData(String param,String param2,SecurityContext securityContext) throws NotFoundException; + public abstract Response testNullable(ChildWithNullable childWithNullable,SecurityContext securityContext) throws NotFoundException; public abstract Response testQueryParameterCollectionFormat( @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context, @NotNull String allowEmpty,Map language,SecurityContext securityContext) throws NotFoundException; public abstract Response uploadFileWithRequiredFile(Long petId,FormDataBodyPart requiredFileBodypart,String additionalMetadata,SecurityContext securityContext) throws NotFoundException; } diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ChildWithNullable.java new file mode 100644 index 000000000000..371f22123bc4 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ChildWithNullable.java @@ -0,0 +1,98 @@ +/* + * 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.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.openapitools.model.ParentWithNullable; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import javax.validation.constraints.*; +import javax.validation.Valid; + +/** + * ChildWithNullable + */ +@JsonPropertyOrder({ + ChildWithNullable.JSON_PROPERTY_OTHER_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen") +public class ChildWithNullable extends ParentWithNullable { + public static final String JSON_PROPERTY_OTHER_PROPERTY = "otherProperty"; + @JsonProperty(JSON_PROPERTY_OTHER_PROPERTY) + private String otherProperty; + + public ChildWithNullable otherProperty(String otherProperty) { + this.otherProperty = otherProperty; + return this; + } + + /** + * Get otherProperty + * @return otherProperty + **/ + @JsonProperty(value = "otherProperty") + @ApiModelProperty(value = "") + + public String getOtherProperty() { + return otherProperty; + } + + public void setOtherProperty(String otherProperty) { + this.otherProperty = otherProperty; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChildWithNullable childWithNullable = (ChildWithNullable) o; + return super.equals(o) && Objects.equals(otherProperty, childWithNullable.otherProperty); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), otherProperty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChildWithNullable {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" otherProperty: ").append(toIndentedString(otherProperty)).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 "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ParentWithNullable.java new file mode 100644 index 000000000000..eedfd014e9c6 --- /dev/null +++ b/samples/server/petstore/jaxrs-jersey/src/gen/java/org/openapitools/model/ParentWithNullable.java @@ -0,0 +1,160 @@ +/* + * 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.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import javax.validation.constraints.*; +import javax.validation.Valid; + +/** + * ParentWithNullable + */ +@JsonPropertyOrder({ + ParentWithNullable.JSON_PROPERTY_TYPE, + ParentWithNullable.JSON_PROPERTY_NULLABLE_PROPERTY +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen")@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChildWithNullable.class, name = "ChildWithNullable"), +}) + +public class ParentWithNullable { + /** + * Gets or Sets type + */ + public enum TypeEnum { + CHILDWITHNULLABLE("ChildWithNullable"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + @JsonProperty(JSON_PROPERTY_TYPE) + private TypeEnum type; + + public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty"; + @JsonProperty(JSON_PROPERTY_NULLABLE_PROPERTY) + private String nullableProperty; + + public ParentWithNullable type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @JsonProperty(value = "type") + @ApiModelProperty(value = "") + + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public ParentWithNullable nullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + /** + * Get nullableProperty + * @return nullableProperty + **/ + @JsonProperty(value = "nullableProperty") + @ApiModelProperty(value = "") + + public String getNullableProperty() { + return nullableProperty; + } + + public void setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentWithNullable parentWithNullable = (ParentWithNullable) o; + return Objects.equals(type, parentWithNullable.type) && + Objects.equals(nullableProperty, parentWithNullable.nullableProperty); + } + + @Override + public int hashCode() { + return Objects.hash(type, nullableProperty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentWithNullable {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } +} + diff --git a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java index 1f513684a47a..8f60cba30a63 100644 --- a/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java +++ b/samples/server/petstore/jaxrs-jersey/src/main/java/org/openapitools/api/impl/FakeApiServiceImpl.java @@ -2,6 +2,7 @@ import org.openapitools.api.*; import java.math.BigDecimal; +import org.openapitools.model.ChildWithNullable; import org.openapitools.model.Client; import java.util.Date; import org.openapitools.model.EnumClass; @@ -114,6 +115,11 @@ public Response testJsonFormData(String param, String param2, SecurityContext se return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); } @Override + public Response testNullable(ChildWithNullable childWithNullable, SecurityContext securityContext) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + @Override public Response testQueryParameterCollectionFormat( @NotNull List pipe, @NotNull List ioutil, @NotNull List http, @NotNull List url, @NotNull List context, @NotNull String allowEmpty, Map language, SecurityContext securityContext) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); diff --git a/samples/server/petstore/php-laravel/.openapi-generator/FILES b/samples/server/petstore/php-laravel/.openapi-generator/FILES index dbd3b18a17d0..b962dea822e3 100644 --- a/samples/server/petstore/php-laravel/.openapi-generator/FILES +++ b/samples/server/petstore/php-laravel/.openapi-generator/FILES @@ -32,6 +32,7 @@ lib/app/Models/ArrayTest.php lib/app/Models/Capitalization.php lib/app/Models/Cat.php lib/app/Models/Category.php +lib/app/Models/ChildWithNullable.php lib/app/Models/ClassModel.php lib/app/Models/Client.php lib/app/Models/DeprecatedObject.php @@ -63,6 +64,7 @@ lib/app/Models/OuterEnumDefaultValue.php lib/app/Models/OuterEnumInteger.php lib/app/Models/OuterEnumIntegerDefaultValue.php lib/app/Models/OuterObjectWithEnumProperty.php +lib/app/Models/ParentWithNullable.php lib/app/Models/Pet.php lib/app/Models/ReadOnlyFirst.php lib/app/Models/SingleRefType.php diff --git a/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php b/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php index 2aadf9fe902c..486d313b45d2 100644 --- a/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php +++ b/samples/server/petstore/php-laravel/lib/app/Http/Controllers/FakeController.php @@ -426,6 +426,30 @@ public function testJsonFormData() return response('How about implementing testJsonFormData as a get method ?'); } + /** + * Operation testNullable + * + * test nullable parent property. + * + * + * @return Http response + */ + public function testNullable() + { + $input = Request::all(); + + //path params validation + + + //not path params validation + if (!isset($input['childWithNullable'])) { + throw new \InvalidArgumentException('Missing the required parameter $childWithNullable when calling testNullable'); + } + $childWithNullable = $input['childWithNullable']; + + + return response('How about implementing testNullable as a post method ?'); + } /** * Operation fakeOuterBooleanSerialize * diff --git a/samples/server/petstore/php-laravel/lib/app/Models/ChildWithNullable.php b/samples/server/petstore/php-laravel/lib/app/Models/ChildWithNullable.php new file mode 100644 index 000000000000..f1354195cb4b --- /dev/null +++ b/samples/server/petstore/php-laravel/lib/app/Models/ChildWithNullable.php @@ -0,0 +1,21 @@ +get('/v2/fake/jsonFormData', 'FakeApi@testJsonFormData'); +/** + * post testNullable + * Summary: test nullable parent property + * Notes: + */ +$router->post('/v2/fake/nullable', 'FakeApi@testNullable'); + /** * post fakeOuterBooleanSerialize * Summary: From aba55f64f29c1830bde77ee169a250ba73a0e328 Mon Sep 17 00:00:00 2001 From: Martin <2026226+martin-mfg@users.noreply.github.com> Date: Sun, 10 Sep 2023 18:41:48 +0200 Subject: [PATCH 5/7] generate samples again --- .../petstore/java-helidon-client/mp/.openapi-generator/FILES | 2 -- .../petstore/java-helidon-client/se/.openapi-generator/FILES | 2 -- .../petstore/java/apache-httpclient/.openapi-generator/FILES | 2 -- samples/client/petstore/java/feign/.openapi-generator/FILES | 2 -- samples/client/petstore/java/resteasy/.openapi-generator/FILES | 2 -- .../petstore/java/resttemplate-withXml/.openapi-generator/FILES | 2 -- .../client/petstore/java/resttemplate/.openapi-generator/FILES | 2 -- samples/client/petstore/java/vertx/.openapi-generator/FILES | 2 -- .../petstore/java/webclient-jakarta/.openapi-generator/FILES | 2 -- .../petstore/java/webclient-swagger2/.openapi-generator/FILES | 2 -- samples/client/petstore/java/webclient/.openapi-generator/FILES | 2 -- samples/client/petstore/perl/.openapi-generator/FILES | 2 -- .../php-nextgen/OpenAPIClient-php/.openapi-generator/FILES | 2 -- samples/client/petstore/ruby-autoload/.openapi-generator/FILES | 2 -- samples/client/petstore/ruby-faraday/.openapi-generator/FILES | 2 -- .../.openapi-generator/FILES | 2 -- .../dart-dio/petstore_client_lib_fake/.openapi-generator/FILES | 2 -- .../dart2/petstore_client_lib_fake/.openapi-generator/FILES | 2 -- .../petstore/java-helidon-server/mp/.openapi-generator/FILES | 2 -- .../petstore/java-helidon-server/se/.openapi-generator/FILES | 2 -- 20 files changed, 40 deletions(-) diff --git a/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES b/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES index a94790d3673e..697bbc6ddabd 100644 --- a/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES +++ b/samples/client/petstore/java-helidon-client/mp/.openapi-generator/FILES @@ -116,5 +116,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES b/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES index abb8b0f182f3..e94daa98539c 100644 --- a/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES +++ b/samples/client/petstore/java-helidon-client/se/.openapi-generator/FILES @@ -125,5 +125,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES b/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES index ce45083786b7..c3b1e93a673c 100644 --- a/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES +++ b/samples/client/petstore/java/apache-httpclient/.openapi-generator/FILES @@ -141,5 +141,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/feign/.openapi-generator/FILES b/samples/client/petstore/java/feign/.openapi-generator/FILES index 60ba7d353fe5..995a090dcb2f 100644 --- a/samples/client/petstore/java/feign/.openapi-generator/FILES +++ b/samples/client/petstore/java/feign/.openapi-generator/FILES @@ -88,5 +88,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/resteasy/.openapi-generator/FILES b/samples/client/petstore/java/resteasy/.openapi-generator/FILES index e62cae5e14c9..5268fd94f532 100644 --- a/samples/client/petstore/java/resteasy/.openapi-generator/FILES +++ b/samples/client/petstore/java/resteasy/.openapi-generator/FILES @@ -142,5 +142,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES index f38c01458cab..66e0488958e7 100644 --- a/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate-withXml/.openapi-generator/FILES @@ -137,5 +137,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/resttemplate/.openapi-generator/FILES b/samples/client/petstore/java/resttemplate/.openapi-generator/FILES index f38c01458cab..66e0488958e7 100644 --- a/samples/client/petstore/java/resttemplate/.openapi-generator/FILES +++ b/samples/client/petstore/java/resttemplate/.openapi-generator/FILES @@ -137,5 +137,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/vertx/.openapi-generator/FILES b/samples/client/petstore/java/vertx/.openapi-generator/FILES index 734a2b4bd937..78449bae3e43 100644 --- a/samples/client/petstore/java/vertx/.openapi-generator/FILES +++ b/samples/client/petstore/java/vertx/.openapi-generator/FILES @@ -155,5 +155,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES index 7a2d1256298d..cf2db2afaf10 100644 --- a/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-jakarta/.openapi-generator/FILES @@ -138,5 +138,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES index 7a2d1256298d..cf2db2afaf10 100644 --- a/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient-swagger2/.openapi-generator/FILES @@ -138,5 +138,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/java/webclient/.openapi-generator/FILES b/samples/client/petstore/java/webclient/.openapi-generator/FILES index 7a2d1256298d..cf2db2afaf10 100644 --- a/samples/client/petstore/java/webclient/.openapi-generator/FILES +++ b/samples/client/petstore/java/webclient/.openapi-generator/FILES @@ -138,5 +138,3 @@ 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/test/java/org/openapitools/client/model/ChildWithNullableTest.java -src/test/java/org/openapitools/client/model/ParentWithNullableTest.java diff --git a/samples/client/petstore/perl/.openapi-generator/FILES b/samples/client/petstore/perl/.openapi-generator/FILES index 0f9d770912c9..6eb6311e98c7 100644 --- a/samples/client/petstore/perl/.openapi-generator/FILES +++ b/samples/client/petstore/perl/.openapi-generator/FILES @@ -120,5 +120,3 @@ lib/WWW/OpenAPIClient/Role.pm lib/WWW/OpenAPIClient/Role/AutoDoc.pm lib/WWW/OpenAPIClient/StoreApi.pm lib/WWW/OpenAPIClient/UserApi.pm -t/ChildWithNullableTest.t -t/ParentWithNullableTest.t diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES b/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES index f368009974a2..b7160868e129 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/.openapi-generator/FILES @@ -123,5 +123,3 @@ src/Model/SpecialModelName.php src/Model/Tag.php src/Model/User.php src/ObjectSerializer.php -tests/Model/ChildWithNullableTest.php -tests/Model/ParentWithNullableTest.php diff --git a/samples/client/petstore/ruby-autoload/.openapi-generator/FILES b/samples/client/petstore/ruby-autoload/.openapi-generator/FILES index 401ceae858c9..f005dcee5522 100644 --- a/samples/client/petstore/ruby-autoload/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-autoload/.openapi-generator/FILES @@ -127,6 +127,4 @@ lib/petstore/version.rb petstore.gemspec spec/api_client_spec.rb spec/configuration_spec.rb -spec/models/child_with_nullable_spec.rb -spec/models/parent_with_nullable_spec.rb spec/spec_helper.rb diff --git a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES index 401ceae858c9..f005dcee5522 100644 --- a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES @@ -127,6 +127,4 @@ lib/petstore/version.rb petstore.gemspec spec/api_client_spec.rb spec/configuration_spec.rb -spec/models/child_with_nullable_spec.rb -spec/models/parent_with_nullable_spec.rb spec/spec_helper.rb diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES index bed568d3b7ff..9507ce9ce3fb 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES @@ -123,5 +123,3 @@ lib/src/model/special_model_name.dart lib/src/model/tag.dart lib/src/model/user.dart pubspec.yaml -test/child_with_nullable_test.dart -test/parent_with_nullable_test.dart diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES index ec17d50cd6e1..b6f2734cf3f7 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/.openapi-generator/FILES @@ -125,5 +125,3 @@ lib/src/model/tag.dart lib/src/model/user.dart lib/src/serializers.dart pubspec.yaml -test/child_with_nullable_test.dart -test/parent_with_nullable_test.dart diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES index b948518e8604..f9f1005bc081 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/.openapi-generator/FILES @@ -125,5 +125,3 @@ lib/model/special_model_name.dart lib/model/tag.dart lib/model/user.dart pubspec.yaml -test/child_with_nullable_test.dart -test/parent_with_nullable_test.dart diff --git a/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES b/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES index 4c9047e40495..7fb08618a074 100644 --- a/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES +++ b/samples/server/petstore/java-helidon-server/mp/.openapi-generator/FILES @@ -71,5 +71,3 @@ src/main/resources/META-INF/beans.xml src/main/resources/META-INF/microprofile-config.properties src/main/resources/META-INF/openapi.yml src/main/resources/logging.properties -src/test/java/org/openapitools/server/model/ChildWithNullableTest.java -src/test/java/org/openapitools/server/model/ParentWithNullableTest.java diff --git a/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES b/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES index e08b2b4d0111..7202c2d2cdc3 100644 --- a/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES +++ b/samples/server/petstore/java-helidon-server/se/.openapi-generator/FILES @@ -72,5 +72,3 @@ src/main/resources/META-INF/openapi.yml src/main/resources/application.yaml src/main/resources/logging.properties src/test/java/org/openapitools/server/MainTest.java -src/test/java/org/openapitools/server/model/ChildWithNullableTest.java -src/test/java/org/openapitools/server/model/ParentWithNullableTest.java From 24274e7f9f32051dfcb0b5ebc393efc38bb540dd Mon Sep 17 00:00:00 2001 From: Martin <2026226+martin-mfg@users.noreply.github.com> Date: Mon, 11 Sep 2023 07:48:19 +0200 Subject: [PATCH 6/7] generates samples again --- .../python/openapi_client/api/body_api.py | 1 - .../UseSourceGeneration/Api/AnotherFakeApi.cs | 5 +- .../src/UseSourceGeneration/Api/DefaultApi.cs | 8 +- .../src/UseSourceGeneration/Api/FakeApi.cs | 11 +- .../Api/FakeClassnameTags123Api.cs | 5 +- .../src/UseSourceGeneration/Api/PetApi.cs | 8 +- .../src/UseSourceGeneration/Api/StoreApi.cs | 5 +- .../src/UseSourceGeneration/Api/UserApi.cs | 5 +- .../client/model/ChildWithNullable.java | 11 - .../client/model/ParentWithNullable.java | 1 + .../okhttp-gson-3.1/.openapi-generator/FILES | 8 - .../petstore/java/okhttp-gson-3.1/README.md | 4 - .../java/okhttp-gson-3.1/api/openapi.yaml | 174 ++++--------- .../java/okhttp-gson-3.1/docs/Animal.md | 4 +- .../java/okhttp-gson-3.1/docs/Category.md | 4 +- .../okhttp-gson-3.1/docs/ModelApiResponse.md | 6 +- .../java/okhttp-gson-3.1/docs/Order.md | 10 +- .../petstore/java/okhttp-gson-3.1/docs/Pet.md | 8 +- .../java/okhttp-gson-3.1/docs/PetApi.md | 56 ++-- .../java/okhttp-gson-3.1/docs/StoreApi.md | 14 +- .../petstore/java/okhttp-gson-3.1/docs/Tag.md | 4 +- .../java/okhttp-gson-3.1/docs/User.md | 16 +- .../java/okhttp-gson-3.1/docs/UserApi.md | 42 +-- .../java/org/openapitools/client/JSON.java | 25 +- .../org/openapitools/client/api/PetApi.java | 85 +++--- .../org/openapitools/client/api/StoreApi.java | 36 +-- .../org/openapitools/client/api/UserApi.java | 119 +++++---- .../org/openapitools/client/model/Animal.java | 111 ++++++-- .../openapitools/client/model/Category.java | 31 ++- .../client/model/ModelApiResponse.java | 42 +-- .../org/openapitools/client/model/Order.java | 70 ++--- .../org/openapitools/client/model/Pet.java | 107 +++----- .../org/openapitools/client/model/Tag.java | 31 ++- .../org/openapitools/client/model/User.java | 94 ++++--- .../petstore/lua/petstore/model/user.lua | 4 +- .../petstore/perl/.openapi-generator/FILES | 4 +- samples/client/petstore/perl/README.md | 6 +- .../petstore/perl/docs/DeprecatedObject.md | 15 ++ .../petstore/perl/docs/HealthCheckResult.md | 2 +- .../perl/docs/ObjectWithDeprecatedFields.md | 2 +- .../OpenAPIClient/Object/DeprecatedObject.pm | 242 ++++++++++++++++++ .../OpenAPIClient/Object/HealthCheckResult.pm | 6 +- .../Object/ObjectWithDeprecatedFields.pm | 6 +- .../petstore/perl/t/DeprecatedObjectTest.t | 34 +++ .../src/Model/ChildWithNullable.php | 2 +- .../src/Model/ParentWithNullable.php | 2 +- .../powershell/.openapi-generator/FILES | 2 +- samples/client/petstore/powershell/README.md | 2 +- .../petstore/powershell/docs/ModelMapping.md | 6 +- .../docs/ObjectWithDeprecatedFields.md | 4 +- .../src/PSPetstore/Model/ModelMapping.ps1 | 97 +++++++ .../Model/ObjectWithDeprecatedFields.ps1 | 12 +- .../tests/Model/ModelMapping.Tests.ps1 | 17 ++ .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../model/ChildWithNullableDto.java | 4 +- .../model/ParentWithNullableDto.java | 2 +- .../petstore_api/api/another_fake_api.py | 1 - .../petstore_api/api/fake_api.py | 1 - .../api/fake_classname_tags123_api.py | 1 - .../petstore_api/api/pet_api.py | 1 - .../petstore_api/api/store_api.py | 1 - .../petstore_api/api/user_api.py | 1 - .../petstore_api/api/another_fake_api.py | 1 - .../python/petstore_api/api/fake_api.py | 1 - .../api/fake_classname_tags123_api.py | 1 - .../python/petstore_api/api/pet_api.py | 1 - .../python/petstore_api/api/store_api.py | 1 - .../python/petstore_api/api/user_api.py | 1 - .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../main/java/org/openapitools/model/Pet.java | 9 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../openapitools/model/ChildWithNullable.java | 4 +- .../model/ParentWithNullable.java | 2 +- .../virtualan/model/ChildWithNullable.java | 4 +- .../virtualan/model/ParentWithNullable.java | 2 +- .../model/ChildWithNullableDto.java | 4 +- .../model/ParentWithNullableDto.java | 2 +- 97 files changed, 1018 insertions(+), 723 deletions(-) create mode 100644 samples/client/petstore/perl/docs/DeprecatedObject.md create mode 100644 samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm create mode 100644 samples/client/petstore/perl/t/DeprecatedObjectTest.t create mode 100644 samples/client/petstore/powershell/src/PSPetstore/Model/ModelMapping.ps1 create mode 100644 samples/client/petstore/powershell/tests/Model/ModelMapping.Tests.ps1 diff --git a/samples/client/echo_api/python/openapi_client/api/body_api.py b/samples/client/echo_api/python/openapi_client/api/body_api.py index 553feae23a3c..a51f6c55926d 100644 --- a/samples/client/echo_api/python/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python/openapi_client/api/body_api.py @@ -19,7 +19,6 @@ from pydantic import validate_arguments, ValidationError -from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictStr, conlist from typing import Any, Dict, Optional, Union diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs index cf6063040ffd..64ca5ea4ef5c 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs @@ -92,7 +92,6 @@ internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception) public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private ModelClientDeserializationContext _modelClientDeserializationContext; /// /// The logger @@ -138,8 +137,7 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi /// Initializes a new instance of the class. /// /// - public AnotherFakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents, - ModelClientDeserializationContext modelClientDeserializationContext, + public AnotherFakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -147,7 +145,6 @@ public AnotherFakeApi(ILogger logger, HttpClient httpClient, Jso TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; - _modelClientDeserializationContext = modelClientDeserializationContext; Logger = logger; HttpClient = httpClient; Events = anotherFakeApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs index 6a7814a941d5..b93d77a886f2 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs @@ -256,8 +256,6 @@ internal void ExecuteOnErrorTest(Exception exception) public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; - private FooGetDefaultResponseDeserializationContext _fooGetDefaultResponseDeserializationContext; - private NotificationtestGetElementsV1ResponseMPayloadDeserializationContext _notificationtestGetElementsV1ResponseMPayloadDeserializationContext; /// /// The logger @@ -303,9 +301,7 @@ public sealed partial class DefaultApi : IDefaultApi /// Initializes a new instance of the class. /// /// - public DefaultApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents, - FooGetDefaultResponseDeserializationContext fooGetDefaultResponseDeserializationContext, - NotificationtestGetElementsV1ResponseMPayloadDeserializationContext notificationtestGetElementsV1ResponseMPayloadDeserializationContext, + public DefaultApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -313,8 +309,6 @@ public DefaultApi(ILogger logger, HttpClient httpClient, JsonSeriali TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; - _fooGetDefaultResponseDeserializationContext = fooGetDefaultResponseDeserializationContext; - _notificationtestGetElementsV1ResponseMPayloadDeserializationContext = notificationtestGetElementsV1ResponseMPayloadDeserializationContext; Logger = logger; HttpClient = httpClient; Events = defaultApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs index 0e32bae17000..2ce166830a07 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs @@ -762,9 +762,6 @@ internal void ExecuteOnErrorTestQueryParameterCollectionFormat(Exception excepti public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; - private HealthCheckResultDeserializationContext _healthCheckResultDeserializationContext; - private OuterCompositeDeserializationContext _outerCompositeDeserializationContext; - private ModelClientDeserializationContext _modelClientDeserializationContext; /// /// The logger @@ -810,10 +807,7 @@ public sealed partial class FakeApi : IFakeApi /// Initializes a new instance of the class. /// /// - public FakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeApiEvents fakeApiEvents, - HealthCheckResultDeserializationContext healthCheckResultDeserializationContext, - OuterCompositeDeserializationContext outerCompositeDeserializationContext, - ModelClientDeserializationContext modelClientDeserializationContext, + public FakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeApiEvents fakeApiEvents,, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -821,9 +815,6 @@ public FakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOpt TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; - _healthCheckResultDeserializationContext = healthCheckResultDeserializationContext; - _outerCompositeDeserializationContext = outerCompositeDeserializationContext; - _modelClientDeserializationContext = modelClientDeserializationContext; Logger = logger; HttpClient = httpClient; Events = fakeApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs index 43825e1856ba..9a1713d2cbf2 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs @@ -92,7 +92,6 @@ internal void ExecuteOnErrorTestClassname(Exception exception) public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; - private ModelClientDeserializationContext _modelClientDeserializationContext; /// /// The logger @@ -138,8 +137,7 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api /// Initializes a new instance of the class. /// /// - public FakeClassnameTags123Api(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents, - ModelClientDeserializationContext modelClientDeserializationContext, + public FakeClassnameTags123Api(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -147,7 +145,6 @@ public FakeClassnameTags123Api(ILogger logger, HttpClie TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; - _modelClientDeserializationContext = modelClientDeserializationContext; Logger = logger; HttpClient = httpClient; Events = fakeClassnameTags123ApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs index 6ce306fc7db7..83e0bf27e908 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs @@ -450,8 +450,6 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; - private PetDeserializationContext _petDeserializationContext; - private ApiResponseDeserializationContext _apiResponseDeserializationContext; /// /// The logger @@ -497,9 +495,7 @@ public sealed partial class PetApi : IPetApi /// Initializes a new instance of the class. /// /// - public PetApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, PetApiEvents petApiEvents, - PetDeserializationContext petDeserializationContext, - ApiResponseDeserializationContext apiResponseDeserializationContext, + public PetApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, PetApiEvents petApiEvents,, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -507,8 +503,6 @@ public PetApi(ILogger logger, HttpClient httpClient, JsonSerializerOptio TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; - _petDeserializationContext = petDeserializationContext; - _apiResponseDeserializationContext = apiResponseDeserializationContext; Logger = logger; HttpClient = httpClient; Events = petApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs index 78c789c85b7b..e3881d4c1443 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs @@ -219,7 +219,6 @@ internal void ExecuteOnErrorPlaceOrder(Exception exception) public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; - private OrderDeserializationContext _orderDeserializationContext; /// /// The logger @@ -265,8 +264,7 @@ public sealed partial class StoreApi : IStoreApi /// Initializes a new instance of the class. /// /// - public StoreApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents, - OrderDeserializationContext orderDeserializationContext, + public StoreApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -274,7 +272,6 @@ public StoreApi(ILogger logger, HttpClient httpClient, JsonSerializerO TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; - _orderDeserializationContext = orderDeserializationContext; Logger = logger; HttpClient = httpClient; Events = storeApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs index 48f91095f805..7f538c1d4e82 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs @@ -395,7 +395,6 @@ internal void ExecuteOnErrorUpdateUser(Exception exception) public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; - private UserDeserializationContext _userDeserializationContext; /// /// The logger @@ -441,8 +440,7 @@ public sealed partial class UserApi : IUserApi /// Initializes a new instance of the class. /// /// - public UserApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, UserApiEvents userApiEvents, - UserDeserializationContext userDeserializationContext, + public UserApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, UserApiEvents userApiEvents,, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -450,7 +448,6 @@ public UserApi(ILogger logger, HttpClient httpClient, JsonSerializerOpt TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; - _userDeserializationContext = userDeserializationContext; Logger = logger; HttpClient = httpClient; Events = userApiEvents; diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java index 808a97496f36..7d8fa698f333 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ChildWithNullable.java @@ -74,17 +74,6 @@ public void setOtherProperty(String otherProperty) { this.otherProperty = otherProperty; } - @Override - public ChildWithNullable type(TypeEnum type) { - this.setType(type); - return this; - } - - @Override - public ChildWithNullable nullableProperty(String nullableProperty) { - this.setNullableProperty(nullableProperty); - return this; - } @Override public boolean equals(Object o) { diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java index b8ad35eda765..defe2fe2dd2c 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ParentWithNullable.java @@ -149,6 +149,7 @@ public void setNullableProperty(String nullableProperty) { this.nullableProperty = JsonNullable.of(nullableProperty); } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES b/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES index af9fa6831fb6..3194f879514d 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES +++ b/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES @@ -6,16 +6,12 @@ api/openapi.yaml build.gradle build.sbt docs/Animal.md -docs/Cat.md docs/Category.md -docs/Dog.md docs/ModelApiResponse.md -docs/OneOfStringOrInt.md docs/Order.md docs/Pet.md docs/PetApi.md docs/StoreApi.md -docs/StringOrInt.md docs/Tag.md docs/User.md docs/UserApi.md @@ -54,13 +50,9 @@ src/main/java/org/openapitools/client/auth/OAuthOkHttpClient.java src/main/java/org/openapitools/client/auth/RetryingOAuth.java src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java src/main/java/org/openapitools/client/model/Animal.java -src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java -src/main/java/org/openapitools/client/model/Dog.java src/main/java/org/openapitools/client/model/ModelApiResponse.java -src/main/java/org/openapitools/client/model/OneOfStringOrInt.java src/main/java/org/openapitools/client/model/Order.java src/main/java/org/openapitools/client/model/Pet.java -src/main/java/org/openapitools/client/model/StringOrInt.java src/main/java/org/openapitools/client/model/Tag.java src/main/java/org/openapitools/client/model/User.java diff --git a/samples/client/petstore/java/okhttp-gson-3.1/README.md b/samples/client/petstore/java/okhttp-gson-3.1/README.md index 4d1472eaa92a..c8fe00e38d9e 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/README.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/README.md @@ -143,14 +143,10 @@ Class | Method | HTTP request | Description ## Documentation for Models - [Animal](docs/Animal.md) - - [Cat](docs/Cat.md) - [Category](docs/Category.md) - - [Dog](docs/Dog.md) - [ModelApiResponse](docs/ModelApiResponse.md) - - [OneOfStringOrInt](docs/OneOfStringOrInt.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) - - [StringOrInt](docs/StringOrInt.md) - [Tag](docs/Tag.md) - [User](docs/User.md) diff --git a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml index bc23e2bb6c6c..f4593d8fca20 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml +++ b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml @@ -98,8 +98,6 @@ paths: - available - pending - sold - type: string - type: array style: form responses: "200": @@ -108,12 +106,10 @@ paths: schema: items: $ref: '#/components/schemas/Pet' - type: array application/json: schema: items: $ref: '#/components/schemas/Pet' - type: array description: successful operation "400": description: Invalid status value @@ -137,9 +133,7 @@ paths: name: tags required: true schema: - items: - type: string - type: array + items: {} style: form responses: "200": @@ -148,12 +142,10 @@ paths: schema: items: $ref: '#/components/schemas/Pet' - type: array application/json: schema: items: $ref: '#/components/schemas/Pet' - type: array description: successful operation "400": description: Invalid tag value @@ -173,8 +165,7 @@ paths: in: header name: api_key required: false - schema: - type: string + schema: {} style: simple - description: Pet id to delete explode: false @@ -183,7 +174,6 @@ paths: required: true schema: format: int64 - type: integer style: simple responses: "400": @@ -207,7 +197,6 @@ paths: required: true schema: format: int64 - type: integer style: simple responses: "200": @@ -240,7 +229,6 @@ paths: required: true schema: format: int64 - type: integer style: simple requestBody: content: @@ -271,7 +259,6 @@ paths: required: true schema: format: int64 - type: integer style: simple requestBody: content: @@ -305,7 +292,6 @@ paths: schema: additionalProperties: format: int32 - type: integer description: successful operation security: - api_key: [] @@ -352,8 +338,7 @@ paths: in: path name: orderId required: true - schema: - type: string + schema: {} style: simple responses: "400": @@ -378,7 +363,6 @@ paths: format: int64 maximum: 5 minimum: 1 - type: integer style: simple responses: "200": @@ -463,25 +447,21 @@ paths: required: true schema: pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" - type: string style: form - description: The password for login in clear text explode: true in: query name: password required: true - schema: - type: string + schema: {} style: form responses: "200": content: application/xml: - schema: - type: string + schema: {} application/json: - schema: - type: string + schema: {} description: successful operation headers: Set-Cookie: @@ -490,21 +470,18 @@ paths: explode: false schema: example: AUTH_KEY=abcde12345; Path=/; HttpOnly - type: string style: simple X-Rate-Limit: description: calls per hour allowed by the user explode: false schema: format: int32 - type: integer style: simple X-Expires-After: description: date in UTC when token expires explode: false schema: format: date-time - type: string style: simple "400": description: Invalid username/password supplied @@ -535,8 +512,7 @@ paths: in: path name: username required: true - schema: - type: string + schema: {} style: simple responses: "400": @@ -558,8 +534,7 @@ paths: in: path name: username required: true - schema: - type: string + schema: {} style: simple responses: "200": @@ -588,8 +563,7 @@ paths: in: path name: username required: true - schema: - type: string + schema: {} style: simple requestBody: content: @@ -618,7 +592,6 @@ components: schema: items: $ref: '#/components/schemas/User' - type: array description: List of user object required: true Pet: @@ -635,138 +608,106 @@ components: Order: description: An order for a pets from the pet store example: - petId: 6 - quantity: 1 - id: 0 - shipDate: 2000-01-23T04:56:07.000+00:00 - complete: false - status: placed + petId: "" + quantity: "" + id: "" + shipDate: "" + complete: "" + status: "" properties: id: format: int64 - type: integer petId: format: int64 - type: integer quantity: format: int32 - type: integer shipDate: format: date-time - type: string status: description: Order Status enum: - placed - approved - delivered - type: string complete: default: false - type: boolean title: Pet Order xml: name: Order Category: description: A category for a pet example: - name: name - id: 6 + name: "" + id: "" properties: id: format: int64 - type: integer name: pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" - type: string title: Pet category xml: name: Category User: description: A User who is purchasing from the pet store example: - firstName: firstName - lastName: lastName - password: password - userStatus: 6 - phone: phone - id: 0 - email: email - username: username + firstName: "" + lastName: "" + password: "" + userStatus: "" + phone: "" + id: "" + email: "" + username: "" properties: id: format: int64 - type: integer - username: - type: string - firstName: - type: string - lastName: - type: string - email: - type: string - password: - type: string - phone: - type: string + username: {} + firstName: {} + lastName: {} + email: {} + password: {} + phone: {} userStatus: description: User Status format: int32 - type: integer title: a User xml: name: User Tag: description: A tag for a pet - example: - name: name - id: 1 properties: id: format: int64 - type: integer - name: - type: string + name: {} title: Pet Tag xml: name: Tag Pet: description: A pet for sale in the pet store example: - photoUrls: - - photoUrls - - photoUrls + photoUrls: "" name: doggie - id: 0 + id: "" category: - name: name - id: 6 - tags: - - name: name - id: 1 - - name: name - id: 1 - status: available + name: "" + id: "" + tags: "" + status: "" properties: id: format: int64 - type: integer category: $ref: '#/components/schemas/Category' name: example: doggie - type: string photoUrls: - items: - type: string - type: array + items: {} xml: name: photoUrl wrapped: true tags: items: $ref: '#/components/schemas/Tag' - type: array xml: name: tag wrapped: true @@ -777,7 +718,6 @@ components: - available - pending - sold - type: string required: - name - photoUrls @@ -787,69 +727,53 @@ components: ApiResponse: description: Describes the result of uploading an image resource example: - code: 0 - type: type - message: message + code: "" + type: "" + message: "" properties: code: format: int32 - type: integer - type: - type: string - message: - type: string + type: {} + message: {} title: An uploaded response StringOrInt: - anyOf: - - type: string - - format: int32 - type: integer description: string or int OneOfStringOrInt: description: string or int (onefOf) - oneOf: - - type: string - - type: integer + nullable: true + oneOf: [] Dog: allOf: - $ref: '#/components/schemas/Animal' - properties: - breed: - type: string + breed: {} Cat: allOf: - $ref: '#/components/schemas/Animal' - properties: - declawed: - type: boolean + declawed: {} Animal: discriminator: propertyName: className properties: - className: - type: string + className: {} color: default: red - type: string required: - className updatePetWithForm_request: properties: name: description: Updated name of the pet - type: string status: description: Updated status of the pet - type: string uploadFile_request: properties: additionalMetadata: description: Additional data to pass to server - type: string file: description: file to upload format: binary - type: string securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Animal.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Animal.md index d9b32f14c88a..79206dd6e28c 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Animal.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Animal.md @@ -7,8 +7,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**className** | **String** | | | -|**color** | **String** | | [optional] | +|**className** | **Object** | | | +|**color** | **Object** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Category.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Category.md index a7fc939d252e..1a3cbfcc5e38 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Category.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Category.md @@ -8,8 +8,8 @@ A category for a pet | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Long** | | [optional] | -|**name** | **String** | | [optional] | +|**id** | **Object** | | [optional] | +|**name** | **Object** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/ModelApiResponse.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/ModelApiResponse.md index cd7e3c400be6..d476e3a42aab 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/ModelApiResponse.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/ModelApiResponse.md @@ -8,9 +8,9 @@ Describes the result of uploading an image resource | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**code** | **Integer** | | [optional] | -|**type** | **String** | | [optional] | -|**message** | **String** | | [optional] | +|**code** | **Object** | | [optional] | +|**type** | **Object** | | [optional] | +|**message** | **Object** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Order.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Order.md index 0c33059b8b6a..2d80a0d37fb8 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Order.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Order.md @@ -8,12 +8,12 @@ An order for a pets from the pet store | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Long** | | [optional] | -|**petId** | **Long** | | [optional] | -|**quantity** | **Integer** | | [optional] | -|**shipDate** | **OffsetDateTime** | | [optional] | +|**id** | **Object** | | [optional] | +|**petId** | **Object** | | [optional] | +|**quantity** | **Object** | | [optional] | +|**shipDate** | **Object** | | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] | -|**complete** | **Boolean** | | [optional] | +|**complete** | **Object** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Pet.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Pet.md index 8bb363301232..b69b3b537404 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Pet.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Pet.md @@ -8,11 +8,11 @@ A pet for sale in the pet store | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Long** | | [optional] | +|**id** | **Object** | | [optional] | |**category** | [**Category**](Category.md) | | [optional] | -|**name** | **String** | | | -|**photoUrls** | **List<String>** | | | -|**tags** | [**List<Tag>**](Tag.md) | | [optional] | +|**name** | **Object** | | | +|**photoUrls** | **Object** | | | +|**tags** | **Object** | | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/PetApi.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/PetApi.md index f395ba3f6f16..997a57e44648 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/PetApi.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/PetApi.md @@ -110,8 +110,8 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - Long petId = 56L; // Long | Pet id to delete - String apiKey = "apiKey_example"; // String | + Object petId = null; // Object | Pet id to delete + Object apiKey = null; // Object | try { apiInstance.deletePet(petId, apiKey); } catch (ApiException e) { @@ -129,8 +129,8 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **petId** | **Long**| Pet id to delete | | -| **apiKey** | **String**| | [optional] | +| **petId** | [**Object**](.md)| Pet id to delete | | +| **apiKey** | [**Object**](.md)| | [optional] | ### Return type @@ -152,7 +152,7 @@ null (empty response body) # **findPetsByStatus** -> List<Pet> findPetsByStatus(status) +> Object findPetsByStatus(status) Finds Pets by status @@ -178,9 +178,9 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - List status = Arrays.asList("available"); // List | Status values that need to be considered for filter + Object status = null; // Object | Status values that need to be considered for filter try { - List result = apiInstance.findPetsByStatus(status); + Object result = apiInstance.findPetsByStatus(status); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling PetApi#findPetsByStatus"); @@ -197,11 +197,11 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | +| **status** | [**Object**](.md)| Status values that need to be considered for filter | | ### Return type -[**List<Pet>**](Pet.md) +**Object** ### Authorization @@ -220,7 +220,7 @@ public class Example { # **findPetsByTags** -> List<Pet> findPetsByTags(tags) +> Object findPetsByTags(tags) Finds Pets by tags @@ -246,9 +246,9 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - List tags = Arrays.asList(); // List | Tags to filter by + Object tags = null; // Object | Tags to filter by try { - List result = apiInstance.findPetsByTags(tags); + Object result = apiInstance.findPetsByTags(tags); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling PetApi#findPetsByTags"); @@ -265,11 +265,11 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **tags** | [**List<String>**](String.md)| Tags to filter by | | +| **tags** | [**Object**](.md)| Tags to filter by | | ### Return type -[**List<Pet>**](Pet.md) +**Object** ### Authorization @@ -316,7 +316,7 @@ public class Example { //api_key.setApiKeyPrefix("Token"); PetApi apiInstance = new PetApi(defaultClient); - Long petId = 56L; // Long | ID of pet to return + Object petId = null; // Object | ID of pet to return try { Pet result = apiInstance.getPetById(petId); System.out.println(result); @@ -335,7 +335,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **petId** | **Long**| ID of pet to return | | +| **petId** | [**Object**](.md)| ID of pet to return | | ### Return type @@ -455,9 +455,9 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - Long petId = 56L; // Long | ID of pet that needs to be updated - String name = "name_example"; // String | Updated name of the pet - String status = "status_example"; // String | Updated status of the pet + Object petId = null; // Object | ID of pet that needs to be updated + Object name = null; // Object | Updated name of the pet + Object status = null; // Object | Updated status of the pet try { apiInstance.updatePetWithForm(petId, name, status); } catch (ApiException e) { @@ -475,9 +475,9 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **petId** | **Long**| ID of pet that needs to be updated | | -| **name** | **String**| Updated name of the pet | [optional] | -| **status** | **String**| Updated status of the pet | [optional] | +| **petId** | [**Object**](.md)| ID of pet that needs to be updated | | +| **name** | [**Object**](Object.md)| Updated name of the pet | [optional] | +| **status** | [**Object**](Object.md)| Updated status of the pet | [optional] | ### Return type @@ -525,9 +525,9 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - Long petId = 56L; // Long | ID of pet to update - String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server - File _file = new File("/path/to/file"); // File | file to upload + Object petId = null; // Object | ID of pet to update + Object additionalMetadata = null; // Object | Additional data to pass to server + Object _file = null; // Object | file to upload try { ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, _file); System.out.println(result); @@ -546,9 +546,9 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **petId** | **Long**| ID of pet to update | | -| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | -| **_file** | **File**| file to upload | [optional] | +| **petId** | [**Object**](.md)| ID of pet to update | | +| **additionalMetadata** | [**Object**](Object.md)| Additional data to pass to server | [optional] | +| **_file** | [**Object**](Object.md)| file to upload | [optional] | ### Return type diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/StoreApi.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/StoreApi.md index af54298ffc2e..d4a84a24e652 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/StoreApi.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/StoreApi.md @@ -33,7 +33,7 @@ public class Example { defaultClient.setBasePath("http://petstore.swagger.io/v2"); StoreApi apiInstance = new StoreApi(defaultClient); - String orderId = "orderId_example"; // String | ID of the order that needs to be deleted + Object orderId = null; // Object | ID of the order that needs to be deleted try { apiInstance.deleteOrder(orderId); } catch (ApiException e) { @@ -51,7 +51,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **orderId** | **String**| ID of the order that needs to be deleted | | +| **orderId** | [**Object**](.md)| ID of the order that needs to be deleted | | ### Return type @@ -74,7 +74,7 @@ No authorization required # **getInventory** -> Map<String, Integer> getInventory() +> Map<String, Object> getInventory() Returns pet inventories by status @@ -103,7 +103,7 @@ public class Example { StoreApi apiInstance = new StoreApi(defaultClient); try { - Map result = apiInstance.getInventory(); + Map result = apiInstance.getInventory(); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling StoreApi#getInventory"); @@ -121,7 +121,7 @@ This endpoint does not need any parameter. ### Return type -**Map<String, Integer>** +**Map<String, Object>** ### Authorization @@ -160,7 +160,7 @@ public class Example { defaultClient.setBasePath("http://petstore.swagger.io/v2"); StoreApi apiInstance = new StoreApi(defaultClient); - Long orderId = 56L; // Long | ID of pet that needs to be fetched + Object orderId = null; // Object | ID of pet that needs to be fetched try { Order result = apiInstance.getOrderById(orderId); System.out.println(result); @@ -179,7 +179,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **orderId** | **Long**| ID of pet that needs to be fetched | | +| **orderId** | [**Object**](.md)| ID of pet that needs to be fetched | | ### Return type diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Tag.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Tag.md index abfde4afb501..6b5547b120b7 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Tag.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Tag.md @@ -8,8 +8,8 @@ A tag for a pet | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Long** | | [optional] | -|**name** | **String** | | [optional] | +|**id** | **Object** | | [optional] | +|**name** | **Object** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/User.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/User.md index 426845227bd3..02cacc0b6aaf 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/User.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/User.md @@ -8,14 +8,14 @@ A User who is purchasing from the pet store | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Long** | | [optional] | -|**username** | **String** | | [optional] | -|**firstName** | **String** | | [optional] | -|**lastName** | **String** | | [optional] | -|**email** | **String** | | [optional] | -|**password** | **String** | | [optional] | -|**phone** | **String** | | [optional] | -|**userStatus** | **Integer** | User Status | [optional] | +|**id** | **Object** | | [optional] | +|**username** | **Object** | | [optional] | +|**firstName** | **Object** | | [optional] | +|**lastName** | **Object** | | [optional] | +|**email** | **Object** | | [optional] | +|**password** | **Object** | | [optional] | +|**phone** | **Object** | | [optional] | +|**userStatus** | **Object** | User Status | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/UserApi.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/UserApi.md index 4c338a42137a..17b29f98ef90 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/UserApi.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/UserApi.md @@ -84,7 +84,7 @@ null (empty response body) # **createUsersWithArrayInput** -> createUsersWithArrayInput(user) +> createUsersWithArrayInput(body) Creates list of users with given input array @@ -112,9 +112,9 @@ public class Example { //api_key.setApiKeyPrefix("Token"); UserApi apiInstance = new UserApi(defaultClient); - List user = Arrays.asList(); // List | List of user object + Object body = null; // Object | List of user object try { - apiInstance.createUsersWithArrayInput(user); + apiInstance.createUsersWithArrayInput(body); } catch (ApiException e) { System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); System.err.println("Status code: " + e.getCode()); @@ -130,7 +130,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **user** | [**List<User>**](User.md)| List of user object | | +| **body** | **Object**| List of user object | | ### Return type @@ -152,7 +152,7 @@ null (empty response body) # **createUsersWithListInput** -> createUsersWithListInput(user) +> createUsersWithListInput(body) Creates list of users with given input array @@ -180,9 +180,9 @@ public class Example { //api_key.setApiKeyPrefix("Token"); UserApi apiInstance = new UserApi(defaultClient); - List user = Arrays.asList(); // List | List of user object + Object body = null; // Object | List of user object try { - apiInstance.createUsersWithListInput(user); + apiInstance.createUsersWithListInput(body); } catch (ApiException e) { System.err.println("Exception when calling UserApi#createUsersWithListInput"); System.err.println("Status code: " + e.getCode()); @@ -198,7 +198,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **user** | [**List<User>**](User.md)| List of user object | | +| **body** | **Object**| List of user object | | ### Return type @@ -248,7 +248,7 @@ public class Example { //api_key.setApiKeyPrefix("Token"); UserApi apiInstance = new UserApi(defaultClient); - String username = "username_example"; // String | The name that needs to be deleted + Object username = null; // Object | The name that needs to be deleted try { apiInstance.deleteUser(username); } catch (ApiException e) { @@ -266,7 +266,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **username** | **String**| The name that needs to be deleted | | +| **username** | [**Object**](.md)| The name that needs to be deleted | | ### Return type @@ -310,7 +310,7 @@ public class Example { defaultClient.setBasePath("http://petstore.swagger.io/v2"); UserApi apiInstance = new UserApi(defaultClient); - String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. + Object username = null; // Object | The name that needs to be fetched. Use user1 for testing. try { User result = apiInstance.getUserByName(username); System.out.println(result); @@ -329,7 +329,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | +| **username** | [**Object**](.md)| The name that needs to be fetched. Use user1 for testing. | | ### Return type @@ -353,7 +353,7 @@ No authorization required # **loginUser** -> String loginUser(username, password) +> Object loginUser(username, password) Logs user into the system @@ -374,10 +374,10 @@ public class Example { defaultClient.setBasePath("http://petstore.swagger.io/v2"); UserApi apiInstance = new UserApi(defaultClient); - String username = "username_example"; // String | The user name for login - String password = "password_example"; // String | The password for login in clear text + Object username = null; // Object | The user name for login + Object password = null; // Object | The password for login in clear text try { - String result = apiInstance.loginUser(username, password); + Object result = apiInstance.loginUser(username, password); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling UserApi#loginUser"); @@ -394,12 +394,12 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **username** | **String**| The user name for login | | -| **password** | **String**| The password for login in clear text | | +| **username** | [**Object**](.md)| The user name for login | | +| **password** | [**Object**](.md)| The password for login in clear text | | ### Return type -**String** +**Object** ### Authorization @@ -510,7 +510,7 @@ public class Example { //api_key.setApiKeyPrefix("Token"); UserApi apiInstance = new UserApi(defaultClient); - String username = "username_example"; // String | name that need to be deleted + Object username = null; // Object | name that need to be deleted User user = new User(); // User | Updated user object try { apiInstance.updateUser(username, user); @@ -529,7 +529,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **username** | **String**| name that need to be deleted | | +| **username** | [**Object**](.md)| name that need to be deleted | | | **user** | [**User**](User.md)| Updated user object | | ### Return type diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/JSON.java index 6791d767d970..7a2100290183 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/JSON.java @@ -62,30 +62,10 @@ public static GsonBuilder createGson() { @Override public Class getClassForElement(JsonElement readElement) { Map classByDiscriminatorValue = new HashMap(); - classByDiscriminatorValue.put("Cat", org.openapitools.client.model.Cat.class); - classByDiscriminatorValue.put("Dog", org.openapitools.client.model.Dog.class); classByDiscriminatorValue.put("Animal", org.openapitools.client.model.Animal.class); return getClassByDiscriminator(classByDiscriminatorValue, getDiscriminatorValue(readElement, "className")); } - }) - .registerTypeSelector(org.openapitools.client.model.Cat.class, new TypeSelector() { - @Override - public Class getClassForElement(JsonElement readElement) { - Map classByDiscriminatorValue = new HashMap(); - classByDiscriminatorValue.put("Cat", org.openapitools.client.model.Cat.class); - return getClassByDiscriminator(classByDiscriminatorValue, - getDiscriminatorValue(readElement, "className")); - } - }) - .registerTypeSelector(org.openapitools.client.model.Dog.class, new TypeSelector() { - @Override - public Class getClassForElement(JsonElement readElement) { - Map classByDiscriminatorValue = new HashMap(); - classByDiscriminatorValue.put("Dog", org.openapitools.client.model.Dog.class); - return getClassByDiscriminator(classByDiscriminatorValue, - getDiscriminatorValue(readElement, "className")); - } }) ; GsonBuilder builder = fireBuilder.createGsonBuilder(); @@ -122,14 +102,11 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); - gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Cat.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Animal.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Category.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Dog.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ModelApiResponse.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.OneOfStringOrInt.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Order.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.StringOrInt.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Tag.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.User.CustomTypeAdapterFactory()); gson = gsonBuilder.create(); diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/PetApi.java index 2c57d0c17dcd..9b7a308aa3c2 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/PetApi.java @@ -27,7 +27,6 @@ import java.io.IOException; -import java.io.File; import org.openapitools.client.model.ModelApiResponse; import org.openapitools.client.model.Pet; @@ -216,7 +215,7 @@ public okhttp3.Call addPetAsync(Pet pet, final ApiCallback _callback) throw 400 Invalid pet value - */ - public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deletePetCall(Object petId, Object apiKey, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -265,7 +264,7 @@ public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _ } @SuppressWarnings("rawtypes") - private okhttp3.Call deletePetValidateBeforeCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { + private okhttp3.Call deletePetValidateBeforeCall(Object petId, Object apiKey, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException("Missing the required parameter 'petId' when calling deletePet(Async)"); @@ -287,7 +286,7 @@ private okhttp3.Call deletePetValidateBeforeCall(Long petId, String apiKey, fina 400 Invalid pet value - */ - public void deletePet(Long petId, String apiKey) throws ApiException { + public void deletePet(Object petId, Object apiKey) throws ApiException { deletePetWithHttpInfo(petId, apiKey); } @@ -304,7 +303,7 @@ public void deletePet(Long petId, String apiKey) throws ApiException { 400 Invalid pet value - */ - public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws ApiException { + public ApiResponse deletePetWithHttpInfo(Object petId, Object apiKey) throws ApiException { okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, null); return localVarApiClient.execute(localVarCall); } @@ -323,7 +322,7 @@ public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws 400 Invalid pet value - */ - public okhttp3.Call deletePetAsync(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deletePetAsync(Object petId, Object apiKey, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, _callback); localVarApiClient.executeAsync(localVarCall, _callback); @@ -342,7 +341,7 @@ public okhttp3.Call deletePetAsync(Long petId, String apiKey, final ApiCallback< 400 Invalid status value - */ - public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback _callback) throws ApiException { + public okhttp3.Call findPetsByStatusCall(Object status, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -368,7 +367,7 @@ public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback Map localVarFormParams = new HashMap(); if (status != null) { - localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "status", status)); + localVarQueryParams.addAll(localVarApiClient.parameterToPair("status", status)); } final String[] localVarAccepts = { @@ -392,7 +391,7 @@ public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback } @SuppressWarnings("rawtypes") - private okhttp3.Call findPetsByStatusValidateBeforeCall(List status, final ApiCallback _callback) throws ApiException { + private okhttp3.Call findPetsByStatusValidateBeforeCall(Object status, final ApiCallback _callback) throws ApiException { // verify the required parameter 'status' is set if (status == null) { throw new ApiException("Missing the required parameter 'status' when calling findPetsByStatus(Async)"); @@ -406,7 +405,7 @@ private okhttp3.Call findPetsByStatusValidateBeforeCall(List status, fin * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter (required) - * @return List<Pet> + * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -415,8 +414,8 @@ private okhttp3.Call findPetsByStatusValidateBeforeCall(List status, fin
400 Invalid status value -
*/ - public List findPetsByStatus(List status) throws ApiException { - ApiResponse> localVarResp = findPetsByStatusWithHttpInfo(status); + public Object findPetsByStatus(Object status) throws ApiException { + ApiResponse localVarResp = findPetsByStatusWithHttpInfo(status); return localVarResp.getData(); } @@ -424,7 +423,7 @@ public List findPetsByStatus(List status) throws ApiException { * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter (required) - * @return ApiResponse<List<Pet>> + * @return ApiResponse<Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -433,9 +432,9 @@ public List findPetsByStatus(List status) throws ApiException {
400 Invalid status value -
*/ - public ApiResponse> findPetsByStatusWithHttpInfo(List status) throws ApiException { + public ApiResponse findPetsByStatusWithHttpInfo(Object status) throws ApiException { okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -453,10 +452,10 @@ public ApiResponse> findPetsByStatusWithHttpInfo(List status) 400 Invalid status value - */ - public okhttp3.Call findPetsByStatusAsync(List status, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call findPetsByStatusAsync(Object status, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -475,7 +474,7 @@ public okhttp3.Call findPetsByStatusAsync(List status, final ApiCallback * @deprecated */ @Deprecated - public okhttp3.Call findPetsByTagsCall(List tags, final ApiCallback _callback) throws ApiException { + public okhttp3.Call findPetsByTagsCall(Object tags, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -501,7 +500,7 @@ public okhttp3.Call findPetsByTagsCall(List tags, final ApiCallback _cal Map localVarFormParams = new HashMap(); if (tags != null) { - localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "tags", tags)); + localVarQueryParams.addAll(localVarApiClient.parameterToPair("tags", tags)); } final String[] localVarAccepts = { @@ -526,7 +525,7 @@ public okhttp3.Call findPetsByTagsCall(List tags, final ApiCallback _cal @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call findPetsByTagsValidateBeforeCall(List tags, final ApiCallback _callback) throws ApiException { + private okhttp3.Call findPetsByTagsValidateBeforeCall(Object tags, final ApiCallback _callback) throws ApiException { // verify the required parameter 'tags' is set if (tags == null) { throw new ApiException("Missing the required parameter 'tags' when calling findPetsByTags(Async)"); @@ -540,7 +539,7 @@ private okhttp3.Call findPetsByTagsValidateBeforeCall(List tags, final A * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by (required) - * @return List<Pet> + * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -551,8 +550,8 @@ private okhttp3.Call findPetsByTagsValidateBeforeCall(List tags, final A * @deprecated */ @Deprecated - public List findPetsByTags(List tags) throws ApiException { - ApiResponse> localVarResp = findPetsByTagsWithHttpInfo(tags); + public Object findPetsByTags(Object tags) throws ApiException { + ApiResponse localVarResp = findPetsByTagsWithHttpInfo(tags); return localVarResp.getData(); } @@ -560,7 +559,7 @@ public List findPetsByTags(List tags) throws ApiException { * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by (required) - * @return ApiResponse<List<Pet>> + * @return ApiResponse<Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details
@@ -571,9 +570,9 @@ public List findPetsByTags(List tags) throws ApiException { * @deprecated */ @Deprecated - public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException { + public ApiResponse findPetsByTagsWithHttpInfo(Object tags) throws ApiException { okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -593,10 +592,10 @@ public ApiResponse> findPetsByTagsWithHttpInfo(List tags) thro * @deprecated */ @Deprecated - public okhttp3.Call findPetsByTagsAsync(List tags, final ApiCallback> _callback) throws ApiException { + public okhttp3.Call findPetsByTagsAsync(Object tags, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -614,7 +613,7 @@ public okhttp3.Call findPetsByTagsAsync(List tags, final ApiCallback
404 Pet not found -
*/ - public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getPetByIdCall(Object petId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -661,7 +660,7 @@ public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) thro } @SuppressWarnings("rawtypes") - private okhttp3.Call getPetByIdValidateBeforeCall(Long petId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getPetByIdValidateBeforeCall(Object petId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException("Missing the required parameter 'petId' when calling getPetById(Async)"); @@ -685,7 +684,7 @@ private okhttp3.Call getPetByIdValidateBeforeCall(Long petId, final ApiCallback 404 Pet not found - */ - public Pet getPetById(Long petId) throws ApiException { + public Pet getPetById(Object petId) throws ApiException { ApiResponse localVarResp = getPetByIdWithHttpInfo(petId); return localVarResp.getData(); } @@ -704,7 +703,7 @@ public Pet getPetById(Long petId) throws ApiException { 404 Pet not found - */ - public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { + public ApiResponse getPetByIdWithHttpInfo(Object petId) throws ApiException { okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -725,7 +724,7 @@ public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { 404 Pet not found - */ - public okhttp3.Call getPetByIdAsync(Long petId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getPetByIdAsync(Object petId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); @@ -891,7 +890,7 @@ public okhttp3.Call updatePetAsync(Pet pet, final ApiCallback _callback) th 405 Invalid input - */ - public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updatePetWithFormCall(Object petId, Object name, Object status, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -945,7 +944,7 @@ public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status } @SuppressWarnings("rawtypes") - private okhttp3.Call updatePetWithFormValidateBeforeCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { + private okhttp3.Call updatePetWithFormValidateBeforeCall(Object petId, Object name, Object status, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException("Missing the required parameter 'petId' when calling updatePetWithForm(Async)"); @@ -968,7 +967,7 @@ private okhttp3.Call updatePetWithFormValidateBeforeCall(Long petId, String name 405 Invalid input - */ - public void updatePetWithForm(Long petId, String name, String status) throws ApiException { + public void updatePetWithForm(Object petId, Object name, Object status) throws ApiException { updatePetWithFormWithHttpInfo(petId, name, status); } @@ -986,7 +985,7 @@ public void updatePetWithForm(Long petId, String name, String status) throws Api 405 Invalid input - */ - public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, String status) throws ApiException { + public ApiResponse updatePetWithFormWithHttpInfo(Object petId, Object name, Object status) throws ApiException { okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, null); return localVarApiClient.execute(localVarCall); } @@ -1006,7 +1005,7 @@ public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, 405 Invalid input - */ - public okhttp3.Call updatePetWithFormAsync(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updatePetWithFormAsync(Object petId, Object name, Object status, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, _callback); localVarApiClient.executeAsync(localVarCall, _callback); @@ -1026,7 +1025,7 @@ public okhttp3.Call updatePetWithFormAsync(Long petId, String name, String statu 200 successful operation - */ - public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException { + public okhttp3.Call uploadFileCall(Object petId, Object additionalMetadata, Object _file, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1081,7 +1080,7 @@ public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File _ } @SuppressWarnings("rawtypes") - private okhttp3.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException { + private okhttp3.Call uploadFileValidateBeforeCall(Object petId, Object additionalMetadata, Object _file, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException("Missing the required parameter 'petId' when calling uploadFile(Async)"); @@ -1105,7 +1104,7 @@ private okhttp3.Call uploadFileValidateBeforeCall(Long petId, String additionalM 200 successful operation - */ - public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File _file) throws ApiException { + public ModelApiResponse uploadFile(Object petId, Object additionalMetadata, Object _file) throws ApiException { ApiResponse localVarResp = uploadFileWithHttpInfo(petId, additionalMetadata, _file); return localVarResp.getData(); } @@ -1124,7 +1123,7 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File _ 200 successful operation - */ - public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File _file) throws ApiException { + public ApiResponse uploadFileWithHttpInfo(Object petId, Object additionalMetadata, Object _file) throws ApiException { okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, _file, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -1145,7 +1144,7 @@ public ApiResponse uploadFileWithHttpInfo(Long petId, String a 200 successful operation - */ - public okhttp3.Call uploadFileAsync(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException { + public okhttp3.Call uploadFileAsync(Object petId, Object additionalMetadata, Object _file, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, _file, _callback); Type localVarReturnType = new TypeToken(){}.getType(); diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/StoreApi.java index df8db739366f..c1a8d762da00 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/StoreApi.java @@ -85,7 +85,7 @@ public void setCustomBaseUrl(String customBaseUrl) { 404 Order not found - */ - public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteOrderCall(Object orderId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -130,7 +130,7 @@ public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) } @SuppressWarnings("rawtypes") - private okhttp3.Call deleteOrderValidateBeforeCall(String orderId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call deleteOrderValidateBeforeCall(Object orderId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException("Missing the required parameter 'orderId' when calling deleteOrder(Async)"); @@ -152,7 +152,7 @@ private okhttp3.Call deleteOrderValidateBeforeCall(String orderId, final ApiCall 404 Order not found - */ - public void deleteOrder(String orderId) throws ApiException { + public void deleteOrder(Object orderId) throws ApiException { deleteOrderWithHttpInfo(orderId); } @@ -169,7 +169,7 @@ public void deleteOrder(String orderId) throws ApiException { 404 Order not found - */ - public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiException { + public ApiResponse deleteOrderWithHttpInfo(Object orderId) throws ApiException { okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, null); return localVarApiClient.execute(localVarCall); } @@ -188,7 +188,7 @@ public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiExcep 404 Order not found - */ - public okhttp3.Call deleteOrderAsync(String orderId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteOrderAsync(Object orderId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, _callback); localVarApiClient.executeAsync(localVarCall, _callback); @@ -258,7 +258,7 @@ private okhttp3.Call getInventoryValidateBeforeCall(final ApiCallback _callback) /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return Map<String, Integer> + * @return Map<String, Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -266,15 +266,15 @@ private okhttp3.Call getInventoryValidateBeforeCall(final ApiCallback _callback)
200 successful operation -
*/ - public Map getInventory() throws ApiException { - ApiResponse> localVarResp = getInventoryWithHttpInfo(); + public Map getInventory() throws ApiException { + ApiResponse> localVarResp = getInventoryWithHttpInfo(); return localVarResp.getData(); } /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return ApiResponse<Map<String, Integer>> + * @return ApiResponse<Map<String, Object>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -282,9 +282,9 @@ public Map getInventory() throws ApiException {
200 successful operation -
*/ - public ApiResponse> getInventoryWithHttpInfo() throws ApiException { + public ApiResponse> getInventoryWithHttpInfo() throws ApiException { okhttp3.Call localVarCall = getInventoryValidateBeforeCall(null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -300,10 +300,10 @@ public ApiResponse> getInventoryWithHttpInfo() throws ApiEx 200 successful operation - */ - public okhttp3.Call getInventoryAsync(final ApiCallback> _callback) throws ApiException { + public okhttp3.Call getInventoryAsync(final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = getInventoryValidateBeforeCall(_callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -321,7 +321,7 @@ public okhttp3.Call getInventoryAsync(final ApiCallback> _c 404 Order not found - */ - public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getOrderByIdCall(Object orderId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -368,7 +368,7 @@ public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) } @SuppressWarnings("rawtypes") - private okhttp3.Call getOrderByIdValidateBeforeCall(Long orderId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getOrderByIdValidateBeforeCall(Object orderId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException("Missing the required parameter 'orderId' when calling getOrderById(Async)"); @@ -392,7 +392,7 @@ private okhttp3.Call getOrderByIdValidateBeforeCall(Long orderId, final ApiCallb 404 Order not found - */ - public Order getOrderById(Long orderId) throws ApiException { + public Order getOrderById(Object orderId) throws ApiException { ApiResponse localVarResp = getOrderByIdWithHttpInfo(orderId); return localVarResp.getData(); } @@ -411,7 +411,7 @@ public Order getOrderById(Long orderId) throws ApiException { 404 Order not found - */ - public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiException { + public ApiResponse getOrderByIdWithHttpInfo(Object orderId) throws ApiException { okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -432,7 +432,7 @@ public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiExcep 404 Order not found - */ - public okhttp3.Call getOrderByIdAsync(Long orderId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getOrderByIdAsync(Object orderId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/UserApi.java index 7b8cb5c3dcbe..3335c3d00389 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/UserApi.java @@ -27,7 +27,6 @@ import java.io.IOException; -import java.time.OffsetDateTime; import org.openapitools.client.model.User; import java.lang.reflect.Type; @@ -193,7 +192,7 @@ public okhttp3.Call createUserAsync(User user, final ApiCallback _callback } /** * Build call for createUsersWithArrayInput - * @param user List of user object (required) + * @param body List of user object (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -203,7 +202,7 @@ public okhttp3.Call createUserAsync(User user, final ApiCallback _callback 0 successful operation - */ - public okhttp3.Call createUsersWithArrayInputCall(List user, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createUsersWithArrayInputCall(Object body, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -217,7 +216,7 @@ public okhttp3.Call createUsersWithArrayInputCall(List user, final ApiCall basePath = null; } - Object localVarPostBody = user; + Object localVarPostBody = body; // create path and map variables String localVarPath = "/user/createWithArray"; @@ -248,20 +247,20 @@ public okhttp3.Call createUsersWithArrayInputCall(List user, final ApiCall } @SuppressWarnings("rawtypes") - private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(List user, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'user' is set - if (user == null) { - throw new ApiException("Missing the required parameter 'user' when calling createUsersWithArrayInput(Async)"); + private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(Object body, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling createUsersWithArrayInput(Async)"); } - return createUsersWithArrayInputCall(user, _callback); + return createUsersWithArrayInputCall(body, _callback); } /** * Creates list of users with given input array * - * @param user List of user object (required) + * @param body List of user object (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -269,14 +268,14 @@ private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(List user
0 successful operation -
*/ - public void createUsersWithArrayInput(List user) throws ApiException { - createUsersWithArrayInputWithHttpInfo(user); + public void createUsersWithArrayInput(Object body) throws ApiException { + createUsersWithArrayInputWithHttpInfo(body); } /** * Creates list of users with given input array * - * @param user List of user object (required) + * @param body List of user object (required) * @return ApiResponse<Void> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -285,15 +284,15 @@ public void createUsersWithArrayInput(List user) throws ApiException { 0 successful operation - */ - public ApiResponse createUsersWithArrayInputWithHttpInfo(List user) throws ApiException { - okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(user, null); + public ApiResponse createUsersWithArrayInputWithHttpInfo(Object body) throws ApiException { + okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } /** * Creates list of users with given input array (asynchronously) * - * @param user List of user object (required) + * @param body List of user object (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -303,15 +302,15 @@ public ApiResponse createUsersWithArrayInputWithHttpInfo(List user) 0 successful operation - */ - public okhttp3.Call createUsersWithArrayInputAsync(List user, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createUsersWithArrayInputAsync(Object body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(user, _callback); + okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for createUsersWithListInput - * @param user List of user object (required) + * @param body List of user object (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -321,7 +320,7 @@ public okhttp3.Call createUsersWithArrayInputAsync(List user, final ApiCal 0 successful operation - */ - public okhttp3.Call createUsersWithListInputCall(List user, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createUsersWithListInputCall(Object body, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -335,7 +334,7 @@ public okhttp3.Call createUsersWithListInputCall(List user, final ApiCallb basePath = null; } - Object localVarPostBody = user; + Object localVarPostBody = body; // create path and map variables String localVarPath = "/user/createWithList"; @@ -366,20 +365,20 @@ public okhttp3.Call createUsersWithListInputCall(List user, final ApiCallb } @SuppressWarnings("rawtypes") - private okhttp3.Call createUsersWithListInputValidateBeforeCall(List user, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'user' is set - if (user == null) { - throw new ApiException("Missing the required parameter 'user' when calling createUsersWithListInput(Async)"); + private okhttp3.Call createUsersWithListInputValidateBeforeCall(Object body, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling createUsersWithListInput(Async)"); } - return createUsersWithListInputCall(user, _callback); + return createUsersWithListInputCall(body, _callback); } /** * Creates list of users with given input array * - * @param user List of user object (required) + * @param body List of user object (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -387,14 +386,14 @@ private okhttp3.Call createUsersWithListInputValidateBeforeCall(List user,
0 successful operation -
*/ - public void createUsersWithListInput(List user) throws ApiException { - createUsersWithListInputWithHttpInfo(user); + public void createUsersWithListInput(Object body) throws ApiException { + createUsersWithListInputWithHttpInfo(body); } /** * Creates list of users with given input array * - * @param user List of user object (required) + * @param body List of user object (required) * @return ApiResponse<Void> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -403,15 +402,15 @@ public void createUsersWithListInput(List user) throws ApiException { 0 successful operation - */ - public ApiResponse createUsersWithListInputWithHttpInfo(List user) throws ApiException { - okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(user, null); + public ApiResponse createUsersWithListInputWithHttpInfo(Object body) throws ApiException { + okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, null); return localVarApiClient.execute(localVarCall); } /** * Creates list of users with given input array (asynchronously) * - * @param user List of user object (required) + * @param body List of user object (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -421,9 +420,9 @@ public ApiResponse createUsersWithListInputWithHttpInfo(List user) t 0 successful operation - */ - public okhttp3.Call createUsersWithListInputAsync(List user, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createUsersWithListInputAsync(Object body, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(user, _callback); + okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -440,7 +439,7 @@ public okhttp3.Call createUsersWithListInputAsync(List user, final ApiCall 404 User not found - */ - public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteUserCall(Object username, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -485,7 +484,7 @@ public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) } @SuppressWarnings("rawtypes") - private okhttp3.Call deleteUserValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + private okhttp3.Call deleteUserValidateBeforeCall(Object username, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException("Missing the required parameter 'username' when calling deleteUser(Async)"); @@ -507,7 +506,7 @@ private okhttp3.Call deleteUserValidateBeforeCall(String username, final ApiCall 404 User not found - */ - public void deleteUser(String username) throws ApiException { + public void deleteUser(Object username) throws ApiException { deleteUserWithHttpInfo(username); } @@ -524,7 +523,7 @@ public void deleteUser(String username) throws ApiException { 404 User not found - */ - public ApiResponse deleteUserWithHttpInfo(String username) throws ApiException { + public ApiResponse deleteUserWithHttpInfo(Object username) throws ApiException { okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, null); return localVarApiClient.execute(localVarCall); } @@ -543,7 +542,7 @@ public ApiResponse deleteUserWithHttpInfo(String username) throws ApiExcep 404 User not found - */ - public okhttp3.Call deleteUserAsync(String username, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteUserAsync(Object username, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, _callback); localVarApiClient.executeAsync(localVarCall, _callback); @@ -563,7 +562,7 @@ public okhttp3.Call deleteUserAsync(String username, final ApiCallback _ca 404 User not found - */ - public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getUserByNameCall(Object username, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -610,7 +609,7 @@ public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callba } @SuppressWarnings("rawtypes") - private okhttp3.Call getUserByNameValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getUserByNameValidateBeforeCall(Object username, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException("Missing the required parameter 'username' when calling getUserByName(Async)"); @@ -634,7 +633,7 @@ private okhttp3.Call getUserByNameValidateBeforeCall(String username, final ApiC 404 User not found - */ - public User getUserByName(String username) throws ApiException { + public User getUserByName(Object username) throws ApiException { ApiResponse localVarResp = getUserByNameWithHttpInfo(username); return localVarResp.getData(); } @@ -653,7 +652,7 @@ public User getUserByName(String username) throws ApiException { 404 User not found - */ - public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiException { + public ApiResponse getUserByNameWithHttpInfo(Object username) throws ApiException { okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -674,7 +673,7 @@ public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiEx 404 User not found - */ - public okhttp3.Call getUserByNameAsync(String username, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getUserByNameAsync(Object username, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, _callback); Type localVarReturnType = new TypeToken(){}.getType(); @@ -695,7 +694,7 @@ public okhttp3.Call getUserByNameAsync(String username, final ApiCallback 400 Invalid username/password supplied - */ - public okhttp3.Call loginUserCall(String username, String password, final ApiCallback _callback) throws ApiException { + public okhttp3.Call loginUserCall(Object username, Object password, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -749,7 +748,7 @@ public okhttp3.Call loginUserCall(String username, String password, final ApiCal } @SuppressWarnings("rawtypes") - private okhttp3.Call loginUserValidateBeforeCall(String username, String password, final ApiCallback _callback) throws ApiException { + private okhttp3.Call loginUserValidateBeforeCall(Object username, Object password, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException("Missing the required parameter 'username' when calling loginUser(Async)"); @@ -769,7 +768,7 @@ private okhttp3.Call loginUserValidateBeforeCall(String username, String passwor * * @param username The user name for login (required) * @param password The password for login in clear text (required) - * @return String + * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -778,8 +777,8 @@ private okhttp3.Call loginUserValidateBeforeCall(String username, String passwor
400 Invalid username/password supplied -
*/ - public String loginUser(String username, String password) throws ApiException { - ApiResponse localVarResp = loginUserWithHttpInfo(username, password); + public Object loginUser(Object username, Object password) throws ApiException { + ApiResponse localVarResp = loginUserWithHttpInfo(username, password); return localVarResp.getData(); } @@ -788,7 +787,7 @@ public String loginUser(String username, String password) throws ApiException { * * @param username The user name for login (required) * @param password The password for login in clear text (required) - * @return ApiResponse<String> + * @return ApiResponse<Object> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -797,9 +796,9 @@ public String loginUser(String username, String password) throws ApiException {
400 Invalid username/password supplied -
*/ - public ApiResponse loginUserWithHttpInfo(String username, String password) throws ApiException { + public ApiResponse loginUserWithHttpInfo(Object username, Object password) throws ApiException { okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -818,10 +817,10 @@ public ApiResponse loginUserWithHttpInfo(String username, String passwor 400 Invalid username/password supplied - */ - public okhttp3.Call loginUserAsync(String username, String password, final ApiCallback _callback) throws ApiException { + public okhttp3.Call loginUserAsync(Object username, Object password, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -947,7 +946,7 @@ public okhttp3.Call logoutUserAsync(final ApiCallback _callback) throws Ap 404 User not found - */ - public okhttp3.Call updateUserCall(String username, User user, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updateUserCall(Object username, User user, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -993,7 +992,7 @@ public okhttp3.Call updateUserCall(String username, User user, final ApiCallback } @SuppressWarnings("rawtypes") - private okhttp3.Call updateUserValidateBeforeCall(String username, User user, final ApiCallback _callback) throws ApiException { + private okhttp3.Call updateUserValidateBeforeCall(Object username, User user, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException("Missing the required parameter 'username' when calling updateUser(Async)"); @@ -1021,7 +1020,7 @@ private okhttp3.Call updateUserValidateBeforeCall(String username, User user, fi 404 User not found - */ - public void updateUser(String username, User user) throws ApiException { + public void updateUser(Object username, User user) throws ApiException { updateUserWithHttpInfo(username, user); } @@ -1039,7 +1038,7 @@ public void updateUser(String username, User user) throws ApiException { 404 User not found - */ - public ApiResponse updateUserWithHttpInfo(String username, User user) throws ApiException { + public ApiResponse updateUserWithHttpInfo(Object username, User user) throws ApiException { okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, user, null); return localVarApiClient.execute(localVarCall); } @@ -1059,7 +1058,7 @@ public ApiResponse updateUserWithHttpInfo(String username, User user) thro 404 User not found - */ - public okhttp3.Call updateUserAsync(String username, User user, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updateUserAsync(Object username, User user, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, user, _callback); localVarApiClient.executeAsync(localVarCall, _callback); diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Animal.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Animal.java index ce03faf30dda..71422ece7907 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Animal.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Animal.java @@ -21,6 +21,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -53,17 +54,17 @@ public class Animal { public static final String SERIALIZED_NAME_CLASS_NAME = "className"; @SerializedName(SERIALIZED_NAME_CLASS_NAME) - protected String className; + protected Object className = null; public static final String SERIALIZED_NAME_COLOR = "color"; @SerializedName(SERIALIZED_NAME_COLOR) - private String color = "red"; + private Object color = red; public Animal() { this.className = this.getClass().getSimpleName(); } - public Animal className(String className) { + public Animal className(Object className) { this.className = className; return this; @@ -73,18 +74,18 @@ public Animal className(String className) { * Get className * @return className **/ - @javax.annotation.Nonnull - public String getClassName() { + @javax.annotation.Nullable + public Object getClassName() { return className; } - public void setClassName(String className) { + public void setClassName(Object className) { this.className = className; } - public Animal color(String color) { + public Animal color(Object color) { this.color = color; return this; @@ -95,12 +96,12 @@ public Animal color(String color) { * @return color **/ @javax.annotation.Nullable - public String getColor() { + public Object getColor() { return color; } - public void setColor(String color) { + public void setColor(Object color) { this.color = color; } @@ -164,11 +165,22 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, animal.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(className, color, additionalProperties); } + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -219,19 +231,80 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - String discriminatorValue = jsonElement.getAsJsonObject().get("className").getAsString(); - switch (discriminatorValue) { - case "Cat": - Cat.validateJsonElement(jsonElement); - break; - case "Dog": - Dog.validateJsonElement(jsonElement); - break; - default: - throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue)); + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Animal.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } } } + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Animal.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Animal' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Animal.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Animal value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Animal read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Animal instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } /** * Create an instance of Animal given an JSON string diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Category.java index ec41d25fa99f..97fac31c5064 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Category.java @@ -21,6 +21,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -53,16 +54,16 @@ public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Long id; + private Object id = null; public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - private String name; + private Object name = null; public Category() { } - public Category id(Long id) { + public Category id(Object id) { this.id = id; return this; @@ -73,17 +74,17 @@ public Category id(Long id) { * @return id **/ @javax.annotation.Nullable - public Long getId() { + public Object getId() { return id; } - public void setId(Long id) { + public void setId(Object id) { this.id = id; } - public Category name(String name) { + public Category name(Object name) { this.name = name; return this; @@ -94,12 +95,12 @@ public Category name(String name) { * @return name **/ @javax.annotation.Nullable - public String getName() { + public Object getName() { return name; } - public void setName(String name) { + public void setName(Object name) { this.name = name; } @@ -163,11 +164,22 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, category.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, name, additionalProperties); } + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -217,9 +229,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/ModelApiResponse.java index a1df10aece5f..ba720365bc52 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -21,6 +21,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -53,20 +54,20 @@ public class ModelApiResponse { public static final String SERIALIZED_NAME_CODE = "code"; @SerializedName(SERIALIZED_NAME_CODE) - private Integer code; + private Object code = null; public static final String SERIALIZED_NAME_TYPE = "type"; @SerializedName(SERIALIZED_NAME_TYPE) - private String type; + private Object type = null; public static final String SERIALIZED_NAME_MESSAGE = "message"; @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; + private Object message = null; public ModelApiResponse() { } - public ModelApiResponse code(Integer code) { + public ModelApiResponse code(Object code) { this.code = code; return this; @@ -77,17 +78,17 @@ public ModelApiResponse code(Integer code) { * @return code **/ @javax.annotation.Nullable - public Integer getCode() { + public Object getCode() { return code; } - public void setCode(Integer code) { + public void setCode(Object code) { this.code = code; } - public ModelApiResponse type(String type) { + public ModelApiResponse type(Object type) { this.type = type; return this; @@ -98,17 +99,17 @@ public ModelApiResponse type(String type) { * @return type **/ @javax.annotation.Nullable - public String getType() { + public Object getType() { return type; } - public void setType(String type) { + public void setType(Object type) { this.type = type; } - public ModelApiResponse message(String message) { + public ModelApiResponse message(Object message) { this.message = message; return this; @@ -119,12 +120,12 @@ public ModelApiResponse message(String message) { * @return message **/ @javax.annotation.Nullable - public String getMessage() { + public Object getMessage() { return message; } - public void setMessage(String message) { + public void setMessage(Object message) { this.message = message; } @@ -189,11 +190,22 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, _apiResponse.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(code, type, message, additionalProperties); } + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -245,12 +257,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); - } - if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java index ae66537b4824..d96a4113d96a 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java @@ -20,8 +20,8 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.time.OffsetDateTime; import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -54,19 +54,19 @@ public class Order { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Long id; + private Object id = null; public static final String SERIALIZED_NAME_PET_ID = "petId"; @SerializedName(SERIALIZED_NAME_PET_ID) - private Long petId; + private Object petId = null; public static final String SERIALIZED_NAME_QUANTITY = "quantity"; @SerializedName(SERIALIZED_NAME_QUANTITY) - private Integer quantity; + private Object quantity = null; public static final String SERIALIZED_NAME_SHIP_DATE = "shipDate"; @SerializedName(SERIALIZED_NAME_SHIP_DATE) - private OffsetDateTime shipDate; + private Object shipDate = null; /** * Order Status @@ -79,13 +79,13 @@ public enum StatusEnum { DELIVERED("delivered"); - private String value; + private Object value; - StatusEnum(String value) { + StatusEnum(Object value) { this.value = value; } - public String getValue() { + public Object getValue() { return value; } @@ -94,13 +94,13 @@ public String toString() { return String.valueOf(value); } - public static StatusEnum fromValue(String value) { + public static StatusEnum fromValue(Object value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } public static class Adapter extends TypeAdapter { @@ -111,7 +111,7 @@ public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) thr @Override public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); + Object value = jsonReader.nextObject(); return StatusEnum.fromValue(value); } } @@ -119,16 +119,16 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { public static final String SERIALIZED_NAME_STATUS = "status"; @SerializedName(SERIALIZED_NAME_STATUS) - private StatusEnum status; + private StatusEnum status = null; public static final String SERIALIZED_NAME_COMPLETE = "complete"; @SerializedName(SERIALIZED_NAME_COMPLETE) - private Boolean complete = false; + private Object complete = false; public Order() { } - public Order id(Long id) { + public Order id(Object id) { this.id = id; return this; @@ -139,17 +139,17 @@ public Order id(Long id) { * @return id **/ @javax.annotation.Nullable - public Long getId() { + public Object getId() { return id; } - public void setId(Long id) { + public void setId(Object id) { this.id = id; } - public Order petId(Long petId) { + public Order petId(Object petId) { this.petId = petId; return this; @@ -160,17 +160,17 @@ public Order petId(Long petId) { * @return petId **/ @javax.annotation.Nullable - public Long getPetId() { + public Object getPetId() { return petId; } - public void setPetId(Long petId) { + public void setPetId(Object petId) { this.petId = petId; } - public Order quantity(Integer quantity) { + public Order quantity(Object quantity) { this.quantity = quantity; return this; @@ -181,17 +181,17 @@ public Order quantity(Integer quantity) { * @return quantity **/ @javax.annotation.Nullable - public Integer getQuantity() { + public Object getQuantity() { return quantity; } - public void setQuantity(Integer quantity) { + public void setQuantity(Object quantity) { this.quantity = quantity; } - public Order shipDate(OffsetDateTime shipDate) { + public Order shipDate(Object shipDate) { this.shipDate = shipDate; return this; @@ -202,12 +202,12 @@ public Order shipDate(OffsetDateTime shipDate) { * @return shipDate **/ @javax.annotation.Nullable - public OffsetDateTime getShipDate() { + public Object getShipDate() { return shipDate; } - public void setShipDate(OffsetDateTime shipDate) { + public void setShipDate(Object shipDate) { this.shipDate = shipDate; } @@ -233,7 +233,7 @@ public void setStatus(StatusEnum status) { } - public Order complete(Boolean complete) { + public Order complete(Object complete) { this.complete = complete; return this; @@ -244,12 +244,12 @@ public Order complete(Boolean complete) { * @return complete **/ @javax.annotation.Nullable - public Boolean getComplete() { + public Object getComplete() { return complete; } - public void setComplete(Boolean complete) { + public void setComplete(Object complete) { this.complete = complete; } @@ -317,11 +317,22 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, order.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, petId, quantity, shipDate, status, complete, additionalProperties); } + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -379,9 +390,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java index 69cec0b898e2..85784bbe1a7c 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java @@ -20,11 +20,9 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import org.openapitools.client.model.Category; -import org.openapitools.client.model.Tag; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -57,7 +55,7 @@ public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Long id; + private Object id = null; public static final String SERIALIZED_NAME_CATEGORY = "category"; @SerializedName(SERIALIZED_NAME_CATEGORY) @@ -65,15 +63,15 @@ public class Pet { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - private String name; + private Object name = null; public static final String SERIALIZED_NAME_PHOTO_URLS = "photoUrls"; @SerializedName(SERIALIZED_NAME_PHOTO_URLS) - private List photoUrls = new ArrayList<>(); + private Object photoUrls = null; public static final String SERIALIZED_NAME_TAGS = "tags"; @SerializedName(SERIALIZED_NAME_TAGS) - private List tags; + private Object tags = null; /** * pet status in the store @@ -86,13 +84,13 @@ public enum StatusEnum { SOLD("sold"); - private String value; + private Object value; - StatusEnum(String value) { + StatusEnum(Object value) { this.value = value; } - public String getValue() { + public Object getValue() { return value; } @@ -101,13 +99,13 @@ public String toString() { return String.valueOf(value); } - public static StatusEnum fromValue(String value) { + public static StatusEnum fromValue(Object value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { return b; } } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return null; } public static class Adapter extends TypeAdapter { @@ -118,7 +116,7 @@ public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) thr @Override public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); + Object value = jsonReader.nextObject(); return StatusEnum.fromValue(value); } } @@ -127,12 +125,12 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { public static final String SERIALIZED_NAME_STATUS = "status"; @Deprecated @SerializedName(SERIALIZED_NAME_STATUS) - private StatusEnum status; + private StatusEnum status = null; public Pet() { } - public Pet id(Long id) { + public Pet id(Object id) { this.id = id; return this; @@ -143,12 +141,12 @@ public Pet id(Long id) { * @return id **/ @javax.annotation.Nullable - public Long getId() { + public Object getId() { return id; } - public void setId(Long id) { + public void setId(Object id) { this.id = id; } @@ -174,7 +172,7 @@ public void setCategory(Category category) { } - public Pet name(String name) { + public Pet name(Object name) { this.name = name; return this; @@ -184,71 +182,55 @@ public Pet name(String name) { * Get name * @return name **/ - @javax.annotation.Nonnull - public String getName() { + @javax.annotation.Nullable + public Object getName() { return name; } - public void setName(String name) { + public void setName(Object name) { this.name = name; } - public Pet photoUrls(List photoUrls) { + public Pet photoUrls(Object photoUrls) { this.photoUrls = photoUrls; return this; } - public Pet addPhotoUrlsItem(String photoUrlsItem) { - if (this.photoUrls == null) { - this.photoUrls = new ArrayList<>(); - } - this.photoUrls.add(photoUrlsItem); - return this; - } - /** * Get photoUrls * @return photoUrls **/ - @javax.annotation.Nonnull - public List getPhotoUrls() { + @javax.annotation.Nullable + public Object getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(List photoUrls) { + public void setPhotoUrls(Object photoUrls) { this.photoUrls = photoUrls; } - public Pet tags(List tags) { + public Pet tags(Object tags) { this.tags = tags; return this; } - public Pet addTagsItem(Tag tagsItem) { - if (this.tags == null) { - this.tags = new ArrayList<>(); - } - this.tags.add(tagsItem); - return this; - } - /** * Get tags * @return tags **/ @javax.annotation.Nullable - public List getTags() { + public Object getTags() { return tags; } - public void setTags(List tags) { + public void setTags(Object tags) { this.tags = tags; } @@ -341,11 +323,22 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, pet.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, category, name, photoUrls, tags, status, additionalProperties); } + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -416,32 +409,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) { Category.validateJsonElement(jsonObj.get("category")); } - if (!jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); - } - // ensure the required json array is present - if (jsonObj.get("photoUrls") == null) { - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); - } else if (!jsonObj.get("photoUrls").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `photoUrls` to be an array in the JSON string but got `%s`", jsonObj.get("photoUrls").toString())); - } - if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull()) { - JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags"); - if (jsonArraytags != null) { - // ensure the json data is an array - if (!jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); - } - - // validate the optional field `tags` (array) - for (int i = 0; i < jsonArraytags.size(); i++) { - Tag.validateJsonElement(jsonArraytags.get(i)); - }; - } - } - if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Tag.java index 262ef93dbbd3..24955509692e 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Tag.java @@ -21,6 +21,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -53,16 +54,16 @@ public class Tag { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Long id; + private Object id = null; public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - private String name; + private Object name = null; public Tag() { } - public Tag id(Long id) { + public Tag id(Object id) { this.id = id; return this; @@ -73,17 +74,17 @@ public Tag id(Long id) { * @return id **/ @javax.annotation.Nullable - public Long getId() { + public Object getId() { return id; } - public void setId(Long id) { + public void setId(Object id) { this.id = id; } - public Tag name(String name) { + public Tag name(Object name) { this.name = name; return this; @@ -94,12 +95,12 @@ public Tag name(String name) { * @return name **/ @javax.annotation.Nullable - public String getName() { + public Object getName() { return name; } - public void setName(String name) { + public void setName(Object name) { this.name = name; } @@ -163,11 +164,22 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, tag.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, name, additionalProperties); } + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -217,9 +229,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/User.java index 8c1f31e4d16a..f1a34cee0c97 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/User.java @@ -21,6 +21,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -53,40 +54,40 @@ public class User { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Long id; + private Object id = null; public static final String SERIALIZED_NAME_USERNAME = "username"; @SerializedName(SERIALIZED_NAME_USERNAME) - private String username; + private Object username = null; public static final String SERIALIZED_NAME_FIRST_NAME = "firstName"; @SerializedName(SERIALIZED_NAME_FIRST_NAME) - private String firstName; + private Object firstName = null; public static final String SERIALIZED_NAME_LAST_NAME = "lastName"; @SerializedName(SERIALIZED_NAME_LAST_NAME) - private String lastName; + private Object lastName = null; public static final String SERIALIZED_NAME_EMAIL = "email"; @SerializedName(SERIALIZED_NAME_EMAIL) - private String email; + private Object email = null; public static final String SERIALIZED_NAME_PASSWORD = "password"; @SerializedName(SERIALIZED_NAME_PASSWORD) - private String password; + private Object password = null; public static final String SERIALIZED_NAME_PHONE = "phone"; @SerializedName(SERIALIZED_NAME_PHONE) - private String phone; + private Object phone = null; public static final String SERIALIZED_NAME_USER_STATUS = "userStatus"; @SerializedName(SERIALIZED_NAME_USER_STATUS) - private Integer userStatus; + private Object userStatus = null; public User() { } - public User id(Long id) { + public User id(Object id) { this.id = id; return this; @@ -97,17 +98,17 @@ public User id(Long id) { * @return id **/ @javax.annotation.Nullable - public Long getId() { + public Object getId() { return id; } - public void setId(Long id) { + public void setId(Object id) { this.id = id; } - public User username(String username) { + public User username(Object username) { this.username = username; return this; @@ -118,17 +119,17 @@ public User username(String username) { * @return username **/ @javax.annotation.Nullable - public String getUsername() { + public Object getUsername() { return username; } - public void setUsername(String username) { + public void setUsername(Object username) { this.username = username; } - public User firstName(String firstName) { + public User firstName(Object firstName) { this.firstName = firstName; return this; @@ -139,17 +140,17 @@ public User firstName(String firstName) { * @return firstName **/ @javax.annotation.Nullable - public String getFirstName() { + public Object getFirstName() { return firstName; } - public void setFirstName(String firstName) { + public void setFirstName(Object firstName) { this.firstName = firstName; } - public User lastName(String lastName) { + public User lastName(Object lastName) { this.lastName = lastName; return this; @@ -160,17 +161,17 @@ public User lastName(String lastName) { * @return lastName **/ @javax.annotation.Nullable - public String getLastName() { + public Object getLastName() { return lastName; } - public void setLastName(String lastName) { + public void setLastName(Object lastName) { this.lastName = lastName; } - public User email(String email) { + public User email(Object email) { this.email = email; return this; @@ -181,17 +182,17 @@ public User email(String email) { * @return email **/ @javax.annotation.Nullable - public String getEmail() { + public Object getEmail() { return email; } - public void setEmail(String email) { + public void setEmail(Object email) { this.email = email; } - public User password(String password) { + public User password(Object password) { this.password = password; return this; @@ -202,17 +203,17 @@ public User password(String password) { * @return password **/ @javax.annotation.Nullable - public String getPassword() { + public Object getPassword() { return password; } - public void setPassword(String password) { + public void setPassword(Object password) { this.password = password; } - public User phone(String phone) { + public User phone(Object phone) { this.phone = phone; return this; @@ -223,17 +224,17 @@ public User phone(String phone) { * @return phone **/ @javax.annotation.Nullable - public String getPhone() { + public Object getPhone() { return phone; } - public void setPhone(String phone) { + public void setPhone(Object phone) { this.phone = phone; } - public User userStatus(Integer userStatus) { + public User userStatus(Object userStatus) { this.userStatus = userStatus; return this; @@ -244,12 +245,12 @@ public User userStatus(Integer userStatus) { * @return userStatus **/ @javax.annotation.Nullable - public Integer getUserStatus() { + public Object getUserStatus() { return userStatus; } - public void setUserStatus(Integer userStatus) { + public void setUserStatus(Object userStatus) { this.userStatus = userStatus; } @@ -319,11 +320,22 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, user.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, username, firstName, lastName, email, password, phone, userStatus, additionalProperties); } + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -385,24 +397,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); - } - if ((jsonObj.get("firstName") != null && !jsonObj.get("firstName").isJsonNull()) && !jsonObj.get("firstName").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `firstName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("firstName").toString())); - } - if ((jsonObj.get("lastName") != null && !jsonObj.get("lastName").isJsonNull()) && !jsonObj.get("lastName").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `lastName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastName").toString())); - } - if ((jsonObj.get("email") != null && !jsonObj.get("email").isJsonNull()) && !jsonObj.get("email").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString())); - } - if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); - } - if ((jsonObj.get("phone") != null && !jsonObj.get("phone").isJsonNull()) && !jsonObj.get("phone").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format("Expected the field `phone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("phone").toString())); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/lua/petstore/model/user.lua b/samples/client/petstore/lua/petstore/model/user.lua index 16f984685718..ae0b97969d14 100644 --- a/samples/client/petstore/lua/petstore/model/user.lua +++ b/samples/client/petstore/lua/petstore/model/user.lua @@ -19,7 +19,7 @@ local function cast_user(t) return setmetatable(t, user_mt) end -local function new_user(id, username, first_name, last_name, email, password, mobile, user_status) +local function new_user(id, username, first_name, last_name, email, password, phone, user_status) return cast_user({ ["id"] = id; ["username"] = username; @@ -27,7 +27,7 @@ local function new_user(id, username, first_name, last_name, email, password, mo ["lastName"] = last_name; ["email"] = email; ["password"] = password; - ["phone"] = mobile; + ["phone"] = phone; ["userStatus"] = user_status; }) end diff --git a/samples/client/petstore/perl/.openapi-generator/FILES b/samples/client/petstore/perl/.openapi-generator/FILES index d6a142a834bb..6eb6311e98c7 100644 --- a/samples/client/petstore/perl/.openapi-generator/FILES +++ b/samples/client/petstore/perl/.openapi-generator/FILES @@ -17,7 +17,7 @@ docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md -docs/DeprecatedModel.md +docs/DeprecatedObject.md docs/Dog.md docs/EnumArrays.md docs/EnumClass.md @@ -79,7 +79,7 @@ lib/WWW/OpenAPIClient/Object/Category.pm lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm lib/WWW/OpenAPIClient/Object/ClassModel.pm lib/WWW/OpenAPIClient/Object/Client.pm -lib/WWW/OpenAPIClient/Object/DeprecatedModel.pm +lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm lib/WWW/OpenAPIClient/Object/Dog.pm lib/WWW/OpenAPIClient/Object/EnumArrays.pm lib/WWW/OpenAPIClient/Object/EnumClass.pm diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index affa55c61941..ca0ebd7ba0ed 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -255,7 +255,7 @@ use WWW::OpenAPIClient::Object::Category; use WWW::OpenAPIClient::Object::ChildWithNullable; use WWW::OpenAPIClient::Object::ClassModel; use WWW::OpenAPIClient::Object::Client; -use WWW::OpenAPIClient::Object::DeprecatedModel; +use WWW::OpenAPIClient::Object::DeprecatedObject; use WWW::OpenAPIClient::Object::Dog; use WWW::OpenAPIClient::Object::EnumArrays; use WWW::OpenAPIClient::Object::EnumClass; @@ -324,7 +324,7 @@ use WWW::OpenAPIClient::Object::Category; use WWW::OpenAPIClient::Object::ChildWithNullable; use WWW::OpenAPIClient::Object::ClassModel; use WWW::OpenAPIClient::Object::Client; -use WWW::OpenAPIClient::Object::DeprecatedModel; +use WWW::OpenAPIClient::Object::DeprecatedObject; use WWW::OpenAPIClient::Object::Dog; use WWW::OpenAPIClient::Object::EnumArrays; use WWW::OpenAPIClient::Object::EnumClass; @@ -445,7 +445,7 @@ Class | Method | HTTP request | Description - [WWW::OpenAPIClient::Object::ChildWithNullable](docs/ChildWithNullable.md) - [WWW::OpenAPIClient::Object::ClassModel](docs/ClassModel.md) - [WWW::OpenAPIClient::Object::Client](docs/Client.md) - - [WWW::OpenAPIClient::Object::DeprecatedModel](docs/DeprecatedModel.md) + - [WWW::OpenAPIClient::Object::DeprecatedObject](docs/DeprecatedObject.md) - [WWW::OpenAPIClient::Object::Dog](docs/Dog.md) - [WWW::OpenAPIClient::Object::EnumArrays](docs/EnumArrays.md) - [WWW::OpenAPIClient::Object::EnumClass](docs/EnumClass.md) diff --git a/samples/client/petstore/perl/docs/DeprecatedObject.md b/samples/client/petstore/perl/docs/DeprecatedObject.md new file mode 100644 index 000000000000..692432fcab15 --- /dev/null +++ b/samples/client/petstore/perl/docs/DeprecatedObject.md @@ -0,0 +1,15 @@ +# WWW::OpenAPIClient::Object::DeprecatedObject + +## Load the model package +```perl +use WWW::OpenAPIClient::Object::DeprecatedObject; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/docs/HealthCheckResult.md b/samples/client/petstore/perl/docs/HealthCheckResult.md index 6f004a50428b..5f0c43d5f3d4 100644 --- a/samples/client/petstore/perl/docs/HealthCheckResult.md +++ b/samples/client/petstore/perl/docs/HealthCheckResult.md @@ -8,7 +8,7 @@ use WWW::OpenAPIClient::Object::HealthCheckResult; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**system_message** | **string** | | [optional] +**nullable_message** | **string** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/perl/docs/ObjectWithDeprecatedFields.md b/samples/client/petstore/perl/docs/ObjectWithDeprecatedFields.md index 8caeb8c34e29..311d746a4159 100644 --- a/samples/client/petstore/perl/docs/ObjectWithDeprecatedFields.md +++ b/samples/client/petstore/perl/docs/ObjectWithDeprecatedFields.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **uuid** | **string** | | [optional] **id** | **double** | | [optional] -**deprecated_ref** | [**DeprecatedModel**](DeprecatedModel.md) | | [optional] +**deprecated_ref** | [**DeprecatedObject**](DeprecatedObject.md) | | [optional] **bars** | **ARRAY[string]** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm new file mode 100644 index 000000000000..590c2782fa1d --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm @@ -0,0 +1,242 @@ +=begin comment + +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 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +package WWW::OpenAPIClient::Object::DeprecatedObject; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + + +use base ("Class::Accessor", "Class::Data::Inheritable"); + +# +# +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. +# REF: https://openapi-generator.tech +# + +=begin comment + +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 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# Do not edit the class manually. +# Ref: https://openapi-generator.tech +# +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('openapi_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new plain object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + $self->init(%args); + + return $self; +} + +# initialize the object +sub init +{ + my ($self, %args) = @_; + + foreach my $attribute (keys %{$self->attribute_map}) { + my $args_key = $self->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } +} + +# return perl hash +sub to_hash { + my $self = shift; + my $_hash = decode_json(JSON->new->convert_blessed->encode($self)); + + return $_hash; +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + my $_json_attribute = $self->attribute_map->{$_key}; + my $_type = $self->openapi_types->{$_key}; + my $_value = $self->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + $_data->{$_json_attribute} = [ map { $self->_to_json_primitives($_subclass, $_) } @$_value ]; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$_value}) { + $_hash{$_key} = $self->_to_json_primitives($_subclass, $_element); + } + $_data->{$_json_attribute} = \%_hash; + } elsif ( grep( /^$_type$/, ('int', 'double', 'string', 'boolean', 'DATE', 'DATE_TIME'))) { + $_data->{$_json_attribute} = $self->_to_json_primitives($_type, $_value); + } else { + $_data->{$_json_attribute} = $_value; + } + } + } + + return $_data; +} + +# to_json non-array data +sub _to_json_primitives { + my ($self, $type, $data) = @_; + if ( grep( /^$type$/, ('int', 'double'))) { + # https://metacpan.org/pod/JSON#simple-scalars + # numify it, ensuring it will be dumped as a number + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + # https://metacpan.org/pod/JSON#simple-scalars + # stringified + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + # https://metacpan.org/pod/JSON#JSON::true,-JSON::false,-JSON::null + return $data ? \1 : \0; + } elsif ($type eq 'DATE') { + return undef unless defined $data; + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Eymd($optional_separator),-$dt-%3Emdy(...),-$dt-%3Edmy(...) + return $data->ymd; + } + return $data .q(); + } elsif ($type eq 'DATE_TIME') { + return undef unless defined $data; + # the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z + if (ref($data) eq 'DateTime') { + # https://metacpan.org/pod/DateTime#$dt-%3Erfc3339 + return $data->rfc3339; + } + return $data .q(); + } else { # hash (model), In this case, the TO_JSON of the $data object is executed + return $data; + } +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use openapi_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->openapi_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[(.+)\]$/i) { # array + my $_subclass = $1; + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash + my $_subclass = $1; + my %_hash = (); + while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) { + $_hash{$_key} = $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \%_hash; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if (grep( /^$type$/ , ('DATE_TIME', 'DATE'))) { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double'))) { + return undef unless defined $data; + return $data + 0; + } elsif ($type eq 'string') { + return undef unless defined $data; + return $data . q(); + } elsif ($type eq 'boolean') { + return !!$data; + } else { # hash(model) + my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + +__PACKAGE__->class_documentation({description => '', + class => 'DeprecatedObject', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'name' => { + datatype => 'string', + base_name => 'name', + description => '', + format => '', + read_only => '', + }, +}); + +__PACKAGE__->openapi_types( { + 'name' => 'string' +} ); + +__PACKAGE__->attribute_map( { + 'name' => 'name' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/HealthCheckResult.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/HealthCheckResult.pm index 000598c457cd..8d95f2044467 100644 --- a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/HealthCheckResult.pm +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/HealthCheckResult.pm @@ -219,7 +219,7 @@ __PACKAGE__->class_documentation({description => 'Just a string to inform instan } ); __PACKAGE__->method_documentation({ - 'system_message' => { + 'nullable_message' => { datatype => 'string', base_name => 'NullableMessage', description => '', @@ -229,11 +229,11 @@ __PACKAGE__->method_documentation({ }); __PACKAGE__->openapi_types( { - 'system_message' => 'string' + 'nullable_message' => 'string' } ); __PACKAGE__->attribute_map( { - 'system_message' => 'NullableMessage' + 'nullable_message' => 'NullableMessage' } ); __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ObjectWithDeprecatedFields.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ObjectWithDeprecatedFields.pm index 61918ae1d1d1..ce18bf6cb6a6 100644 --- a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ObjectWithDeprecatedFields.pm +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ObjectWithDeprecatedFields.pm @@ -30,7 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; -use WWW::OpenAPIClient::Object::DeprecatedModel; +use WWW::OpenAPIClient::Object::DeprecatedObject; use base ("Class::Accessor", "Class::Data::Inheritable"); @@ -235,7 +235,7 @@ __PACKAGE__->method_documentation({ read_only => '', }, 'deprecated_ref' => { - datatype => 'DeprecatedModel', + datatype => 'DeprecatedObject', base_name => 'deprecatedRef', description => '', format => '', @@ -253,7 +253,7 @@ __PACKAGE__->method_documentation({ __PACKAGE__->openapi_types( { 'uuid' => 'string', 'id' => 'double', - 'deprecated_ref' => 'DeprecatedModel', + 'deprecated_ref' => 'DeprecatedObject', 'bars' => 'ARRAY[string]' } ); diff --git a/samples/client/petstore/perl/t/DeprecatedObjectTest.t b/samples/client/petstore/perl/t/DeprecatedObjectTest.t new file mode 100644 index 000000000000..485a695b4bb2 --- /dev/null +++ b/samples/client/petstore/perl/t/DeprecatedObjectTest.t @@ -0,0 +1,34 @@ +=begin comment + +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 + +Generated by: https://openapi-generator.tech + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the OpenAPI Generator +# Please update the test cases below to test the model. +# Ref: https://openapi-generator.tech +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::OpenAPIClient::Object::DeprecatedObject'); + +# uncomment below and update the test +#my $instance = WWW::OpenAPIClient::Object::DeprecatedObject->new(); +# +#isa_ok($instance, 'WWW::OpenAPIClient::Object::DeprecatedObject'); + diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php index 11a3dd4a614a..1dea6bea779e 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ChildWithNullable.php @@ -2,7 +2,7 @@ /** * ChildWithNullable * - * PHP version 8.0 + * PHP version 8.1 * * @category Class * @package OpenAPI\Client diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php index 83f01e1ac7af..e000ef7cf5f0 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/ParentWithNullable.php @@ -2,7 +2,7 @@ /** * ParentWithNullable * - * PHP version 8.0 + * PHP version 8.1 * * @category Class * @package OpenAPI\Client diff --git a/samples/client/petstore/powershell/.openapi-generator/FILES b/samples/client/petstore/powershell/.openapi-generator/FILES index 7e8383cf879a..92a65ac907d5 100644 --- a/samples/client/petstore/powershell/.openapi-generator/FILES +++ b/samples/client/petstore/powershell/.openapi-generator/FILES @@ -130,9 +130,9 @@ src/PSPetstore/Model/Mammal.ps1 src/PSPetstore/Model/MapTest.ps1 src/PSPetstore/Model/MixedPropertiesAndAdditionalPropertiesClass.ps1 src/PSPetstore/Model/Model200Response.ps1 +src/PSPetstore/Model/ModelMapping.ps1 src/PSPetstore/Model/ModelReturn.ps1 src/PSPetstore/Model/Name.ps1 -src/PSPetstore/Model/NewModel.ps1 src/PSPetstore/Model/NullableClass.ps1 src/PSPetstore/Model/NullableShape.ps1 src/PSPetstore/Model/NumberOnly.ps1 diff --git a/samples/client/petstore/powershell/README.md b/samples/client/petstore/powershell/README.md index 30b0f1454eeb..85badaa315fb 100644 --- a/samples/client/petstore/powershell/README.md +++ b/samples/client/petstore/powershell/README.md @@ -139,9 +139,9 @@ Class | Method | HTTP request | Description - [PSPetstore\Model.MapTest](docs/MapTest.md) - [PSPetstore\Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [PSPetstore\Model.Model200Response](docs/Model200Response.md) + - [PSPetstore\Model.ModelMapping](docs/ModelMapping.md) - [PSPetstore\Model.ModelReturn](docs/ModelReturn.md) - [PSPetstore\Model.Name](docs/Name.md) - - [PSPetstore\Model.NewModel](docs/NewModel.md) - [PSPetstore\Model.NullableClass](docs/NullableClass.md) - [PSPetstore\Model.NullableShape](docs/NullableShape.md) - [PSPetstore\Model.NumberOnly](docs/NumberOnly.md) diff --git a/samples/client/petstore/powershell/docs/ModelMapping.md b/samples/client/petstore/powershell/docs/ModelMapping.md index 399b227c2aeb..0e23f1563869 100644 --- a/samples/client/petstore/powershell/docs/ModelMapping.md +++ b/samples/client/petstore/powershell/docs/ModelMapping.md @@ -1,4 +1,4 @@ -# NewModel +# ModelMapping ## Properties Name | Type | Description | Notes @@ -9,12 +9,12 @@ Name | Type | Description | Notes - Prepare the resource ```powershell -$NewModel = Initialize-PSPetstoreNewModel -Name null +$ModelMapping = Initialize-PSPetstoreModelMapping -Name null ``` - Convert the resource to JSON ```powershell -$NewModel | ConvertTo-JSON +$ModelMapping | ConvertTo-JSON ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/powershell/docs/ObjectWithDeprecatedFields.md b/samples/client/petstore/powershell/docs/ObjectWithDeprecatedFields.md index d9a9570fa6f4..fe8f3853fd17 100644 --- a/samples/client/petstore/powershell/docs/ObjectWithDeprecatedFields.md +++ b/samples/client/petstore/powershell/docs/ObjectWithDeprecatedFields.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **Id** | **Decimal** | | [optional] **DeprecatedRef** | [**DeprecatedObject**](DeprecatedObject.md) | | [optional] **Bars** | **String[]** | | [optional] -**SomethingElse** | **String** | | [optional] +**NameMapping** | **String** | | [optional] ## Examples @@ -17,7 +17,7 @@ $ObjectWithDeprecatedFields = Initialize-PSPetstoreObjectWithDeprecatedFields - -Id null ` -DeprecatedRef null ` -Bars null ` - -SomethingElse null + -NameMapping null ``` - Convert the resource to JSON diff --git a/samples/client/petstore/powershell/src/PSPetstore/Model/ModelMapping.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Model/ModelMapping.ps1 new file mode 100644 index 000000000000..5ec4e8b92f18 --- /dev/null +++ b/samples/client/petstore/powershell/src/PSPetstore/Model/ModelMapping.ps1 @@ -0,0 +1,97 @@ +# +# 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: "" \ +# Version: 1.0.0 +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +<# +.SYNOPSIS + +No summary available. + +.DESCRIPTION + +No description available. + +.PARAMETER Name +No description available. +.OUTPUTS + +ModelMapping +#> + +function Initialize-PSModelMapping { + [CmdletBinding()] + Param ( + [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] + [String] + ${Name} + ) + + Process { + 'Creating PSCustomObject: PSPetstore => PSModelMapping' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + + $PSO = [PSCustomObject]@{ + "name" = ${Name} + } + + + return $PSO + } +} + +<# +.SYNOPSIS + +Convert from JSON to ModelMapping + +.DESCRIPTION + +Convert from JSON to ModelMapping + +.PARAMETER Json + +Json object + +.OUTPUTS + +ModelMapping +#> +function ConvertFrom-PSJsonToModelMapping { + Param( + [AllowEmptyString()] + [string]$Json + ) + + Process { + 'Converting JSON to PSCustomObject: PSPetstore => PSModelMapping' | Write-Debug + $PSBoundParameters | Out-DebugParameter | Write-Debug + + $JsonParameters = ConvertFrom-Json -InputObject $Json + + # check if Json contains properties not defined in PSModelMapping + $AllProperties = ("name") + foreach ($name in $JsonParameters.PsObject.Properties.Name) { + if (!($AllProperties.Contains($name))) { + throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + } + } + + if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) { #optional property not found + $Name = $null + } else { + $Name = $JsonParameters.PSobject.Properties["name"].value + } + + $PSO = [PSCustomObject]@{ + "name" = ${Name} + } + + return $PSO + } + +} + diff --git a/samples/client/petstore/powershell/src/PSPetstore/Model/ObjectWithDeprecatedFields.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Model/ObjectWithDeprecatedFields.ps1 index 0651b4e55daf..743e7e5a37be 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Model/ObjectWithDeprecatedFields.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Model/ObjectWithDeprecatedFields.ps1 @@ -22,7 +22,7 @@ No description available. No description available. .PARAMETER Bars No description available. -.PARAMETER SomethingElse +.PARAMETER NameMapping No description available. .OUTPUTS @@ -46,7 +46,7 @@ function Initialize-PSObjectWithDeprecatedFields { ${Bars}, [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)] [String] - ${SomethingElse} + ${NameMapping} ) Process { @@ -59,7 +59,7 @@ function Initialize-PSObjectWithDeprecatedFields { "id" = ${Id} "deprecatedRef" = ${DeprecatedRef} "bars" = ${Bars} - "name_mapping" = ${SomethingElse} + "name_mapping" = ${NameMapping} } @@ -129,9 +129,9 @@ function ConvertFrom-PSJsonToObjectWithDeprecatedFields { } if (!([bool]($JsonParameters.PSobject.Properties.name -match "name_mapping"))) { #optional property not found - $SomethingElse = $null + $NameMapping = $null } else { - $SomethingElse = $JsonParameters.PSobject.Properties["name_mapping"].value + $NameMapping = $JsonParameters.PSobject.Properties["name_mapping"].value } $PSO = [PSCustomObject]@{ @@ -139,7 +139,7 @@ function ConvertFrom-PSJsonToObjectWithDeprecatedFields { "id" = ${Id} "deprecatedRef" = ${DeprecatedRef} "bars" = ${Bars} - "name_mapping" = ${SomethingElse} + "name_mapping" = ${NameMapping} } return $PSO diff --git a/samples/client/petstore/powershell/tests/Model/ModelMapping.Tests.ps1 b/samples/client/petstore/powershell/tests/Model/ModelMapping.Tests.ps1 new file mode 100644 index 000000000000..c6c051a88bd3 --- /dev/null +++ b/samples/client/petstore/powershell/tests/Model/ModelMapping.Tests.ps1 @@ -0,0 +1,17 @@ +# +# 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: "" \ +# Version: 1.0.0 +# Generated by OpenAPI Generator: https://openapi-generator.tech +# + +Describe -tag 'PSPetstore' -name 'PSModelMapping' { + Context 'PSModelMapping' { + It 'Initialize-PSModelMapping' { + # a simple test to create an object + #$NewObject = Initialize-PSModelMapping -Name "TEST_VALUE" + #$NewObject | Should -BeOfType ModelMapping + #$NewObject.property | Should -Be 0 + } + } +} diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java index 190a9033d2d8..dc42ffccaf90 100644 --- a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -50,12 +50,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java index f02a9851d667..9b071569af21 100644 --- a/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -70,7 +70,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java index 8c3fa92f59a4..2a21344c37b7 100644 --- a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ChildWithNullableDto.java @@ -52,12 +52,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullableDto type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullableDto nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java index 85c1e88f3cc8..ee8d6b570d0c 100644 --- a/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java +++ b/samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/model/ParentWithNullableDto.java @@ -71,7 +71,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullableDto type(TypeEnum type) { this.type = type; diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py index 140dcf434609..6b7ed5dde57e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py @@ -19,7 +19,6 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable -from typing_extensions import Annotated from pydantic import Field from petstore_api.models.client import Client diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py index 3c0ef29b788f..eb966cc1286d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py @@ -19,7 +19,6 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable -from typing_extensions import Annotated from datetime import date, datetime from pydantic import Field, StrictBool, StrictBytes, StrictInt, StrictStr, conbytes, confloat, conint, conlist, constr, validator diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py index 6b9c88c1212f..c96013003e5b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py @@ -19,7 +19,6 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable -from typing_extensions import Annotated from pydantic import Field from petstore_api.models.client import Client diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py index 72e29e7d0429..f9a43cba02a3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py @@ -19,7 +19,6 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable -from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictInt, StrictStr, conlist, validator from typing import List, Optional, Union diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py index e52b31ee5e13..7c8220e8ae08 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py @@ -19,7 +19,6 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable -from typing_extensions import Annotated from pydantic import Field, StrictStr, conint from typing import Dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index 3c059d73339f..3236bfd06ce4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -19,7 +19,6 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable -from typing_extensions import Annotated from pydantic import Field, StrictStr, conlist from petstore_api.models.user import User diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py index c8ae8d0af133..fd4cd25f4cab 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py @@ -18,7 +18,6 @@ from pydantic import validate_arguments, ValidationError -from typing_extensions import Annotated from pydantic import Field from petstore_api.models.client import Client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 1bdbf4e06a91..73f759675320 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -18,7 +18,6 @@ from pydantic import validate_arguments, ValidationError -from typing_extensions import Annotated from datetime import date, datetime from pydantic import Field, StrictBool, StrictBytes, StrictFloat, StrictInt, StrictStr, conbytes, confloat, conint, conlist, constr, validator diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py index acfe8c01a94f..ddbfc8fc082d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py @@ -18,7 +18,6 @@ from pydantic import validate_arguments, ValidationError -from typing_extensions import Annotated from pydantic import Field from petstore_api.models.client import Client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py index f0eefd7ec890..8799ae2cb27f 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py @@ -18,7 +18,6 @@ from pydantic import validate_arguments, ValidationError -from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictInt, StrictStr, conlist, validator from typing import List, Optional, Union diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index b5b845531fe6..ace73770b75a 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -18,7 +18,6 @@ from pydantic import validate_arguments, ValidationError -from typing_extensions import Annotated from pydantic import Field, StrictStr, conint from typing import Dict diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index 240a692ebcad..7738ee78a689 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -18,7 +18,6 @@ from pydantic import validate_arguments, ValidationError -from typing_extensions import Annotated from pydantic import Field, StrictStr, conlist from petstore_api.models.user import User diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java index c3cca4b9a770..fb169e0b74a8 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -53,12 +53,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java index c1d7117e7f6c..7ddb5ac9fb72 100644 --- a/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -72,7 +72,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java index c3cca4b9a770..fb169e0b74a8 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -53,12 +53,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java index c1d7117e7f6c..7ddb5ac9fb72 100644 --- a/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -72,7 +72,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java index c3cca4b9a770..fb169e0b74a8 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -53,12 +53,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java index c1d7117e7f6c..7ddb5ac9fb72 100644 --- a/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/openapi3/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -72,7 +72,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java index 0f7d2a1f6f64..07dcef91798a 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java @@ -91,7 +91,6 @@ public static StatusEnum fromValue(String value) { } @JacksonXmlProperty(localName = "status") - @Deprecated private StatusEnum status; public Pet() { @@ -230,20 +229,14 @@ public Pet status(StatusEnum status) { /** * pet status in the store * @return status - * @deprecated */ - @Schema(name = "status", description = "pet status in the store", deprecated = true, requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "status", description = "pet status in the store", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty("status") - @Deprecated public StatusEnum getStatus() { return status; } - /** - * @deprecated - */ - @Deprecated public void setStatus(StatusEnum status) { this.status = status; } diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java index c3cca4b9a770..fb169e0b74a8 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -53,12 +53,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java index c1d7117e7f6c..7ddb5ac9fb72 100644 --- a/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/spring-boot-defaultInterface-unhandledException/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -72,7 +72,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java index 68c0c1261cce..3ce936a5302f 100644 --- a/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-beanvalidation-no-nullable/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -51,12 +51,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java index 5a7df76b879b..49094e267a20 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -54,12 +54,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java index 359a889813fc..88477c887c25 100644 --- a/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-beanvalidation/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -73,7 +73,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java index 5a7df76b879b..49094e267a20 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -54,12 +54,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java index 359a889813fc..88477c887c25 100644 --- a/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-delegate-j8/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -73,7 +73,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java index 5a7df76b879b..49094e267a20 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -54,12 +54,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java index 359a889813fc..88477c887c25 100644 --- a/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-delegate/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -73,7 +73,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java index 5a7df76b879b..49094e267a20 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -54,12 +54,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java index 359a889813fc..88477c887c25 100644 --- a/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-implicitHeaders/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -73,7 +73,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java index 5a7df76b879b..49094e267a20 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -54,12 +54,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java index 359a889813fc..88477c887c25 100644 --- a/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-reactive-noResponseEntity/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -73,7 +73,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java index 5a7df76b879b..49094e267a20 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -54,12 +54,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java index 359a889813fc..88477c887c25 100644 --- a/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -73,7 +73,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java index 5a7df76b879b..49094e267a20 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ChildWithNullable.java @@ -54,12 +54,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java index 359a889813fc..88477c887c25 100644 --- a/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-useoptional/src/main/java/org/openapitools/model/ParentWithNullable.java @@ -73,7 +73,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java index 5da8631d7b07..040cd5c6afeb 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ChildWithNullable.java @@ -53,12 +53,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullable type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullable nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java index e38b43c30ea7..3ef9d3cff29b 100644 --- a/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java +++ b/samples/server/petstore/springboot-virtualan/src/main/java/org/openapitools/virtualan/model/ParentWithNullable.java @@ -72,7 +72,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullable type(TypeEnum type) { this.type = type; diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java index 32f4b016fa0e..d954f1970942 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ChildWithNullableDto.java @@ -56,12 +56,12 @@ public void setOtherProperty(String otherProperty) { public ChildWithNullableDto type(TypeEnum type) { - super.setType(type); + super.type(type); return this; } public ChildWithNullableDto nullableProperty(String nullableProperty) { - super.setNullableProperty(nullableProperty); + super.nullableProperty(nullableProperty); return this; } @Override diff --git a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java index a06f9c5272c5..5a76b286e6b0 100644 --- a/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java +++ b/samples/server/petstore/springboot/src/main/java/org/openapitools/model/ParentWithNullableDto.java @@ -74,7 +74,7 @@ public static TypeEnum fromValue(String value) { private TypeEnum type; - private JsonNullable nullableProperty = JsonNullable.undefined(); + private JsonNullable nullableProperty = JsonNullable.undefined(); public ParentWithNullableDto type(TypeEnum type) { this.type = type; From 6ea1b5ec3df22e2cf8dc3fc6ea69494e1f663ccc Mon Sep 17 00:00:00 2001 From: Martin <2026226+martin-mfg@users.noreply.github.com> Date: Mon, 11 Sep 2023 08:11:55 +0200 Subject: [PATCH 7/7] re-build from new sources, generates samples again --- .../python/openapi_client/api/body_api.py | 1 + .../UseSourceGeneration/Api/AnotherFakeApi.cs | 5 +- .../src/UseSourceGeneration/Api/DefaultApi.cs | 8 +- .../src/UseSourceGeneration/Api/FakeApi.cs | 11 +- .../Api/FakeClassnameTags123Api.cs | 5 +- .../src/UseSourceGeneration/Api/PetApi.cs | 8 +- .../src/UseSourceGeneration/Api/StoreApi.cs | 5 +- .../src/UseSourceGeneration/Api/UserApi.cs | 5 +- .../okhttp-gson-3.1/.openapi-generator/FILES | 8 + .../petstore/java/okhttp-gson-3.1/README.md | 4 + .../java/okhttp-gson-3.1/api/openapi.yaml | 174 +++++++++++++----- .../java/okhttp-gson-3.1/docs/Animal.md | 4 +- .../java/okhttp-gson-3.1/docs/Category.md | 4 +- .../okhttp-gson-3.1/docs/ModelApiResponse.md | 6 +- .../java/okhttp-gson-3.1/docs/Order.md | 10 +- .../petstore/java/okhttp-gson-3.1/docs/Pet.md | 8 +- .../java/okhttp-gson-3.1/docs/PetApi.md | 56 +++--- .../java/okhttp-gson-3.1/docs/StoreApi.md | 14 +- .../petstore/java/okhttp-gson-3.1/docs/Tag.md | 4 +- .../java/okhttp-gson-3.1/docs/User.md | 16 +- .../java/okhttp-gson-3.1/docs/UserApi.md | 42 ++--- .../java/org/openapitools/client/JSON.java | 25 ++- .../org/openapitools/client/api/PetApi.java | 85 ++++----- .../org/openapitools/client/api/StoreApi.java | 36 ++-- .../org/openapitools/client/api/UserApi.java | 119 ++++++------ .../org/openapitools/client/model/Animal.java | 111 ++--------- .../openapitools/client/model/Category.java | 31 ++-- .../client/model/ModelApiResponse.java | 42 ++--- .../org/openapitools/client/model/Order.java | 70 ++++--- .../org/openapitools/client/model/Pet.java | 107 +++++++---- .../org/openapitools/client/model/Tag.java | 31 ++-- .../org/openapitools/client/model/User.java | 94 +++++----- .../petstore/lua/petstore/model/user.lua | 4 +- .../petstore/perl/.openapi-generator/FILES | 4 +- samples/client/petstore/perl/README.md | 6 +- .../petstore/perl/docs/HealthCheckResult.md | 2 +- .../perl/docs/ObjectWithDeprecatedFields.md | 2 +- .../OpenAPIClient/Object/HealthCheckResult.pm | 6 +- .../Object/ObjectWithDeprecatedFields.pm | 6 +- .../powershell/.openapi-generator/FILES | 2 +- samples/client/petstore/powershell/README.md | 2 +- .../petstore/powershell/docs/ModelMapping.md | 6 +- .../docs/ObjectWithDeprecatedFields.md | 4 +- .../Model/ObjectWithDeprecatedFields.ps1 | 12 +- .../petstore_api/api/another_fake_api.py | 1 + .../petstore_api/api/fake_api.py | 1 + .../api/fake_classname_tags123_api.py | 1 + .../petstore_api/api/pet_api.py | 1 + .../petstore_api/api/store_api.py | 1 + .../petstore_api/api/user_api.py | 1 + .../petstore_api/api/another_fake_api.py | 1 + .../python/petstore_api/api/fake_api.py | 1 + .../api/fake_classname_tags123_api.py | 1 + .../python/petstore_api/api/pet_api.py | 1 + .../python/petstore_api/api/store_api.py | 1 + .../python/petstore_api/api/user_api.py | 1 + .../main/java/org/openapitools/model/Pet.java | 9 +- 57 files changed, 663 insertions(+), 563 deletions(-) diff --git a/samples/client/echo_api/python/openapi_client/api/body_api.py b/samples/client/echo_api/python/openapi_client/api/body_api.py index a51f6c55926d..553feae23a3c 100644 --- a/samples/client/echo_api/python/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python/openapi_client/api/body_api.py @@ -19,6 +19,7 @@ from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictStr, conlist from typing import Any, Dict, Optional, Union diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs index 64ca5ea4ef5c..cf6063040ffd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/AnotherFakeApi.cs @@ -92,6 +92,7 @@ internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception) public sealed partial class AnotherFakeApi : IAnotherFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private ModelClientDeserializationContext _modelClientDeserializationContext; /// /// The logger @@ -137,7 +138,8 @@ public sealed partial class AnotherFakeApi : IAnotherFakeApi /// Initializes a new instance of the class. /// /// - public AnotherFakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,, + public AnotherFakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents, + ModelClientDeserializationContext modelClientDeserializationContext, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -145,6 +147,7 @@ public AnotherFakeApi(ILogger logger, HttpClient httpClient, Jso TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + _modelClientDeserializationContext = modelClientDeserializationContext; Logger = logger; HttpClient = httpClient; Events = anotherFakeApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs index b93d77a886f2..6a7814a941d5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/DefaultApi.cs @@ -256,6 +256,8 @@ internal void ExecuteOnErrorTest(Exception exception) public sealed partial class DefaultApi : IDefaultApi { private JsonSerializerOptions _jsonSerializerOptions; + private FooGetDefaultResponseDeserializationContext _fooGetDefaultResponseDeserializationContext; + private NotificationtestGetElementsV1ResponseMPayloadDeserializationContext _notificationtestGetElementsV1ResponseMPayloadDeserializationContext; /// /// The logger @@ -301,7 +303,9 @@ public sealed partial class DefaultApi : IDefaultApi /// Initializes a new instance of the class. /// /// - public DefaultApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,, + public DefaultApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents, + FooGetDefaultResponseDeserializationContext fooGetDefaultResponseDeserializationContext, + NotificationtestGetElementsV1ResponseMPayloadDeserializationContext notificationtestGetElementsV1ResponseMPayloadDeserializationContext, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -309,6 +313,8 @@ public DefaultApi(ILogger logger, HttpClient httpClient, JsonSeriali TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + _fooGetDefaultResponseDeserializationContext = fooGetDefaultResponseDeserializationContext; + _notificationtestGetElementsV1ResponseMPayloadDeserializationContext = notificationtestGetElementsV1ResponseMPayloadDeserializationContext; Logger = logger; HttpClient = httpClient; Events = defaultApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs index 2ce166830a07..0e32bae17000 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeApi.cs @@ -762,6 +762,9 @@ internal void ExecuteOnErrorTestQueryParameterCollectionFormat(Exception excepti public sealed partial class FakeApi : IFakeApi { private JsonSerializerOptions _jsonSerializerOptions; + private HealthCheckResultDeserializationContext _healthCheckResultDeserializationContext; + private OuterCompositeDeserializationContext _outerCompositeDeserializationContext; + private ModelClientDeserializationContext _modelClientDeserializationContext; /// /// The logger @@ -807,7 +810,10 @@ public sealed partial class FakeApi : IFakeApi /// Initializes a new instance of the class. /// /// - public FakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeApiEvents fakeApiEvents,, + public FakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeApiEvents fakeApiEvents, + HealthCheckResultDeserializationContext healthCheckResultDeserializationContext, + OuterCompositeDeserializationContext outerCompositeDeserializationContext, + ModelClientDeserializationContext modelClientDeserializationContext, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -815,6 +821,9 @@ public FakeApi(ILogger logger, HttpClient httpClient, JsonSerializerOpt TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + _healthCheckResultDeserializationContext = healthCheckResultDeserializationContext; + _outerCompositeDeserializationContext = outerCompositeDeserializationContext; + _modelClientDeserializationContext = modelClientDeserializationContext; Logger = logger; HttpClient = httpClient; Events = fakeApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs index 9a1713d2cbf2..43825e1856ba 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/FakeClassnameTags123Api.cs @@ -92,6 +92,7 @@ internal void ExecuteOnErrorTestClassname(Exception exception) public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api { private JsonSerializerOptions _jsonSerializerOptions; + private ModelClientDeserializationContext _modelClientDeserializationContext; /// /// The logger @@ -137,7 +138,8 @@ public sealed partial class FakeClassnameTags123Api : IFakeClassnameTags123Api /// Initializes a new instance of the class. /// /// - public FakeClassnameTags123Api(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,, + public FakeClassnameTags123Api(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents, + ModelClientDeserializationContext modelClientDeserializationContext, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -145,6 +147,7 @@ public FakeClassnameTags123Api(ILogger logger, HttpClie TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + _modelClientDeserializationContext = modelClientDeserializationContext; Logger = logger; HttpClient = httpClient; Events = fakeClassnameTags123ApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs index 83e0bf27e908..6ce306fc7db7 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/PetApi.cs @@ -450,6 +450,8 @@ internal void ExecuteOnErrorUploadFileWithRequiredFile(Exception exception) public sealed partial class PetApi : IPetApi { private JsonSerializerOptions _jsonSerializerOptions; + private PetDeserializationContext _petDeserializationContext; + private ApiResponseDeserializationContext _apiResponseDeserializationContext; /// /// The logger @@ -495,7 +497,9 @@ public sealed partial class PetApi : IPetApi /// Initializes a new instance of the class. /// /// - public PetApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, PetApiEvents petApiEvents,, + public PetApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, PetApiEvents petApiEvents, + PetDeserializationContext petDeserializationContext, + ApiResponseDeserializationContext apiResponseDeserializationContext, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -503,6 +507,8 @@ public PetApi(ILogger logger, HttpClient httpClient, JsonSerializerOptio TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + _petDeserializationContext = petDeserializationContext; + _apiResponseDeserializationContext = apiResponseDeserializationContext; Logger = logger; HttpClient = httpClient; Events = petApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs index e3881d4c1443..78c789c85b7b 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/StoreApi.cs @@ -219,6 +219,7 @@ internal void ExecuteOnErrorPlaceOrder(Exception exception) public sealed partial class StoreApi : IStoreApi { private JsonSerializerOptions _jsonSerializerOptions; + private OrderDeserializationContext _orderDeserializationContext; /// /// The logger @@ -264,7 +265,8 @@ public sealed partial class StoreApi : IStoreApi /// Initializes a new instance of the class. /// /// - public StoreApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,, + public StoreApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents, + OrderDeserializationContext orderDeserializationContext, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -272,6 +274,7 @@ public StoreApi(ILogger logger, HttpClient httpClient, JsonSerializerO TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + _orderDeserializationContext = orderDeserializationContext; Logger = logger; HttpClient = httpClient; Events = storeApiEvents; diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs index 7f538c1d4e82..48f91095f805 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Api/UserApi.cs @@ -395,6 +395,7 @@ internal void ExecuteOnErrorUpdateUser(Exception exception) public sealed partial class UserApi : IUserApi { private JsonSerializerOptions _jsonSerializerOptions; + private UserDeserializationContext _userDeserializationContext; /// /// The logger @@ -440,7 +441,8 @@ public sealed partial class UserApi : IUserApi /// Initializes a new instance of the class. /// /// - public UserApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, UserApiEvents userApiEvents,, + public UserApi(ILogger logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, UserApiEvents userApiEvents, + UserDeserializationContext userDeserializationContext, TokenProvider apiKeyProvider, TokenProvider bearerTokenProvider, TokenProvider basicTokenProvider, @@ -448,6 +450,7 @@ public UserApi(ILogger logger, HttpClient httpClient, JsonSerializerOpt TokenProvider oauthTokenProvider) { _jsonSerializerOptions = jsonSerializerOptionsProvider.Options; + _userDeserializationContext = userDeserializationContext; Logger = logger; HttpClient = httpClient; Events = userApiEvents; diff --git a/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES b/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES index 3194f879514d..af9fa6831fb6 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES +++ b/samples/client/petstore/java/okhttp-gson-3.1/.openapi-generator/FILES @@ -6,12 +6,16 @@ api/openapi.yaml build.gradle build.sbt docs/Animal.md +docs/Cat.md docs/Category.md +docs/Dog.md docs/ModelApiResponse.md +docs/OneOfStringOrInt.md docs/Order.md docs/Pet.md docs/PetApi.md docs/StoreApi.md +docs/StringOrInt.md docs/Tag.md docs/User.md docs/UserApi.md @@ -50,9 +54,13 @@ src/main/java/org/openapitools/client/auth/OAuthOkHttpClient.java src/main/java/org/openapitools/client/auth/RetryingOAuth.java src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java src/main/java/org/openapitools/client/model/Animal.java +src/main/java/org/openapitools/client/model/Cat.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/Dog.java src/main/java/org/openapitools/client/model/ModelApiResponse.java +src/main/java/org/openapitools/client/model/OneOfStringOrInt.java src/main/java/org/openapitools/client/model/Order.java src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/StringOrInt.java src/main/java/org/openapitools/client/model/Tag.java src/main/java/org/openapitools/client/model/User.java diff --git a/samples/client/petstore/java/okhttp-gson-3.1/README.md b/samples/client/petstore/java/okhttp-gson-3.1/README.md index c8fe00e38d9e..4d1472eaa92a 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/README.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/README.md @@ -143,10 +143,14 @@ Class | Method | HTTP request | Description ## Documentation for Models - [Animal](docs/Animal.md) + - [Cat](docs/Cat.md) - [Category](docs/Category.md) + - [Dog](docs/Dog.md) - [ModelApiResponse](docs/ModelApiResponse.md) + - [OneOfStringOrInt](docs/OneOfStringOrInt.md) - [Order](docs/Order.md) - [Pet](docs/Pet.md) + - [StringOrInt](docs/StringOrInt.md) - [Tag](docs/Tag.md) - [User](docs/User.md) diff --git a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml index f4593d8fca20..bc23e2bb6c6c 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml +++ b/samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml @@ -98,6 +98,8 @@ paths: - available - pending - sold + type: string + type: array style: form responses: "200": @@ -106,10 +108,12 @@ paths: schema: items: $ref: '#/components/schemas/Pet' + type: array application/json: schema: items: $ref: '#/components/schemas/Pet' + type: array description: successful operation "400": description: Invalid status value @@ -133,7 +137,9 @@ paths: name: tags required: true schema: - items: {} + items: + type: string + type: array style: form responses: "200": @@ -142,10 +148,12 @@ paths: schema: items: $ref: '#/components/schemas/Pet' + type: array application/json: schema: items: $ref: '#/components/schemas/Pet' + type: array description: successful operation "400": description: Invalid tag value @@ -165,7 +173,8 @@ paths: in: header name: api_key required: false - schema: {} + schema: + type: string style: simple - description: Pet id to delete explode: false @@ -174,6 +183,7 @@ paths: required: true schema: format: int64 + type: integer style: simple responses: "400": @@ -197,6 +207,7 @@ paths: required: true schema: format: int64 + type: integer style: simple responses: "200": @@ -229,6 +240,7 @@ paths: required: true schema: format: int64 + type: integer style: simple requestBody: content: @@ -259,6 +271,7 @@ paths: required: true schema: format: int64 + type: integer style: simple requestBody: content: @@ -292,6 +305,7 @@ paths: schema: additionalProperties: format: int32 + type: integer description: successful operation security: - api_key: [] @@ -338,7 +352,8 @@ paths: in: path name: orderId required: true - schema: {} + schema: + type: string style: simple responses: "400": @@ -363,6 +378,7 @@ paths: format: int64 maximum: 5 minimum: 1 + type: integer style: simple responses: "200": @@ -447,21 +463,25 @@ paths: required: true schema: pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string style: form - description: The password for login in clear text explode: true in: query name: password required: true - schema: {} + schema: + type: string style: form responses: "200": content: application/xml: - schema: {} + schema: + type: string application/json: - schema: {} + schema: + type: string description: successful operation headers: Set-Cookie: @@ -470,18 +490,21 @@ paths: explode: false schema: example: AUTH_KEY=abcde12345; Path=/; HttpOnly + type: string style: simple X-Rate-Limit: description: calls per hour allowed by the user explode: false schema: format: int32 + type: integer style: simple X-Expires-After: description: date in UTC when token expires explode: false schema: format: date-time + type: string style: simple "400": description: Invalid username/password supplied @@ -512,7 +535,8 @@ paths: in: path name: username required: true - schema: {} + schema: + type: string style: simple responses: "400": @@ -534,7 +558,8 @@ paths: in: path name: username required: true - schema: {} + schema: + type: string style: simple responses: "200": @@ -563,7 +588,8 @@ paths: in: path name: username required: true - schema: {} + schema: + type: string style: simple requestBody: content: @@ -592,6 +618,7 @@ components: schema: items: $ref: '#/components/schemas/User' + type: array description: List of user object required: true Pet: @@ -608,106 +635,138 @@ components: Order: description: An order for a pets from the pet store example: - petId: "" - quantity: "" - id: "" - shipDate: "" - complete: "" - status: "" + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed properties: id: format: int64 + type: integer petId: format: int64 + type: integer quantity: format: int32 + type: integer shipDate: format: date-time + type: string status: description: Order Status enum: - placed - approved - delivered + type: string complete: default: false + type: boolean title: Pet Order xml: name: Order Category: description: A category for a pet example: - name: "" - id: "" + name: name + id: 6 properties: id: format: int64 + type: integer name: pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$" + type: string title: Pet category xml: name: Category User: description: A User who is purchasing from the pet store example: - firstName: "" - lastName: "" - password: "" - userStatus: "" - phone: "" - id: "" - email: "" - username: "" + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username properties: id: format: int64 - username: {} - firstName: {} - lastName: {} - email: {} - password: {} - phone: {} + type: integer + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string userStatus: description: User Status format: int32 + type: integer title: a User xml: name: User Tag: description: A tag for a pet + example: + name: name + id: 1 properties: id: format: int64 - name: {} + type: integer + name: + type: string title: Pet Tag xml: name: Tag Pet: description: A pet for sale in the pet store example: - photoUrls: "" + photoUrls: + - photoUrls + - photoUrls name: doggie - id: "" + id: 0 category: - name: "" - id: "" - tags: "" - status: "" + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available properties: id: format: int64 + type: integer category: $ref: '#/components/schemas/Category' name: example: doggie + type: string photoUrls: - items: {} + items: + type: string + type: array xml: name: photoUrl wrapped: true tags: items: $ref: '#/components/schemas/Tag' + type: array xml: name: tag wrapped: true @@ -718,6 +777,7 @@ components: - available - pending - sold + type: string required: - name - photoUrls @@ -727,53 +787,69 @@ components: ApiResponse: description: Describes the result of uploading an image resource example: - code: "" - type: "" - message: "" + code: 0 + type: type + message: message properties: code: format: int32 - type: {} - message: {} + type: integer + type: + type: string + message: + type: string title: An uploaded response StringOrInt: + anyOf: + - type: string + - format: int32 + type: integer description: string or int OneOfStringOrInt: description: string or int (onefOf) - nullable: true - oneOf: [] + oneOf: + - type: string + - type: integer Dog: allOf: - $ref: '#/components/schemas/Animal' - properties: - breed: {} + breed: + type: string Cat: allOf: - $ref: '#/components/schemas/Animal' - properties: - declawed: {} + declawed: + type: boolean Animal: discriminator: propertyName: className properties: - className: {} + className: + type: string color: default: red + type: string required: - className updatePetWithForm_request: properties: name: description: Updated name of the pet + type: string status: description: Updated status of the pet + type: string uploadFile_request: properties: additionalMetadata: description: Additional data to pass to server + type: string file: description: file to upload format: binary + type: string securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Animal.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Animal.md index 79206dd6e28c..d9b32f14c88a 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Animal.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Animal.md @@ -7,8 +7,8 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**className** | **Object** | | | -|**color** | **Object** | | [optional] | +|**className** | **String** | | | +|**color** | **String** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Category.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Category.md index 1a3cbfcc5e38..a7fc939d252e 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Category.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Category.md @@ -8,8 +8,8 @@ A category for a pet | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Object** | | [optional] | -|**name** | **Object** | | [optional] | +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/ModelApiResponse.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/ModelApiResponse.md index d476e3a42aab..cd7e3c400be6 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/ModelApiResponse.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/ModelApiResponse.md @@ -8,9 +8,9 @@ Describes the result of uploading an image resource | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**code** | **Object** | | [optional] | -|**type** | **Object** | | [optional] | -|**message** | **Object** | | [optional] | +|**code** | **Integer** | | [optional] | +|**type** | **String** | | [optional] | +|**message** | **String** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Order.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Order.md index 2d80a0d37fb8..0c33059b8b6a 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Order.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Order.md @@ -8,12 +8,12 @@ An order for a pets from the pet store | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Object** | | [optional] | -|**petId** | **Object** | | [optional] | -|**quantity** | **Object** | | [optional] | -|**shipDate** | **Object** | | [optional] | +|**id** | **Long** | | [optional] | +|**petId** | **Long** | | [optional] | +|**quantity** | **Integer** | | [optional] | +|**shipDate** | **OffsetDateTime** | | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional] | -|**complete** | **Object** | | [optional] | +|**complete** | **Boolean** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Pet.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Pet.md index b69b3b537404..8bb363301232 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Pet.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Pet.md @@ -8,11 +8,11 @@ A pet for sale in the pet store | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Object** | | [optional] | +|**id** | **Long** | | [optional] | |**category** | [**Category**](Category.md) | | [optional] | -|**name** | **Object** | | | -|**photoUrls** | **Object** | | | -|**tags** | **Object** | | [optional] | +|**name** | **String** | | | +|**photoUrls** | **List<String>** | | | +|**tags** | [**List<Tag>**](Tag.md) | | [optional] | |**status** | [**StatusEnum**](#StatusEnum) | pet status in the store | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/PetApi.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/PetApi.md index 997a57e44648..f395ba3f6f16 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/PetApi.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/PetApi.md @@ -110,8 +110,8 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - Object petId = null; // Object | Pet id to delete - Object apiKey = null; // Object | + Long petId = 56L; // Long | Pet id to delete + String apiKey = "apiKey_example"; // String | try { apiInstance.deletePet(petId, apiKey); } catch (ApiException e) { @@ -129,8 +129,8 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **petId** | [**Object**](.md)| Pet id to delete | | -| **apiKey** | [**Object**](.md)| | [optional] | +| **petId** | **Long**| Pet id to delete | | +| **apiKey** | **String**| | [optional] | ### Return type @@ -152,7 +152,7 @@ null (empty response body) # **findPetsByStatus** -> Object findPetsByStatus(status) +> List<Pet> findPetsByStatus(status) Finds Pets by status @@ -178,9 +178,9 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - Object status = null; // Object | Status values that need to be considered for filter + List status = Arrays.asList("available"); // List | Status values that need to be considered for filter try { - Object result = apiInstance.findPetsByStatus(status); + List result = apiInstance.findPetsByStatus(status); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling PetApi#findPetsByStatus"); @@ -197,11 +197,11 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **status** | [**Object**](.md)| Status values that need to be considered for filter | | +| **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] | ### Return type -**Object** +[**List<Pet>**](Pet.md) ### Authorization @@ -220,7 +220,7 @@ public class Example { # **findPetsByTags** -> Object findPetsByTags(tags) +> List<Pet> findPetsByTags(tags) Finds Pets by tags @@ -246,9 +246,9 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - Object tags = null; // Object | Tags to filter by + List tags = Arrays.asList(); // List | Tags to filter by try { - Object result = apiInstance.findPetsByTags(tags); + List result = apiInstance.findPetsByTags(tags); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling PetApi#findPetsByTags"); @@ -265,11 +265,11 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **tags** | [**Object**](.md)| Tags to filter by | | +| **tags** | [**List<String>**](String.md)| Tags to filter by | | ### Return type -**Object** +[**List<Pet>**](Pet.md) ### Authorization @@ -316,7 +316,7 @@ public class Example { //api_key.setApiKeyPrefix("Token"); PetApi apiInstance = new PetApi(defaultClient); - Object petId = null; // Object | ID of pet to return + Long petId = 56L; // Long | ID of pet to return try { Pet result = apiInstance.getPetById(petId); System.out.println(result); @@ -335,7 +335,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **petId** | [**Object**](.md)| ID of pet to return | | +| **petId** | **Long**| ID of pet to return | | ### Return type @@ -455,9 +455,9 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - Object petId = null; // Object | ID of pet that needs to be updated - Object name = null; // Object | Updated name of the pet - Object status = null; // Object | Updated status of the pet + Long petId = 56L; // Long | ID of pet that needs to be updated + String name = "name_example"; // String | Updated name of the pet + String status = "status_example"; // String | Updated status of the pet try { apiInstance.updatePetWithForm(petId, name, status); } catch (ApiException e) { @@ -475,9 +475,9 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **petId** | [**Object**](.md)| ID of pet that needs to be updated | | -| **name** | [**Object**](Object.md)| Updated name of the pet | [optional] | -| **status** | [**Object**](Object.md)| Updated status of the pet | [optional] | +| **petId** | **Long**| ID of pet that needs to be updated | | +| **name** | **String**| Updated name of the pet | [optional] | +| **status** | **String**| Updated status of the pet | [optional] | ### Return type @@ -525,9 +525,9 @@ public class Example { petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); PetApi apiInstance = new PetApi(defaultClient); - Object petId = null; // Object | ID of pet to update - Object additionalMetadata = null; // Object | Additional data to pass to server - Object _file = null; // Object | file to upload + Long petId = 56L; // Long | ID of pet to update + String additionalMetadata = "additionalMetadata_example"; // String | Additional data to pass to server + File _file = new File("/path/to/file"); // File | file to upload try { ModelApiResponse result = apiInstance.uploadFile(petId, additionalMetadata, _file); System.out.println(result); @@ -546,9 +546,9 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **petId** | [**Object**](.md)| ID of pet to update | | -| **additionalMetadata** | [**Object**](Object.md)| Additional data to pass to server | [optional] | -| **_file** | [**Object**](Object.md)| file to upload | [optional] | +| **petId** | **Long**| ID of pet to update | | +| **additionalMetadata** | **String**| Additional data to pass to server | [optional] | +| **_file** | **File**| file to upload | [optional] | ### Return type diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/StoreApi.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/StoreApi.md index d4a84a24e652..af54298ffc2e 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/StoreApi.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/StoreApi.md @@ -33,7 +33,7 @@ public class Example { defaultClient.setBasePath("http://petstore.swagger.io/v2"); StoreApi apiInstance = new StoreApi(defaultClient); - Object orderId = null; // Object | ID of the order that needs to be deleted + String orderId = "orderId_example"; // String | ID of the order that needs to be deleted try { apiInstance.deleteOrder(orderId); } catch (ApiException e) { @@ -51,7 +51,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **orderId** | [**Object**](.md)| ID of the order that needs to be deleted | | +| **orderId** | **String**| ID of the order that needs to be deleted | | ### Return type @@ -74,7 +74,7 @@ No authorization required # **getInventory** -> Map<String, Object> getInventory() +> Map<String, Integer> getInventory() Returns pet inventories by status @@ -103,7 +103,7 @@ public class Example { StoreApi apiInstance = new StoreApi(defaultClient); try { - Map result = apiInstance.getInventory(); + Map result = apiInstance.getInventory(); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling StoreApi#getInventory"); @@ -121,7 +121,7 @@ This endpoint does not need any parameter. ### Return type -**Map<String, Object>** +**Map<String, Integer>** ### Authorization @@ -160,7 +160,7 @@ public class Example { defaultClient.setBasePath("http://petstore.swagger.io/v2"); StoreApi apiInstance = new StoreApi(defaultClient); - Object orderId = null; // Object | ID of pet that needs to be fetched + Long orderId = 56L; // Long | ID of pet that needs to be fetched try { Order result = apiInstance.getOrderById(orderId); System.out.println(result); @@ -179,7 +179,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **orderId** | [**Object**](.md)| ID of pet that needs to be fetched | | +| **orderId** | **Long**| ID of pet that needs to be fetched | | ### Return type diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/Tag.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/Tag.md index 6b5547b120b7..abfde4afb501 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/Tag.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/Tag.md @@ -8,8 +8,8 @@ A tag for a pet | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Object** | | [optional] | -|**name** | **Object** | | [optional] | +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/User.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/User.md index 02cacc0b6aaf..426845227bd3 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/User.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/User.md @@ -8,14 +8,14 @@ A User who is purchasing from the pet store | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**id** | **Object** | | [optional] | -|**username** | **Object** | | [optional] | -|**firstName** | **Object** | | [optional] | -|**lastName** | **Object** | | [optional] | -|**email** | **Object** | | [optional] | -|**password** | **Object** | | [optional] | -|**phone** | **Object** | | [optional] | -|**userStatus** | **Object** | User Status | [optional] | +|**id** | **Long** | | [optional] | +|**username** | **String** | | [optional] | +|**firstName** | **String** | | [optional] | +|**lastName** | **String** | | [optional] | +|**email** | **String** | | [optional] | +|**password** | **String** | | [optional] | +|**phone** | **String** | | [optional] | +|**userStatus** | **Integer** | User Status | [optional] | diff --git a/samples/client/petstore/java/okhttp-gson-3.1/docs/UserApi.md b/samples/client/petstore/java/okhttp-gson-3.1/docs/UserApi.md index 17b29f98ef90..4c338a42137a 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/docs/UserApi.md +++ b/samples/client/petstore/java/okhttp-gson-3.1/docs/UserApi.md @@ -84,7 +84,7 @@ null (empty response body) # **createUsersWithArrayInput** -> createUsersWithArrayInput(body) +> createUsersWithArrayInput(user) Creates list of users with given input array @@ -112,9 +112,9 @@ public class Example { //api_key.setApiKeyPrefix("Token"); UserApi apiInstance = new UserApi(defaultClient); - Object body = null; // Object | List of user object + List user = Arrays.asList(); // List | List of user object try { - apiInstance.createUsersWithArrayInput(body); + apiInstance.createUsersWithArrayInput(user); } catch (ApiException e) { System.err.println("Exception when calling UserApi#createUsersWithArrayInput"); System.err.println("Status code: " + e.getCode()); @@ -130,7 +130,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **body** | **Object**| List of user object | | +| **user** | [**List<User>**](User.md)| List of user object | | ### Return type @@ -152,7 +152,7 @@ null (empty response body) # **createUsersWithListInput** -> createUsersWithListInput(body) +> createUsersWithListInput(user) Creates list of users with given input array @@ -180,9 +180,9 @@ public class Example { //api_key.setApiKeyPrefix("Token"); UserApi apiInstance = new UserApi(defaultClient); - Object body = null; // Object | List of user object + List user = Arrays.asList(); // List | List of user object try { - apiInstance.createUsersWithListInput(body); + apiInstance.createUsersWithListInput(user); } catch (ApiException e) { System.err.println("Exception when calling UserApi#createUsersWithListInput"); System.err.println("Status code: " + e.getCode()); @@ -198,7 +198,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **body** | **Object**| List of user object | | +| **user** | [**List<User>**](User.md)| List of user object | | ### Return type @@ -248,7 +248,7 @@ public class Example { //api_key.setApiKeyPrefix("Token"); UserApi apiInstance = new UserApi(defaultClient); - Object username = null; // Object | The name that needs to be deleted + String username = "username_example"; // String | The name that needs to be deleted try { apiInstance.deleteUser(username); } catch (ApiException e) { @@ -266,7 +266,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **username** | [**Object**](.md)| The name that needs to be deleted | | +| **username** | **String**| The name that needs to be deleted | | ### Return type @@ -310,7 +310,7 @@ public class Example { defaultClient.setBasePath("http://petstore.swagger.io/v2"); UserApi apiInstance = new UserApi(defaultClient); - Object username = null; // Object | The name that needs to be fetched. Use user1 for testing. + String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing. try { User result = apiInstance.getUserByName(username); System.out.println(result); @@ -329,7 +329,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **username** | [**Object**](.md)| The name that needs to be fetched. Use user1 for testing. | | +| **username** | **String**| The name that needs to be fetched. Use user1 for testing. | | ### Return type @@ -353,7 +353,7 @@ No authorization required # **loginUser** -> Object loginUser(username, password) +> String loginUser(username, password) Logs user into the system @@ -374,10 +374,10 @@ public class Example { defaultClient.setBasePath("http://petstore.swagger.io/v2"); UserApi apiInstance = new UserApi(defaultClient); - Object username = null; // Object | The user name for login - Object password = null; // Object | The password for login in clear text + String username = "username_example"; // String | The user name for login + String password = "password_example"; // String | The password for login in clear text try { - Object result = apiInstance.loginUser(username, password); + String result = apiInstance.loginUser(username, password); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling UserApi#loginUser"); @@ -394,12 +394,12 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **username** | [**Object**](.md)| The user name for login | | -| **password** | [**Object**](.md)| The password for login in clear text | | +| **username** | **String**| The user name for login | | +| **password** | **String**| The password for login in clear text | | ### Return type -**Object** +**String** ### Authorization @@ -510,7 +510,7 @@ public class Example { //api_key.setApiKeyPrefix("Token"); UserApi apiInstance = new UserApi(defaultClient); - Object username = null; // Object | name that need to be deleted + String username = "username_example"; // String | name that need to be deleted User user = new User(); // User | Updated user object try { apiInstance.updateUser(username, user); @@ -529,7 +529,7 @@ public class Example { | Name | Type | Description | Notes | |------------- | ------------- | ------------- | -------------| -| **username** | [**Object**](.md)| name that need to be deleted | | +| **username** | **String**| name that need to be deleted | | | **user** | [**User**](User.md)| Updated user object | | ### Return type diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/JSON.java index 7a2100290183..6791d767d970 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/JSON.java @@ -62,10 +62,30 @@ public static GsonBuilder createGson() { @Override public Class getClassForElement(JsonElement readElement) { Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("Cat", org.openapitools.client.model.Cat.class); + classByDiscriminatorValue.put("Dog", org.openapitools.client.model.Dog.class); classByDiscriminatorValue.put("Animal", org.openapitools.client.model.Animal.class); return getClassByDiscriminator(classByDiscriminatorValue, getDiscriminatorValue(readElement, "className")); } + }) + .registerTypeSelector(org.openapitools.client.model.Cat.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("Cat", org.openapitools.client.model.Cat.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "className")); + } + }) + .registerTypeSelector(org.openapitools.client.model.Dog.class, new TypeSelector() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + classByDiscriminatorValue.put("Dog", org.openapitools.client.model.Dog.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "className")); + } }) ; GsonBuilder builder = fireBuilder.createGsonBuilder(); @@ -102,11 +122,14 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); - gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Animal.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Cat.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Category.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Dog.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ModelApiResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.OneOfStringOrInt.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Order.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.StringOrInt.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Tag.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.User.CustomTypeAdapterFactory()); gson = gsonBuilder.create(); diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/PetApi.java index 9b7a308aa3c2..2c57d0c17dcd 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/PetApi.java @@ -27,6 +27,7 @@ import java.io.IOException; +import java.io.File; import org.openapitools.client.model.ModelApiResponse; import org.openapitools.client.model.Pet; @@ -215,7 +216,7 @@ public okhttp3.Call addPetAsync(Pet pet, final ApiCallback _callback) throw 400 Invalid pet value - */ - public okhttp3.Call deletePetCall(Object petId, Object apiKey, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -264,7 +265,7 @@ public okhttp3.Call deletePetCall(Object petId, Object apiKey, final ApiCallback } @SuppressWarnings("rawtypes") - private okhttp3.Call deletePetValidateBeforeCall(Object petId, Object apiKey, final ApiCallback _callback) throws ApiException { + private okhttp3.Call deletePetValidateBeforeCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException("Missing the required parameter 'petId' when calling deletePet(Async)"); @@ -286,7 +287,7 @@ private okhttp3.Call deletePetValidateBeforeCall(Object petId, Object apiKey, fi 400 Invalid pet value - */ - public void deletePet(Object petId, Object apiKey) throws ApiException { + public void deletePet(Long petId, String apiKey) throws ApiException { deletePetWithHttpInfo(petId, apiKey); } @@ -303,7 +304,7 @@ public void deletePet(Object petId, Object apiKey) throws ApiException { 400 Invalid pet value - */ - public ApiResponse deletePetWithHttpInfo(Object petId, Object apiKey) throws ApiException { + public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws ApiException { okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, null); return localVarApiClient.execute(localVarCall); } @@ -322,7 +323,7 @@ public ApiResponse deletePetWithHttpInfo(Object petId, Object apiKey) thro 400 Invalid pet value - */ - public okhttp3.Call deletePetAsync(Object petId, Object apiKey, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deletePetAsync(Long petId, String apiKey, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = deletePetValidateBeforeCall(petId, apiKey, _callback); localVarApiClient.executeAsync(localVarCall, _callback); @@ -341,7 +342,7 @@ public okhttp3.Call deletePetAsync(Object petId, Object apiKey, final ApiCallbac 400 Invalid status value - */ - public okhttp3.Call findPetsByStatusCall(Object status, final ApiCallback _callback) throws ApiException { + public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -367,7 +368,7 @@ public okhttp3.Call findPetsByStatusCall(Object status, final ApiCallback _callb Map localVarFormParams = new HashMap(); if (status != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("status", status)); + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "status", status)); } final String[] localVarAccepts = { @@ -391,7 +392,7 @@ public okhttp3.Call findPetsByStatusCall(Object status, final ApiCallback _callb } @SuppressWarnings("rawtypes") - private okhttp3.Call findPetsByStatusValidateBeforeCall(Object status, final ApiCallback _callback) throws ApiException { + private okhttp3.Call findPetsByStatusValidateBeforeCall(List status, final ApiCallback _callback) throws ApiException { // verify the required parameter 'status' is set if (status == null) { throw new ApiException("Missing the required parameter 'status' when calling findPetsByStatus(Async)"); @@ -405,7 +406,7 @@ private okhttp3.Call findPetsByStatusValidateBeforeCall(Object status, final Api * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter (required) - * @return Object + * @return List<Pet> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -414,8 +415,8 @@ private okhttp3.Call findPetsByStatusValidateBeforeCall(Object status, final Api
400 Invalid status value -
*/ - public Object findPetsByStatus(Object status) throws ApiException { - ApiResponse localVarResp = findPetsByStatusWithHttpInfo(status); + public List findPetsByStatus(List status) throws ApiException { + ApiResponse> localVarResp = findPetsByStatusWithHttpInfo(status); return localVarResp.getData(); } @@ -423,7 +424,7 @@ public Object findPetsByStatus(Object status) throws ApiException { * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter (required) - * @return ApiResponse<Object> + * @return ApiResponse<List<Pet>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -432,9 +433,9 @@ public Object findPetsByStatus(Object status) throws ApiException {
400 Invalid status value -
*/ - public ApiResponse findPetsByStatusWithHttpInfo(Object status) throws ApiException { + public ApiResponse> findPetsByStatusWithHttpInfo(List status) throws ApiException { okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -452,10 +453,10 @@ public ApiResponse findPetsByStatusWithHttpInfo(Object status) throws Ap 400 Invalid status value - */ - public okhttp3.Call findPetsByStatusAsync(Object status, final ApiCallback _callback) throws ApiException { + public okhttp3.Call findPetsByStatusAsync(List status, final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -474,7 +475,7 @@ public okhttp3.Call findPetsByStatusAsync(Object status, final ApiCallback tags, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -500,7 +501,7 @@ public okhttp3.Call findPetsByTagsCall(Object tags, final ApiCallback _callback) Map localVarFormParams = new HashMap(); if (tags != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("tags", tags)); + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "tags", tags)); } final String[] localVarAccepts = { @@ -525,7 +526,7 @@ public okhttp3.Call findPetsByTagsCall(Object tags, final ApiCallback _callback) @Deprecated @SuppressWarnings("rawtypes") - private okhttp3.Call findPetsByTagsValidateBeforeCall(Object tags, final ApiCallback _callback) throws ApiException { + private okhttp3.Call findPetsByTagsValidateBeforeCall(List tags, final ApiCallback _callback) throws ApiException { // verify the required parameter 'tags' is set if (tags == null) { throw new ApiException("Missing the required parameter 'tags' when calling findPetsByTags(Async)"); @@ -539,7 +540,7 @@ private okhttp3.Call findPetsByTagsValidateBeforeCall(Object tags, final ApiCall * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by (required) - * @return Object + * @return List<Pet> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -550,8 +551,8 @@ private okhttp3.Call findPetsByTagsValidateBeforeCall(Object tags, final ApiCall * @deprecated */ @Deprecated - public Object findPetsByTags(Object tags) throws ApiException { - ApiResponse localVarResp = findPetsByTagsWithHttpInfo(tags); + public List findPetsByTags(List tags) throws ApiException { + ApiResponse> localVarResp = findPetsByTagsWithHttpInfo(tags); return localVarResp.getData(); } @@ -559,7 +560,7 @@ public Object findPetsByTags(Object tags) throws ApiException { * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by (required) - * @return ApiResponse<Object> + * @return ApiResponse<List<Pet>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details
@@ -570,9 +571,9 @@ public Object findPetsByTags(Object tags) throws ApiException { * @deprecated */ @Deprecated - public ApiResponse findPetsByTagsWithHttpInfo(Object tags) throws ApiException { + public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException { okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -592,10 +593,10 @@ public ApiResponse findPetsByTagsWithHttpInfo(Object tags) throws ApiExc * @deprecated */ @Deprecated - public okhttp3.Call findPetsByTagsAsync(Object tags, final ApiCallback _callback) throws ApiException { + public okhttp3.Call findPetsByTagsAsync(List tags, final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -613,7 +614,7 @@ public okhttp3.Call findPetsByTagsAsync(Object tags, final ApiCallback _
404 Pet not found -
*/ - public okhttp3.Call getPetByIdCall(Object petId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -660,7 +661,7 @@ public okhttp3.Call getPetByIdCall(Object petId, final ApiCallback _callback) th } @SuppressWarnings("rawtypes") - private okhttp3.Call getPetByIdValidateBeforeCall(Object petId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getPetByIdValidateBeforeCall(Long petId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException("Missing the required parameter 'petId' when calling getPetById(Async)"); @@ -684,7 +685,7 @@ private okhttp3.Call getPetByIdValidateBeforeCall(Object petId, final ApiCallbac 404 Pet not found - */ - public Pet getPetById(Object petId) throws ApiException { + public Pet getPetById(Long petId) throws ApiException { ApiResponse localVarResp = getPetByIdWithHttpInfo(petId); return localVarResp.getData(); } @@ -703,7 +704,7 @@ public Pet getPetById(Object petId) throws ApiException { 404 Pet not found - */ - public ApiResponse getPetByIdWithHttpInfo(Object petId) throws ApiException { + public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -724,7 +725,7 @@ public ApiResponse getPetByIdWithHttpInfo(Object petId) throws ApiException 404 Pet not found - */ - public okhttp3.Call getPetByIdAsync(Object petId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getPetByIdAsync(Long petId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); @@ -890,7 +891,7 @@ public okhttp3.Call updatePetAsync(Pet pet, final ApiCallback _callback) th 405 Invalid input - */ - public okhttp3.Call updatePetWithFormCall(Object petId, Object name, Object status, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -944,7 +945,7 @@ public okhttp3.Call updatePetWithFormCall(Object petId, Object name, Object stat } @SuppressWarnings("rawtypes") - private okhttp3.Call updatePetWithFormValidateBeforeCall(Object petId, Object name, Object status, final ApiCallback _callback) throws ApiException { + private okhttp3.Call updatePetWithFormValidateBeforeCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException("Missing the required parameter 'petId' when calling updatePetWithForm(Async)"); @@ -967,7 +968,7 @@ private okhttp3.Call updatePetWithFormValidateBeforeCall(Object petId, Object na 405 Invalid input - */ - public void updatePetWithForm(Object petId, Object name, Object status) throws ApiException { + public void updatePetWithForm(Long petId, String name, String status) throws ApiException { updatePetWithFormWithHttpInfo(petId, name, status); } @@ -985,7 +986,7 @@ public void updatePetWithForm(Object petId, Object name, Object status) throws A 405 Invalid input - */ - public ApiResponse updatePetWithFormWithHttpInfo(Object petId, Object name, Object status) throws ApiException { + public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, String status) throws ApiException { okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, null); return localVarApiClient.execute(localVarCall); } @@ -1005,7 +1006,7 @@ public ApiResponse updatePetWithFormWithHttpInfo(Object petId, Object name 405 Invalid input - */ - public okhttp3.Call updatePetWithFormAsync(Object petId, Object name, Object status, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updatePetWithFormAsync(Long petId, String name, String status, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = updatePetWithFormValidateBeforeCall(petId, name, status, _callback); localVarApiClient.executeAsync(localVarCall, _callback); @@ -1025,7 +1026,7 @@ public okhttp3.Call updatePetWithFormAsync(Object petId, Object name, Object sta 200 successful operation - */ - public okhttp3.Call uploadFileCall(Object petId, Object additionalMetadata, Object _file, final ApiCallback _callback) throws ApiException { + public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1080,7 +1081,7 @@ public okhttp3.Call uploadFileCall(Object petId, Object additionalMetadata, Obje } @SuppressWarnings("rawtypes") - private okhttp3.Call uploadFileValidateBeforeCall(Object petId, Object additionalMetadata, Object _file, final ApiCallback _callback) throws ApiException { + private okhttp3.Call uploadFileValidateBeforeCall(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException { // verify the required parameter 'petId' is set if (petId == null) { throw new ApiException("Missing the required parameter 'petId' when calling uploadFile(Async)"); @@ -1104,7 +1105,7 @@ private okhttp3.Call uploadFileValidateBeforeCall(Object petId, Object additiona 200 successful operation - */ - public ModelApiResponse uploadFile(Object petId, Object additionalMetadata, Object _file) throws ApiException { + public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File _file) throws ApiException { ApiResponse localVarResp = uploadFileWithHttpInfo(petId, additionalMetadata, _file); return localVarResp.getData(); } @@ -1123,7 +1124,7 @@ public ModelApiResponse uploadFile(Object petId, Object additionalMetadata, Obje 200 successful operation - */ - public ApiResponse uploadFileWithHttpInfo(Object petId, Object additionalMetadata, Object _file) throws ApiException { + public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File _file) throws ApiException { okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, _file, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -1144,7 +1145,7 @@ public ApiResponse uploadFileWithHttpInfo(Object petId, Object 200 successful operation - */ - public okhttp3.Call uploadFileAsync(Object petId, Object additionalMetadata, Object _file, final ApiCallback _callback) throws ApiException { + public okhttp3.Call uploadFileAsync(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, _file, _callback); Type localVarReturnType = new TypeToken(){}.getType(); diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/StoreApi.java index c1a8d762da00..df8db739366f 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/StoreApi.java @@ -85,7 +85,7 @@ public void setCustomBaseUrl(String customBaseUrl) { 404 Order not found - */ - public okhttp3.Call deleteOrderCall(Object orderId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -130,7 +130,7 @@ public okhttp3.Call deleteOrderCall(Object orderId, final ApiCallback _callback) } @SuppressWarnings("rawtypes") - private okhttp3.Call deleteOrderValidateBeforeCall(Object orderId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call deleteOrderValidateBeforeCall(String orderId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException("Missing the required parameter 'orderId' when calling deleteOrder(Async)"); @@ -152,7 +152,7 @@ private okhttp3.Call deleteOrderValidateBeforeCall(Object orderId, final ApiCall 404 Order not found - */ - public void deleteOrder(Object orderId) throws ApiException { + public void deleteOrder(String orderId) throws ApiException { deleteOrderWithHttpInfo(orderId); } @@ -169,7 +169,7 @@ public void deleteOrder(Object orderId) throws ApiException { 404 Order not found - */ - public ApiResponse deleteOrderWithHttpInfo(Object orderId) throws ApiException { + public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiException { okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, null); return localVarApiClient.execute(localVarCall); } @@ -188,7 +188,7 @@ public ApiResponse deleteOrderWithHttpInfo(Object orderId) throws ApiExcep 404 Order not found - */ - public okhttp3.Call deleteOrderAsync(Object orderId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteOrderAsync(String orderId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = deleteOrderValidateBeforeCall(orderId, _callback); localVarApiClient.executeAsync(localVarCall, _callback); @@ -258,7 +258,7 @@ private okhttp3.Call getInventoryValidateBeforeCall(final ApiCallback _callback) /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return Map<String, Object> + * @return Map<String, Integer> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -266,15 +266,15 @@ private okhttp3.Call getInventoryValidateBeforeCall(final ApiCallback _callback)
200 successful operation -
*/ - public Map getInventory() throws ApiException { - ApiResponse> localVarResp = getInventoryWithHttpInfo(); + public Map getInventory() throws ApiException { + ApiResponse> localVarResp = getInventoryWithHttpInfo(); return localVarResp.getData(); } /** * Returns pet inventories by status * Returns a map of status codes to quantities - * @return ApiResponse<Map<String, Object>> + * @return ApiResponse<Map<String, Integer>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -282,9 +282,9 @@ public Map getInventory() throws ApiException {
200 successful operation -
*/ - public ApiResponse> getInventoryWithHttpInfo() throws ApiException { + public ApiResponse> getInventoryWithHttpInfo() throws ApiException { okhttp3.Call localVarCall = getInventoryValidateBeforeCall(null); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -300,10 +300,10 @@ public ApiResponse> getInventoryWithHttpInfo() throws ApiExc 200 successful operation - */ - public okhttp3.Call getInventoryAsync(final ApiCallback> _callback) throws ApiException { + public okhttp3.Call getInventoryAsync(final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = getInventoryValidateBeforeCall(_callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -321,7 +321,7 @@ public okhttp3.Call getInventoryAsync(final ApiCallback> _ca 404 Order not found - */ - public okhttp3.Call getOrderByIdCall(Object orderId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -368,7 +368,7 @@ public okhttp3.Call getOrderByIdCall(Object orderId, final ApiCallback _callback } @SuppressWarnings("rawtypes") - private okhttp3.Call getOrderByIdValidateBeforeCall(Object orderId, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getOrderByIdValidateBeforeCall(Long orderId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'orderId' is set if (orderId == null) { throw new ApiException("Missing the required parameter 'orderId' when calling getOrderById(Async)"); @@ -392,7 +392,7 @@ private okhttp3.Call getOrderByIdValidateBeforeCall(Object orderId, final ApiCal 404 Order not found - */ - public Order getOrderById(Object orderId) throws ApiException { + public Order getOrderById(Long orderId) throws ApiException { ApiResponse localVarResp = getOrderByIdWithHttpInfo(orderId); return localVarResp.getData(); } @@ -411,7 +411,7 @@ public Order getOrderById(Object orderId) throws ApiException { 404 Order not found - */ - public ApiResponse getOrderByIdWithHttpInfo(Object orderId) throws ApiException { + public ApiResponse getOrderByIdWithHttpInfo(Long orderId) throws ApiException { okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -432,7 +432,7 @@ public ApiResponse getOrderByIdWithHttpInfo(Object orderId) throws ApiExc 404 Order not found - */ - public okhttp3.Call getOrderByIdAsync(Object orderId, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getOrderByIdAsync(Long orderId, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, _callback); Type localVarReturnType = new TypeToken(){}.getType(); diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/UserApi.java index 3335c3d00389..7b8cb5c3dcbe 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/api/UserApi.java @@ -27,6 +27,7 @@ import java.io.IOException; +import java.time.OffsetDateTime; import org.openapitools.client.model.User; import java.lang.reflect.Type; @@ -192,7 +193,7 @@ public okhttp3.Call createUserAsync(User user, final ApiCallback _callback } /** * Build call for createUsersWithArrayInput - * @param body List of user object (required) + * @param user List of user object (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -202,7 +203,7 @@ public okhttp3.Call createUserAsync(User user, final ApiCallback _callback 0 successful operation - */ - public okhttp3.Call createUsersWithArrayInputCall(Object body, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createUsersWithArrayInputCall(List user, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -216,7 +217,7 @@ public okhttp3.Call createUsersWithArrayInputCall(Object body, final ApiCallback basePath = null; } - Object localVarPostBody = body; + Object localVarPostBody = user; // create path and map variables String localVarPath = "/user/createWithArray"; @@ -247,20 +248,20 @@ public okhttp3.Call createUsersWithArrayInputCall(Object body, final ApiCallback } @SuppressWarnings("rawtypes") - private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(Object body, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling createUsersWithArrayInput(Async)"); + private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(List user, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException("Missing the required parameter 'user' when calling createUsersWithArrayInput(Async)"); } - return createUsersWithArrayInputCall(body, _callback); + return createUsersWithArrayInputCall(user, _callback); } /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param user List of user object (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -268,14 +269,14 @@ private okhttp3.Call createUsersWithArrayInputValidateBeforeCall(Object body, fi
0 successful operation -
*/ - public void createUsersWithArrayInput(Object body) throws ApiException { - createUsersWithArrayInputWithHttpInfo(body); + public void createUsersWithArrayInput(List user) throws ApiException { + createUsersWithArrayInputWithHttpInfo(user); } /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param user List of user object (required) * @return ApiResponse<Void> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -284,15 +285,15 @@ public void createUsersWithArrayInput(Object body) throws ApiException { 0 successful operation - */ - public ApiResponse createUsersWithArrayInputWithHttpInfo(Object body) throws ApiException { - okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, null); + public ApiResponse createUsersWithArrayInputWithHttpInfo(List user) throws ApiException { + okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(user, null); return localVarApiClient.execute(localVarCall); } /** * Creates list of users with given input array (asynchronously) * - * @param body List of user object (required) + * @param user List of user object (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -302,15 +303,15 @@ public ApiResponse createUsersWithArrayInputWithHttpInfo(Object body) thro 0 successful operation - */ - public okhttp3.Call createUsersWithArrayInputAsync(Object body, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createUsersWithArrayInputAsync(List user, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(body, _callback); + okhttp3.Call localVarCall = createUsersWithArrayInputValidateBeforeCall(user, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } /** * Build call for createUsersWithListInput - * @param body List of user object (required) + * @param user List of user object (required) * @param _callback Callback for upload/download progress * @return Call to execute * @throws ApiException If fail to serialize the request body object @@ -320,7 +321,7 @@ public okhttp3.Call createUsersWithArrayInputAsync(Object body, final ApiCallbac 0 successful operation - */ - public okhttp3.Call createUsersWithListInputCall(Object body, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createUsersWithListInputCall(List user, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -334,7 +335,7 @@ public okhttp3.Call createUsersWithListInputCall(Object body, final ApiCallback basePath = null; } - Object localVarPostBody = body; + Object localVarPostBody = user; // create path and map variables String localVarPath = "/user/createWithList"; @@ -365,20 +366,20 @@ public okhttp3.Call createUsersWithListInputCall(Object body, final ApiCallback } @SuppressWarnings("rawtypes") - private okhttp3.Call createUsersWithListInputValidateBeforeCall(Object body, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling createUsersWithListInput(Async)"); + private okhttp3.Call createUsersWithListInputValidateBeforeCall(List user, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'user' is set + if (user == null) { + throw new ApiException("Missing the required parameter 'user' when calling createUsersWithListInput(Async)"); } - return createUsersWithListInputCall(body, _callback); + return createUsersWithListInputCall(user, _callback); } /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param user List of user object (required) * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -386,14 +387,14 @@ private okhttp3.Call createUsersWithListInputValidateBeforeCall(Object body, fin
0 successful operation -
*/ - public void createUsersWithListInput(Object body) throws ApiException { - createUsersWithListInputWithHttpInfo(body); + public void createUsersWithListInput(List user) throws ApiException { + createUsersWithListInputWithHttpInfo(user); } /** * Creates list of users with given input array * - * @param body List of user object (required) + * @param user List of user object (required) * @return ApiResponse<Void> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -402,15 +403,15 @@ public void createUsersWithListInput(Object body) throws ApiException { 0 successful operation - */ - public ApiResponse createUsersWithListInputWithHttpInfo(Object body) throws ApiException { - okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, null); + public ApiResponse createUsersWithListInputWithHttpInfo(List user) throws ApiException { + okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(user, null); return localVarApiClient.execute(localVarCall); } /** * Creates list of users with given input array (asynchronously) * - * @param body List of user object (required) + * @param user List of user object (required) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object @@ -420,9 +421,9 @@ public ApiResponse createUsersWithListInputWithHttpInfo(Object body) throw 0 successful operation - */ - public okhttp3.Call createUsersWithListInputAsync(Object body, final ApiCallback _callback) throws ApiException { + public okhttp3.Call createUsersWithListInputAsync(List user, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(body, _callback); + okhttp3.Call localVarCall = createUsersWithListInputValidateBeforeCall(user, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -439,7 +440,7 @@ public okhttp3.Call createUsersWithListInputAsync(Object body, final ApiCallback 404 User not found - */ - public okhttp3.Call deleteUserCall(Object username, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -484,7 +485,7 @@ public okhttp3.Call deleteUserCall(Object username, final ApiCallback _callback) } @SuppressWarnings("rawtypes") - private okhttp3.Call deleteUserValidateBeforeCall(Object username, final ApiCallback _callback) throws ApiException { + private okhttp3.Call deleteUserValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException("Missing the required parameter 'username' when calling deleteUser(Async)"); @@ -506,7 +507,7 @@ private okhttp3.Call deleteUserValidateBeforeCall(Object username, final ApiCall 404 User not found - */ - public void deleteUser(Object username) throws ApiException { + public void deleteUser(String username) throws ApiException { deleteUserWithHttpInfo(username); } @@ -523,7 +524,7 @@ public void deleteUser(Object username) throws ApiException { 404 User not found - */ - public ApiResponse deleteUserWithHttpInfo(Object username) throws ApiException { + public ApiResponse deleteUserWithHttpInfo(String username) throws ApiException { okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, null); return localVarApiClient.execute(localVarCall); } @@ -542,7 +543,7 @@ public ApiResponse deleteUserWithHttpInfo(Object username) throws ApiExcep 404 User not found - */ - public okhttp3.Call deleteUserAsync(Object username, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteUserAsync(String username, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = deleteUserValidateBeforeCall(username, _callback); localVarApiClient.executeAsync(localVarCall, _callback); @@ -562,7 +563,7 @@ public okhttp3.Call deleteUserAsync(Object username, final ApiCallback _ca 404 User not found - */ - public okhttp3.Call getUserByNameCall(Object username, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -609,7 +610,7 @@ public okhttp3.Call getUserByNameCall(Object username, final ApiCallback _callba } @SuppressWarnings("rawtypes") - private okhttp3.Call getUserByNameValidateBeforeCall(Object username, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getUserByNameValidateBeforeCall(String username, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException("Missing the required parameter 'username' when calling getUserByName(Async)"); @@ -633,7 +634,7 @@ private okhttp3.Call getUserByNameValidateBeforeCall(Object username, final ApiC 404 User not found - */ - public User getUserByName(Object username) throws ApiException { + public User getUserByName(String username) throws ApiException { ApiResponse localVarResp = getUserByNameWithHttpInfo(username); return localVarResp.getData(); } @@ -652,7 +653,7 @@ public User getUserByName(Object username) throws ApiException { 404 User not found - */ - public ApiResponse getUserByNameWithHttpInfo(Object username) throws ApiException { + public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiException { okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, null); Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); @@ -673,7 +674,7 @@ public ApiResponse getUserByNameWithHttpInfo(Object username) throws ApiEx 404 User not found - */ - public okhttp3.Call getUserByNameAsync(Object username, final ApiCallback _callback) throws ApiException { + public okhttp3.Call getUserByNameAsync(String username, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, _callback); Type localVarReturnType = new TypeToken(){}.getType(); @@ -694,7 +695,7 @@ public okhttp3.Call getUserByNameAsync(Object username, final ApiCallback 400 Invalid username/password supplied - */ - public okhttp3.Call loginUserCall(Object username, Object password, final ApiCallback _callback) throws ApiException { + public okhttp3.Call loginUserCall(String username, String password, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -748,7 +749,7 @@ public okhttp3.Call loginUserCall(Object username, Object password, final ApiCal } @SuppressWarnings("rawtypes") - private okhttp3.Call loginUserValidateBeforeCall(Object username, Object password, final ApiCallback _callback) throws ApiException { + private okhttp3.Call loginUserValidateBeforeCall(String username, String password, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException("Missing the required parameter 'username' when calling loginUser(Async)"); @@ -768,7 +769,7 @@ private okhttp3.Call loginUserValidateBeforeCall(Object username, Object passwor * * @param username The user name for login (required) * @param password The password for login in clear text (required) - * @return Object + * @return String * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -777,8 +778,8 @@ private okhttp3.Call loginUserValidateBeforeCall(Object username, Object passwor
400 Invalid username/password supplied -
*/ - public Object loginUser(Object username, Object password) throws ApiException { - ApiResponse localVarResp = loginUserWithHttpInfo(username, password); + public String loginUser(String username, String password) throws ApiException { + ApiResponse localVarResp = loginUserWithHttpInfo(username, password); return localVarResp.getData(); } @@ -787,7 +788,7 @@ public Object loginUser(Object username, Object password) throws ApiException { * * @param username The user name for login (required) * @param password The password for login in clear text (required) - * @return ApiResponse<Object> + * @return ApiResponse<String> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -796,9 +797,9 @@ public Object loginUser(Object username, Object password) throws ApiException {
400 Invalid username/password supplied -
*/ - public ApiResponse loginUserWithHttpInfo(Object username, Object password) throws ApiException { + public ApiResponse loginUserWithHttpInfo(String username, String password) throws ApiException { okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -817,10 +818,10 @@ public ApiResponse loginUserWithHttpInfo(Object username, Object passwor 400 Invalid username/password supplied - */ - public okhttp3.Call loginUserAsync(Object username, Object password, final ApiCallback _callback) throws ApiException { + public okhttp3.Call loginUserAsync(String username, String password, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } @@ -946,7 +947,7 @@ public okhttp3.Call logoutUserAsync(final ApiCallback _callback) throws Ap 404 User not found - */ - public okhttp3.Call updateUserCall(Object username, User user, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updateUserCall(String username, User user, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -992,7 +993,7 @@ public okhttp3.Call updateUserCall(Object username, User user, final ApiCallback } @SuppressWarnings("rawtypes") - private okhttp3.Call updateUserValidateBeforeCall(Object username, User user, final ApiCallback _callback) throws ApiException { + private okhttp3.Call updateUserValidateBeforeCall(String username, User user, final ApiCallback _callback) throws ApiException { // verify the required parameter 'username' is set if (username == null) { throw new ApiException("Missing the required parameter 'username' when calling updateUser(Async)"); @@ -1020,7 +1021,7 @@ private okhttp3.Call updateUserValidateBeforeCall(Object username, User user, fi 404 User not found - */ - public void updateUser(Object username, User user) throws ApiException { + public void updateUser(String username, User user) throws ApiException { updateUserWithHttpInfo(username, user); } @@ -1038,7 +1039,7 @@ public void updateUser(Object username, User user) throws ApiException { 404 User not found - */ - public ApiResponse updateUserWithHttpInfo(Object username, User user) throws ApiException { + public ApiResponse updateUserWithHttpInfo(String username, User user) throws ApiException { okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, user, null); return localVarApiClient.execute(localVarCall); } @@ -1058,7 +1059,7 @@ public ApiResponse updateUserWithHttpInfo(Object username, User user) thro 404 User not found - */ - public okhttp3.Call updateUserAsync(Object username, User user, final ApiCallback _callback) throws ApiException { + public okhttp3.Call updateUserAsync(String username, User user, final ApiCallback _callback) throws ApiException { okhttp3.Call localVarCall = updateUserValidateBeforeCall(username, user, _callback); localVarApiClient.executeAsync(localVarCall, _callback); diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Animal.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Animal.java index 71422ece7907..ce03faf30dda 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Animal.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Animal.java @@ -21,7 +21,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -54,17 +53,17 @@ public class Animal { public static final String SERIALIZED_NAME_CLASS_NAME = "className"; @SerializedName(SERIALIZED_NAME_CLASS_NAME) - protected Object className = null; + protected String className; public static final String SERIALIZED_NAME_COLOR = "color"; @SerializedName(SERIALIZED_NAME_COLOR) - private Object color = red; + private String color = "red"; public Animal() { this.className = this.getClass().getSimpleName(); } - public Animal className(Object className) { + public Animal className(String className) { this.className = className; return this; @@ -74,18 +73,18 @@ public Animal className(Object className) { * Get className * @return className **/ - @javax.annotation.Nullable - public Object getClassName() { + @javax.annotation.Nonnull + public String getClassName() { return className; } - public void setClassName(Object className) { + public void setClassName(String className) { this.className = className; } - public Animal color(Object color) { + public Animal color(String color) { this.color = color; return this; @@ -96,12 +95,12 @@ public Animal color(Object color) { * @return color **/ @javax.annotation.Nullable - public Object getColor() { + public String getColor() { return color; } - public void setColor(Object color) { + public void setColor(String color) { this.color = color; } @@ -165,22 +164,11 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, animal.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable 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(className, color, additionalProperties); } - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -231,80 +219,19 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : Animal.openapiRequiredFields) { - if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); - } + String discriminatorValue = jsonElement.getAsJsonObject().get("className").getAsString(); + switch (discriminatorValue) { + case "Cat": + Cat.validateJsonElement(jsonElement); + break; + case "Dog": + Dog.validateJsonElement(jsonElement); + break; + default: + throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue)); } } - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Animal.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Animal' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter - = gson.getDelegateAdapter(this, TypeToken.get(Animal.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Animal value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - obj.remove("additionalProperties"); - // serialize additional properties - if (value.getAdditionalProperties() != null) { - for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { - if (entry.getValue() instanceof String) - obj.addProperty(entry.getKey(), (String) entry.getValue()); - else if (entry.getValue() instanceof Number) - obj.addProperty(entry.getKey(), (Number) entry.getValue()); - else if (entry.getValue() instanceof Boolean) - obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); - else if (entry.getValue() instanceof Character) - obj.addProperty(entry.getKey(), (Character) entry.getValue()); - else { - obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); - } - } - } - elementAdapter.write(out, obj); - } - - @Override - public Animal read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - Animal instance = thisAdapter.fromJsonTree(jsonObj); - for (Map.Entry entry : jsonObj.entrySet()) { - if (!openapiFields.contains(entry.getKey())) { - if (entry.getValue().isJsonPrimitive()) { // primitive type - if (entry.getValue().getAsJsonPrimitive().isString()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); - else if (entry.getValue().getAsJsonPrimitive().isNumber()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); - else if (entry.getValue().getAsJsonPrimitive().isBoolean()) - instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); - else - throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; - } - - }.nullSafe(); - } - } /** * Create an instance of Animal given an JSON string diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Category.java index 97fac31c5064..ec41d25fa99f 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Category.java @@ -21,7 +21,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -54,16 +53,16 @@ public class Category { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Object id = null; + private Long id; public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - private Object name = null; + private String name; public Category() { } - public Category id(Object id) { + public Category id(Long id) { this.id = id; return this; @@ -74,17 +73,17 @@ public Category id(Object id) { * @return id **/ @javax.annotation.Nullable - public Object getId() { + public Long getId() { return id; } - public void setId(Object id) { + public void setId(Long id) { this.id = id; } - public Category name(Object name) { + public Category name(String name) { this.name = name; return this; @@ -95,12 +94,12 @@ public Category name(Object name) { * @return name **/ @javax.annotation.Nullable - public Object getName() { + public String getName() { return name; } - public void setName(Object name) { + public void setName(String name) { this.name = name; } @@ -164,22 +163,11 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, category.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, name, additionalProperties); } - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -229,6 +217,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/ModelApiResponse.java index ba720365bc52..a1df10aece5f 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -21,7 +21,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -54,20 +53,20 @@ public class ModelApiResponse { public static final String SERIALIZED_NAME_CODE = "code"; @SerializedName(SERIALIZED_NAME_CODE) - private Object code = null; + private Integer code; public static final String SERIALIZED_NAME_TYPE = "type"; @SerializedName(SERIALIZED_NAME_TYPE) - private Object type = null; + private String type; public static final String SERIALIZED_NAME_MESSAGE = "message"; @SerializedName(SERIALIZED_NAME_MESSAGE) - private Object message = null; + private String message; public ModelApiResponse() { } - public ModelApiResponse code(Object code) { + public ModelApiResponse code(Integer code) { this.code = code; return this; @@ -78,17 +77,17 @@ public ModelApiResponse code(Object code) { * @return code **/ @javax.annotation.Nullable - public Object getCode() { + public Integer getCode() { return code; } - public void setCode(Object code) { + public void setCode(Integer code) { this.code = code; } - public ModelApiResponse type(Object type) { + public ModelApiResponse type(String type) { this.type = type; return this; @@ -99,17 +98,17 @@ public ModelApiResponse type(Object type) { * @return type **/ @javax.annotation.Nullable - public Object getType() { + public String getType() { return type; } - public void setType(Object type) { + public void setType(String type) { this.type = type; } - public ModelApiResponse message(Object message) { + public ModelApiResponse message(String message) { this.message = message; return this; @@ -120,12 +119,12 @@ public ModelApiResponse message(Object message) { * @return message **/ @javax.annotation.Nullable - public Object getMessage() { + public String getMessage() { return message; } - public void setMessage(Object message) { + public void setMessage(String message) { this.message = message; } @@ -190,22 +189,11 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, _apiResponse.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable 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(code, type, message, additionalProperties); } - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -257,6 +245,12 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java index d96a4113d96a..ae66537b4824 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java @@ -20,8 +20,8 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; +import java.time.OffsetDateTime; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -54,19 +54,19 @@ public class Order { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Object id = null; + private Long id; public static final String SERIALIZED_NAME_PET_ID = "petId"; @SerializedName(SERIALIZED_NAME_PET_ID) - private Object petId = null; + private Long petId; public static final String SERIALIZED_NAME_QUANTITY = "quantity"; @SerializedName(SERIALIZED_NAME_QUANTITY) - private Object quantity = null; + private Integer quantity; public static final String SERIALIZED_NAME_SHIP_DATE = "shipDate"; @SerializedName(SERIALIZED_NAME_SHIP_DATE) - private Object shipDate = null; + private OffsetDateTime shipDate; /** * Order Status @@ -79,13 +79,13 @@ public enum StatusEnum { DELIVERED("delivered"); - private Object value; + private String value; - StatusEnum(Object value) { + StatusEnum(String value) { this.value = value; } - public Object getValue() { + public String getValue() { return value; } @@ -94,13 +94,13 @@ public String toString() { return String.valueOf(value); } - public static StatusEnum fromValue(Object value) { + public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } public static class Adapter extends TypeAdapter { @@ -111,7 +111,7 @@ public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) thr @Override public StatusEnum read(final JsonReader jsonReader) throws IOException { - Object value = jsonReader.nextObject(); + String value = jsonReader.nextString(); return StatusEnum.fromValue(value); } } @@ -119,16 +119,16 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { public static final String SERIALIZED_NAME_STATUS = "status"; @SerializedName(SERIALIZED_NAME_STATUS) - private StatusEnum status = null; + private StatusEnum status; public static final String SERIALIZED_NAME_COMPLETE = "complete"; @SerializedName(SERIALIZED_NAME_COMPLETE) - private Object complete = false; + private Boolean complete = false; public Order() { } - public Order id(Object id) { + public Order id(Long id) { this.id = id; return this; @@ -139,17 +139,17 @@ public Order id(Object id) { * @return id **/ @javax.annotation.Nullable - public Object getId() { + public Long getId() { return id; } - public void setId(Object id) { + public void setId(Long id) { this.id = id; } - public Order petId(Object petId) { + public Order petId(Long petId) { this.petId = petId; return this; @@ -160,17 +160,17 @@ public Order petId(Object petId) { * @return petId **/ @javax.annotation.Nullable - public Object getPetId() { + public Long getPetId() { return petId; } - public void setPetId(Object petId) { + public void setPetId(Long petId) { this.petId = petId; } - public Order quantity(Object quantity) { + public Order quantity(Integer quantity) { this.quantity = quantity; return this; @@ -181,17 +181,17 @@ public Order quantity(Object quantity) { * @return quantity **/ @javax.annotation.Nullable - public Object getQuantity() { + public Integer getQuantity() { return quantity; } - public void setQuantity(Object quantity) { + public void setQuantity(Integer quantity) { this.quantity = quantity; } - public Order shipDate(Object shipDate) { + public Order shipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; return this; @@ -202,12 +202,12 @@ public Order shipDate(Object shipDate) { * @return shipDate **/ @javax.annotation.Nullable - public Object getShipDate() { + public OffsetDateTime getShipDate() { return shipDate; } - public void setShipDate(Object shipDate) { + public void setShipDate(OffsetDateTime shipDate) { this.shipDate = shipDate; } @@ -233,7 +233,7 @@ public void setStatus(StatusEnum status) { } - public Order complete(Object complete) { + public Order complete(Boolean complete) { this.complete = complete; return this; @@ -244,12 +244,12 @@ public Order complete(Object complete) { * @return complete **/ @javax.annotation.Nullable - public Object getComplete() { + public Boolean getComplete() { return complete; } - public void setComplete(Object complete) { + public void setComplete(Boolean complete) { this.complete = complete; } @@ -317,22 +317,11 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, order.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, petId, quantity, shipDate, status, complete, additionalProperties); } - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -390,6 +379,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java index 85784bbe1a7c..69cec0b898e2 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java @@ -20,9 +20,11 @@ import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import org.openapitools.client.model.Category; -import org.openapitools.jackson.nullable.JsonNullable; +import org.openapitools.client.model.Tag; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -55,7 +57,7 @@ public class Pet { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Object id = null; + private Long id; public static final String SERIALIZED_NAME_CATEGORY = "category"; @SerializedName(SERIALIZED_NAME_CATEGORY) @@ -63,15 +65,15 @@ public class Pet { public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - private Object name = null; + private String name; public static final String SERIALIZED_NAME_PHOTO_URLS = "photoUrls"; @SerializedName(SERIALIZED_NAME_PHOTO_URLS) - private Object photoUrls = null; + private List photoUrls = new ArrayList<>(); public static final String SERIALIZED_NAME_TAGS = "tags"; @SerializedName(SERIALIZED_NAME_TAGS) - private Object tags = null; + private List tags; /** * pet status in the store @@ -84,13 +86,13 @@ public enum StatusEnum { SOLD("sold"); - private Object value; + private String value; - StatusEnum(Object value) { + StatusEnum(String value) { this.value = value; } - public Object getValue() { + public String getValue() { return value; } @@ -99,13 +101,13 @@ public String toString() { return String.valueOf(value); } - public static StatusEnum fromValue(Object value) { + public static StatusEnum fromValue(String value) { for (StatusEnum b : StatusEnum.values()) { if (b.value.equals(value)) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + value + "'"); } public static class Adapter extends TypeAdapter { @@ -116,7 +118,7 @@ public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) thr @Override public StatusEnum read(final JsonReader jsonReader) throws IOException { - Object value = jsonReader.nextObject(); + String value = jsonReader.nextString(); return StatusEnum.fromValue(value); } } @@ -125,12 +127,12 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { public static final String SERIALIZED_NAME_STATUS = "status"; @Deprecated @SerializedName(SERIALIZED_NAME_STATUS) - private StatusEnum status = null; + private StatusEnum status; public Pet() { } - public Pet id(Object id) { + public Pet id(Long id) { this.id = id; return this; @@ -141,12 +143,12 @@ public Pet id(Object id) { * @return id **/ @javax.annotation.Nullable - public Object getId() { + public Long getId() { return id; } - public void setId(Object id) { + public void setId(Long id) { this.id = id; } @@ -172,7 +174,7 @@ public void setCategory(Category category) { } - public Pet name(Object name) { + public Pet name(String name) { this.name = name; return this; @@ -182,55 +184,71 @@ public Pet name(Object name) { * Get name * @return name **/ - @javax.annotation.Nullable - public Object getName() { + @javax.annotation.Nonnull + public String getName() { return name; } - public void setName(Object name) { + public void setName(String name) { this.name = name; } - public Pet photoUrls(Object photoUrls) { + public Pet photoUrls(List photoUrls) { this.photoUrls = photoUrls; return this; } + public Pet addPhotoUrlsItem(String photoUrlsItem) { + if (this.photoUrls == null) { + this.photoUrls = new ArrayList<>(); + } + this.photoUrls.add(photoUrlsItem); + return this; + } + /** * Get photoUrls * @return photoUrls **/ - @javax.annotation.Nullable - public Object getPhotoUrls() { + @javax.annotation.Nonnull + public List getPhotoUrls() { return photoUrls; } - public void setPhotoUrls(Object photoUrls) { + public void setPhotoUrls(List photoUrls) { this.photoUrls = photoUrls; } - public Pet tags(Object tags) { + public Pet tags(List tags) { this.tags = tags; return this; } + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + /** * Get tags * @return tags **/ @javax.annotation.Nullable - public Object getTags() { + public List getTags() { return tags; } - public void setTags(Object tags) { + public void setTags(List tags) { this.tags = tags; } @@ -323,22 +341,11 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, pet.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, category, name, photoUrls, tags, status, additionalProperties); } - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -409,6 +416,32 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) { Category.validateJsonElement(jsonObj.get("category")); } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // ensure the required json array is present + if (jsonObj.get("photoUrls") == null) { + throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); + } else if (!jsonObj.get("photoUrls").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `photoUrls` to be an array in the JSON string but got `%s`", jsonObj.get("photoUrls").toString())); + } + if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull()) { + JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags"); + if (jsonArraytags != null) { + // ensure the json data is an array + if (!jsonObj.get("tags").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } + + // validate the optional field `tags` (array) + for (int i = 0; i < jsonArraytags.size(); i++) { + Tag.validateJsonElement(jsonArraytags.get(i)); + }; + } + } + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Tag.java index 24955509692e..262ef93dbbd3 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Tag.java @@ -21,7 +21,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -54,16 +53,16 @@ public class Tag { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Object id = null; + private Long id; public static final String SERIALIZED_NAME_NAME = "name"; @SerializedName(SERIALIZED_NAME_NAME) - private Object name = null; + private String name; public Tag() { } - public Tag id(Object id) { + public Tag id(Long id) { this.id = id; return this; @@ -74,17 +73,17 @@ public Tag id(Object id) { * @return id **/ @javax.annotation.Nullable - public Object getId() { + public Long getId() { return id; } - public void setId(Object id) { + public void setId(Long id) { this.id = id; } - public Tag name(Object name) { + public Tag name(String name) { this.name = name; return this; @@ -95,12 +94,12 @@ public Tag name(Object name) { * @return name **/ @javax.annotation.Nullable - public Object getName() { + public String getName() { return name; } - public void setName(Object name) { + public void setName(String name) { this.name = name; } @@ -164,22 +163,11 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, tag.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, name, additionalProperties); } - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -229,6 +217,9 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/User.java index f1a34cee0c97..8c1f31e4d16a 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/User.java @@ -21,7 +21,6 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; -import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -54,40 +53,40 @@ public class User { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) - private Object id = null; + private Long id; public static final String SERIALIZED_NAME_USERNAME = "username"; @SerializedName(SERIALIZED_NAME_USERNAME) - private Object username = null; + private String username; public static final String SERIALIZED_NAME_FIRST_NAME = "firstName"; @SerializedName(SERIALIZED_NAME_FIRST_NAME) - private Object firstName = null; + private String firstName; public static final String SERIALIZED_NAME_LAST_NAME = "lastName"; @SerializedName(SERIALIZED_NAME_LAST_NAME) - private Object lastName = null; + private String lastName; public static final String SERIALIZED_NAME_EMAIL = "email"; @SerializedName(SERIALIZED_NAME_EMAIL) - private Object email = null; + private String email; public static final String SERIALIZED_NAME_PASSWORD = "password"; @SerializedName(SERIALIZED_NAME_PASSWORD) - private Object password = null; + private String password; public static final String SERIALIZED_NAME_PHONE = "phone"; @SerializedName(SERIALIZED_NAME_PHONE) - private Object phone = null; + private String phone; public static final String SERIALIZED_NAME_USER_STATUS = "userStatus"; @SerializedName(SERIALIZED_NAME_USER_STATUS) - private Object userStatus = null; + private Integer userStatus; public User() { } - public User id(Object id) { + public User id(Long id) { this.id = id; return this; @@ -98,17 +97,17 @@ public User id(Object id) { * @return id **/ @javax.annotation.Nullable - public Object getId() { + public Long getId() { return id; } - public void setId(Object id) { + public void setId(Long id) { this.id = id; } - public User username(Object username) { + public User username(String username) { this.username = username; return this; @@ -119,17 +118,17 @@ public User username(Object username) { * @return username **/ @javax.annotation.Nullable - public Object getUsername() { + public String getUsername() { return username; } - public void setUsername(Object username) { + public void setUsername(String username) { this.username = username; } - public User firstName(Object firstName) { + public User firstName(String firstName) { this.firstName = firstName; return this; @@ -140,17 +139,17 @@ public User firstName(Object firstName) { * @return firstName **/ @javax.annotation.Nullable - public Object getFirstName() { + public String getFirstName() { return firstName; } - public void setFirstName(Object firstName) { + public void setFirstName(String firstName) { this.firstName = firstName; } - public User lastName(Object lastName) { + public User lastName(String lastName) { this.lastName = lastName; return this; @@ -161,17 +160,17 @@ public User lastName(Object lastName) { * @return lastName **/ @javax.annotation.Nullable - public Object getLastName() { + public String getLastName() { return lastName; } - public void setLastName(Object lastName) { + public void setLastName(String lastName) { this.lastName = lastName; } - public User email(Object email) { + public User email(String email) { this.email = email; return this; @@ -182,17 +181,17 @@ public User email(Object email) { * @return email **/ @javax.annotation.Nullable - public Object getEmail() { + public String getEmail() { return email; } - public void setEmail(Object email) { + public void setEmail(String email) { this.email = email; } - public User password(Object password) { + public User password(String password) { this.password = password; return this; @@ -203,17 +202,17 @@ public User password(Object password) { * @return password **/ @javax.annotation.Nullable - public Object getPassword() { + public String getPassword() { return password; } - public void setPassword(Object password) { + public void setPassword(String password) { this.password = password; } - public User phone(Object phone) { + public User phone(String phone) { this.phone = phone; return this; @@ -224,17 +223,17 @@ public User phone(Object phone) { * @return phone **/ @javax.annotation.Nullable - public Object getPhone() { + public String getPhone() { return phone; } - public void setPhone(Object phone) { + public void setPhone(String phone) { this.phone = phone; } - public User userStatus(Object userStatus) { + public User userStatus(Integer userStatus) { this.userStatus = userStatus; return this; @@ -245,12 +244,12 @@ public User userStatus(Object userStatus) { * @return userStatus **/ @javax.annotation.Nullable - public Object getUserStatus() { + public Integer getUserStatus() { return userStatus; } - public void setUserStatus(Object userStatus) { + public void setUserStatus(Integer userStatus) { this.userStatus = userStatus; } @@ -320,22 +319,11 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, user.additionalProperties); } - private static boolean equalsNullable(JsonNullable a, JsonNullable 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(id, username, firstName, lastName, email, password, phone, userStatus, additionalProperties); } - private static int hashCodeNullable(JsonNullable a) { - if (a == null) { - return 1; - } - return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -397,6 +385,24 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + if ((jsonObj.get("firstName") != null && !jsonObj.get("firstName").isJsonNull()) && !jsonObj.get("firstName").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `firstName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("firstName").toString())); + } + if ((jsonObj.get("lastName") != null && !jsonObj.get("lastName").isJsonNull()) && !jsonObj.get("lastName").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `lastName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastName").toString())); + } + if ((jsonObj.get("email") != null && !jsonObj.get("email").isJsonNull()) && !jsonObj.get("email").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString())); + } + if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); + } + if ((jsonObj.get("phone") != null && !jsonObj.get("phone").isJsonNull()) && !jsonObj.get("phone").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `phone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("phone").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/lua/petstore/model/user.lua b/samples/client/petstore/lua/petstore/model/user.lua index ae0b97969d14..16f984685718 100644 --- a/samples/client/petstore/lua/petstore/model/user.lua +++ b/samples/client/petstore/lua/petstore/model/user.lua @@ -19,7 +19,7 @@ local function cast_user(t) return setmetatable(t, user_mt) end -local function new_user(id, username, first_name, last_name, email, password, phone, user_status) +local function new_user(id, username, first_name, last_name, email, password, mobile, user_status) return cast_user({ ["id"] = id; ["username"] = username; @@ -27,7 +27,7 @@ local function new_user(id, username, first_name, last_name, email, password, ph ["lastName"] = last_name; ["email"] = email; ["password"] = password; - ["phone"] = phone; + ["phone"] = mobile; ["userStatus"] = user_status; }) end diff --git a/samples/client/petstore/perl/.openapi-generator/FILES b/samples/client/petstore/perl/.openapi-generator/FILES index 6eb6311e98c7..d6a142a834bb 100644 --- a/samples/client/petstore/perl/.openapi-generator/FILES +++ b/samples/client/petstore/perl/.openapi-generator/FILES @@ -17,7 +17,7 @@ docs/ChildWithNullable.md docs/ClassModel.md docs/Client.md docs/DefaultApi.md -docs/DeprecatedObject.md +docs/DeprecatedModel.md docs/Dog.md docs/EnumArrays.md docs/EnumClass.md @@ -79,7 +79,7 @@ lib/WWW/OpenAPIClient/Object/Category.pm lib/WWW/OpenAPIClient/Object/ChildWithNullable.pm lib/WWW/OpenAPIClient/Object/ClassModel.pm lib/WWW/OpenAPIClient/Object/Client.pm -lib/WWW/OpenAPIClient/Object/DeprecatedObject.pm +lib/WWW/OpenAPIClient/Object/DeprecatedModel.pm lib/WWW/OpenAPIClient/Object/Dog.pm lib/WWW/OpenAPIClient/Object/EnumArrays.pm lib/WWW/OpenAPIClient/Object/EnumClass.pm diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index ca0ebd7ba0ed..affa55c61941 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -255,7 +255,7 @@ use WWW::OpenAPIClient::Object::Category; use WWW::OpenAPIClient::Object::ChildWithNullable; use WWW::OpenAPIClient::Object::ClassModel; use WWW::OpenAPIClient::Object::Client; -use WWW::OpenAPIClient::Object::DeprecatedObject; +use WWW::OpenAPIClient::Object::DeprecatedModel; use WWW::OpenAPIClient::Object::Dog; use WWW::OpenAPIClient::Object::EnumArrays; use WWW::OpenAPIClient::Object::EnumClass; @@ -324,7 +324,7 @@ use WWW::OpenAPIClient::Object::Category; use WWW::OpenAPIClient::Object::ChildWithNullable; use WWW::OpenAPIClient::Object::ClassModel; use WWW::OpenAPIClient::Object::Client; -use WWW::OpenAPIClient::Object::DeprecatedObject; +use WWW::OpenAPIClient::Object::DeprecatedModel; use WWW::OpenAPIClient::Object::Dog; use WWW::OpenAPIClient::Object::EnumArrays; use WWW::OpenAPIClient::Object::EnumClass; @@ -445,7 +445,7 @@ Class | Method | HTTP request | Description - [WWW::OpenAPIClient::Object::ChildWithNullable](docs/ChildWithNullable.md) - [WWW::OpenAPIClient::Object::ClassModel](docs/ClassModel.md) - [WWW::OpenAPIClient::Object::Client](docs/Client.md) - - [WWW::OpenAPIClient::Object::DeprecatedObject](docs/DeprecatedObject.md) + - [WWW::OpenAPIClient::Object::DeprecatedModel](docs/DeprecatedModel.md) - [WWW::OpenAPIClient::Object::Dog](docs/Dog.md) - [WWW::OpenAPIClient::Object::EnumArrays](docs/EnumArrays.md) - [WWW::OpenAPIClient::Object::EnumClass](docs/EnumClass.md) diff --git a/samples/client/petstore/perl/docs/HealthCheckResult.md b/samples/client/petstore/perl/docs/HealthCheckResult.md index 5f0c43d5f3d4..6f004a50428b 100644 --- a/samples/client/petstore/perl/docs/HealthCheckResult.md +++ b/samples/client/petstore/perl/docs/HealthCheckResult.md @@ -8,7 +8,7 @@ use WWW::OpenAPIClient::Object::HealthCheckResult; ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**nullable_message** | **string** | | [optional] +**system_message** | **string** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/perl/docs/ObjectWithDeprecatedFields.md b/samples/client/petstore/perl/docs/ObjectWithDeprecatedFields.md index 311d746a4159..8caeb8c34e29 100644 --- a/samples/client/petstore/perl/docs/ObjectWithDeprecatedFields.md +++ b/samples/client/petstore/perl/docs/ObjectWithDeprecatedFields.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **uuid** | **string** | | [optional] **id** | **double** | | [optional] -**deprecated_ref** | [**DeprecatedObject**](DeprecatedObject.md) | | [optional] +**deprecated_ref** | [**DeprecatedModel**](DeprecatedModel.md) | | [optional] **bars** | **ARRAY[string]** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/HealthCheckResult.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/HealthCheckResult.pm index 8d95f2044467..000598c457cd 100644 --- a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/HealthCheckResult.pm +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/HealthCheckResult.pm @@ -219,7 +219,7 @@ __PACKAGE__->class_documentation({description => 'Just a string to inform instan } ); __PACKAGE__->method_documentation({ - 'nullable_message' => { + 'system_message' => { datatype => 'string', base_name => 'NullableMessage', description => '', @@ -229,11 +229,11 @@ __PACKAGE__->method_documentation({ }); __PACKAGE__->openapi_types( { - 'nullable_message' => 'string' + 'system_message' => 'string' } ); __PACKAGE__->attribute_map( { - 'nullable_message' => 'NullableMessage' + 'system_message' => 'NullableMessage' } ); __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); diff --git a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ObjectWithDeprecatedFields.pm b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ObjectWithDeprecatedFields.pm index ce18bf6cb6a6..61918ae1d1d1 100644 --- a/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ObjectWithDeprecatedFields.pm +++ b/samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/ObjectWithDeprecatedFields.pm @@ -30,7 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; -use WWW::OpenAPIClient::Object::DeprecatedObject; +use WWW::OpenAPIClient::Object::DeprecatedModel; use base ("Class::Accessor", "Class::Data::Inheritable"); @@ -235,7 +235,7 @@ __PACKAGE__->method_documentation({ read_only => '', }, 'deprecated_ref' => { - datatype => 'DeprecatedObject', + datatype => 'DeprecatedModel', base_name => 'deprecatedRef', description => '', format => '', @@ -253,7 +253,7 @@ __PACKAGE__->method_documentation({ __PACKAGE__->openapi_types( { 'uuid' => 'string', 'id' => 'double', - 'deprecated_ref' => 'DeprecatedObject', + 'deprecated_ref' => 'DeprecatedModel', 'bars' => 'ARRAY[string]' } ); diff --git a/samples/client/petstore/powershell/.openapi-generator/FILES b/samples/client/petstore/powershell/.openapi-generator/FILES index 92a65ac907d5..7e8383cf879a 100644 --- a/samples/client/petstore/powershell/.openapi-generator/FILES +++ b/samples/client/petstore/powershell/.openapi-generator/FILES @@ -130,9 +130,9 @@ src/PSPetstore/Model/Mammal.ps1 src/PSPetstore/Model/MapTest.ps1 src/PSPetstore/Model/MixedPropertiesAndAdditionalPropertiesClass.ps1 src/PSPetstore/Model/Model200Response.ps1 -src/PSPetstore/Model/ModelMapping.ps1 src/PSPetstore/Model/ModelReturn.ps1 src/PSPetstore/Model/Name.ps1 +src/PSPetstore/Model/NewModel.ps1 src/PSPetstore/Model/NullableClass.ps1 src/PSPetstore/Model/NullableShape.ps1 src/PSPetstore/Model/NumberOnly.ps1 diff --git a/samples/client/petstore/powershell/README.md b/samples/client/petstore/powershell/README.md index 85badaa315fb..30b0f1454eeb 100644 --- a/samples/client/petstore/powershell/README.md +++ b/samples/client/petstore/powershell/README.md @@ -139,9 +139,9 @@ Class | Method | HTTP request | Description - [PSPetstore\Model.MapTest](docs/MapTest.md) - [PSPetstore\Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [PSPetstore\Model.Model200Response](docs/Model200Response.md) - - [PSPetstore\Model.ModelMapping](docs/ModelMapping.md) - [PSPetstore\Model.ModelReturn](docs/ModelReturn.md) - [PSPetstore\Model.Name](docs/Name.md) + - [PSPetstore\Model.NewModel](docs/NewModel.md) - [PSPetstore\Model.NullableClass](docs/NullableClass.md) - [PSPetstore\Model.NullableShape](docs/NullableShape.md) - [PSPetstore\Model.NumberOnly](docs/NumberOnly.md) diff --git a/samples/client/petstore/powershell/docs/ModelMapping.md b/samples/client/petstore/powershell/docs/ModelMapping.md index 0e23f1563869..399b227c2aeb 100644 --- a/samples/client/petstore/powershell/docs/ModelMapping.md +++ b/samples/client/petstore/powershell/docs/ModelMapping.md @@ -1,4 +1,4 @@ -# ModelMapping +# NewModel ## Properties Name | Type | Description | Notes @@ -9,12 +9,12 @@ Name | Type | Description | Notes - Prepare the resource ```powershell -$ModelMapping = Initialize-PSPetstoreModelMapping -Name null +$NewModel = Initialize-PSPetstoreNewModel -Name null ``` - Convert the resource to JSON ```powershell -$ModelMapping | ConvertTo-JSON +$NewModel | ConvertTo-JSON ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/powershell/docs/ObjectWithDeprecatedFields.md b/samples/client/petstore/powershell/docs/ObjectWithDeprecatedFields.md index fe8f3853fd17..d9a9570fa6f4 100644 --- a/samples/client/petstore/powershell/docs/ObjectWithDeprecatedFields.md +++ b/samples/client/petstore/powershell/docs/ObjectWithDeprecatedFields.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **Id** | **Decimal** | | [optional] **DeprecatedRef** | [**DeprecatedObject**](DeprecatedObject.md) | | [optional] **Bars** | **String[]** | | [optional] -**NameMapping** | **String** | | [optional] +**SomethingElse** | **String** | | [optional] ## Examples @@ -17,7 +17,7 @@ $ObjectWithDeprecatedFields = Initialize-PSPetstoreObjectWithDeprecatedFields - -Id null ` -DeprecatedRef null ` -Bars null ` - -NameMapping null + -SomethingElse null ``` - Convert the resource to JSON diff --git a/samples/client/petstore/powershell/src/PSPetstore/Model/ObjectWithDeprecatedFields.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Model/ObjectWithDeprecatedFields.ps1 index 743e7e5a37be..0651b4e55daf 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Model/ObjectWithDeprecatedFields.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Model/ObjectWithDeprecatedFields.ps1 @@ -22,7 +22,7 @@ No description available. No description available. .PARAMETER Bars No description available. -.PARAMETER NameMapping +.PARAMETER SomethingElse No description available. .OUTPUTS @@ -46,7 +46,7 @@ function Initialize-PSObjectWithDeprecatedFields { ${Bars}, [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)] [String] - ${NameMapping} + ${SomethingElse} ) Process { @@ -59,7 +59,7 @@ function Initialize-PSObjectWithDeprecatedFields { "id" = ${Id} "deprecatedRef" = ${DeprecatedRef} "bars" = ${Bars} - "name_mapping" = ${NameMapping} + "name_mapping" = ${SomethingElse} } @@ -129,9 +129,9 @@ function ConvertFrom-PSJsonToObjectWithDeprecatedFields { } if (!([bool]($JsonParameters.PSobject.Properties.name -match "name_mapping"))) { #optional property not found - $NameMapping = $null + $SomethingElse = $null } else { - $NameMapping = $JsonParameters.PSobject.Properties["name_mapping"].value + $SomethingElse = $JsonParameters.PSobject.Properties["name_mapping"].value } $PSO = [PSCustomObject]@{ @@ -139,7 +139,7 @@ function ConvertFrom-PSJsonToObjectWithDeprecatedFields { "id" = ${Id} "deprecatedRef" = ${DeprecatedRef} "bars" = ${Bars} - "name_mapping" = ${NameMapping} + "name_mapping" = ${SomethingElse} } return $PSO diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py index 6b7ed5dde57e..140dcf434609 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py @@ -19,6 +19,7 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable +from typing_extensions import Annotated from pydantic import Field from petstore_api.models.client import Client diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py index eb966cc1286d..3c0ef29b788f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py @@ -19,6 +19,7 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable +from typing_extensions import Annotated from datetime import date, datetime from pydantic import Field, StrictBool, StrictBytes, StrictInt, StrictStr, conbytes, confloat, conint, conlist, constr, validator diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py index c96013003e5b..6b9c88c1212f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py @@ -19,6 +19,7 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable +from typing_extensions import Annotated from pydantic import Field from petstore_api.models.client import Client diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py index f9a43cba02a3..72e29e7d0429 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py @@ -19,6 +19,7 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable +from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictInt, StrictStr, conlist, validator from typing import List, Optional, Union diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py index 7c8220e8ae08..e52b31ee5e13 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py @@ -19,6 +19,7 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable +from typing_extensions import Annotated from pydantic import Field, StrictStr, conint from typing import Dict diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index 3236bfd06ce4..3c059d73339f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -19,6 +19,7 @@ from pydantic import validate_arguments, ValidationError from typing import overload, Optional, Union, Awaitable +from typing_extensions import Annotated from pydantic import Field, StrictStr, conlist from petstore_api.models.user import User diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py index fd4cd25f4cab..c8ae8d0af133 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py @@ -18,6 +18,7 @@ from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from pydantic import Field from petstore_api.models.client import Client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 73f759675320..1bdbf4e06a91 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -18,6 +18,7 @@ from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from datetime import date, datetime from pydantic import Field, StrictBool, StrictBytes, StrictFloat, StrictInt, StrictStr, conbytes, confloat, conint, conlist, constr, validator diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py index ddbfc8fc082d..acfe8c01a94f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py @@ -18,6 +18,7 @@ from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from pydantic import Field from petstore_api.models.client import Client diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py index 8799ae2cb27f..f0eefd7ec890 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py @@ -18,6 +18,7 @@ from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictInt, StrictStr, conlist, validator from typing import List, Optional, Union diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index ace73770b75a..b5b845531fe6 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -18,6 +18,7 @@ from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from pydantic import Field, StrictStr, conint from typing import Dict diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index 7738ee78a689..240a692ebcad 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -18,6 +18,7 @@ from pydantic import validate_arguments, ValidationError +from typing_extensions import Annotated from pydantic import Field, StrictStr, conlist from petstore_api.models.user import User diff --git a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java index 07dcef91798a..0f7d2a1f6f64 100644 --- a/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/java-camel/src/main/java/org/openapitools/model/Pet.java @@ -91,6 +91,7 @@ public static StatusEnum fromValue(String value) { } @JacksonXmlProperty(localName = "status") + @Deprecated private StatusEnum status; public Pet() { @@ -229,14 +230,20 @@ public Pet status(StatusEnum status) { /** * pet status in the store * @return status + * @deprecated */ - @Schema(name = "status", description = "pet status in the store", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @Schema(name = "status", description = "pet status in the store", deprecated = true, requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty("status") + @Deprecated public StatusEnum getStatus() { return status; } + /** + * @deprecated + */ + @Deprecated public void setStatus(StatusEnum status) { this.status = status; }