diff --git a/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache index f875240996b3..be273444d7ff 100644 --- a/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache +++ b/modules/openapi-generator/src/main/resources/Java/modelInnerEnum.mustache @@ -23,7 +23,7 @@ {{#withXml}} @XmlEnumValue({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) {{/withXml}} - {{{name}}}({{^isUri}}{{dataType}}.valueOf({{/isUri}}{{{value}}}{{^isUri}}){{/isUri}}){{^-last}}, + {{{name}}}({{^isUri}}{{^isString}}{{dataType}}.valueOf({{/isString}}{{/isUri}}{{{value}}}{{^isUri}}{{^isString}}){{/isString}}{{/isUri}}){{^-last}}, {{/-last}}{{#-last}};{{/-last}} {{/enumVars}} {{/allowableValues}} diff --git a/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/model/Example.java b/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/model/Example.java index 7fd556601601..9b95d1727dad 100644 --- a/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/model/Example.java +++ b/samples/client/others/java/jersey2-oneOf-Mixed/src/main/java/org/openapitools/client/model/Example.java @@ -216,9 +216,9 @@ public UUID getUUID() throws ClassCastException { * @return The actual instance of `List` * @throws ClassCastException if the instance is not `List` */ - public List getListInteger() throws ClassCastException { + public List getListInteger() throws ClassCastException { return (List)super.getActualInstance(); - } + } } diff --git a/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/model/Example.java b/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/model/Example.java index d39111ccdfc5..41dd5ceb236c 100644 --- a/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/model/Example.java +++ b/samples/client/others/java/jersey2-oneOf-duplicates/src/main/java/org/openapitools/client/model/Example.java @@ -196,9 +196,9 @@ public Object getActualInstance() { * @return The actual instance of `List` * @throws ClassCastException if the instance is not `List` */ - public List getListBigDecimal() throws ClassCastException { + public List getListBigDecimal() throws ClassCastException { return (List)super.getActualInstance(); - } + } /** * Get the actual instance of `List`. If the actual instance is not `List`, @@ -207,9 +207,9 @@ public List getListBigDecimal() throws ClassCastException { * @return The actual instance of `List` * @throws ClassCastException if the instance is not `List` */ - public List getListInteger() throws ClassCastException { + public List getListInteger() throws ClassCastException { return (List)super.getActualInstance(); - } + } } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java index 5fe70b9e5c67..e8072d8bb994 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java @@ -134,9 +134,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -172,9 +172,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java index 31e3f8199f3e..67e9d965ce63 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java @@ -122,9 +122,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -160,9 +160,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/EnumTest.java index 6636e85935ae..ed799eff97a7 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/EnumTest.java @@ -131,9 +131,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -169,9 +169,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/EnumTest.java index 726fcf37f13d..6c368f4ff4fa 100644 --- a/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/google-api-client/src/main/java/org/openapitools/client/model/EnumTest.java @@ -121,9 +121,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -159,9 +159,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/EnumTest.java index f25d2337822c..0b77156a55e4 100644 --- a/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/jersey2-java8-localdatetime/src/main/java/org/openapitools/client/model/EnumTest.java @@ -124,9 +124,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -162,9 +162,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java index f25d2337822c..0b77156a55e4 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java @@ -124,9 +124,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -162,9 +162,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/jersey3/.openapi-generator/FILES b/samples/client/petstore/java/jersey3/.openapi-generator/FILES index 78d8fe209b3a..01fa6e215e48 100644 --- a/samples/client/petstore/java/jersey3/.openapi-generator/FILES +++ b/samples/client/petstore/java/jersey3/.openapi-generator/FILES @@ -8,6 +8,12 @@ build.sbt docs/AdditionalPropertiesClass.md docs/Animal.md docs/AnotherFakeApi.md +docs/AnyOf1.md +docs/AnyOf2.md +docs/AnyofArray200Response.md +docs/AnyofArrayOneOfParamParameter.md +docs/AnyofArrayRequest.md +docs/AnyofArrayRequestMapProp.md docs/Apple.md docs/AppleReq.md docs/ArrayOfArrayOfNumberOnly.md @@ -124,6 +130,12 @@ src/main/java/org/openapitools/client/auth/OAuthFlow.java src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java src/main/java/org/openapitools/client/model/Animal.java +src/main/java/org/openapitools/client/model/AnyOf1.java +src/main/java/org/openapitools/client/model/AnyOf2.java +src/main/java/org/openapitools/client/model/AnyofArray200Response.java +src/main/java/org/openapitools/client/model/AnyofArrayOneOfParamParameter.java +src/main/java/org/openapitools/client/model/AnyofArrayRequest.java +src/main/java/org/openapitools/client/model/AnyofArrayRequestMapProp.java src/main/java/org/openapitools/client/model/Apple.java src/main/java/org/openapitools/client/model/AppleReq.java src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java @@ -197,3 +209,9 @@ src/main/java/org/openapitools/client/model/TriangleInterface.java src/main/java/org/openapitools/client/model/User.java src/main/java/org/openapitools/client/model/Whale.java src/main/java/org/openapitools/client/model/Zebra.java +src/test/java/org/openapitools/client/model/AnyOf1Test.java +src/test/java/org/openapitools/client/model/AnyOf2Test.java +src/test/java/org/openapitools/client/model/AnyofArray200ResponseTest.java +src/test/java/org/openapitools/client/model/AnyofArrayOneOfParamParameterTest.java +src/test/java/org/openapitools/client/model/AnyofArrayRequestMapPropTest.java +src/test/java/org/openapitools/client/model/AnyofArrayRequestTest.java diff --git a/samples/client/petstore/java/jersey3/README.md b/samples/client/petstore/java/jersey3/README.md index b74b4ea9a07e..d58e7f9c7a2d 100644 --- a/samples/client/petstore/java/jersey3/README.md +++ b/samples/client/petstore/java/jersey3/README.md @@ -117,6 +117,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags *DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooGet) | **GET** /foo | +*FakeApi* | [**anyofArray**](docs/FakeApi.md#anyofArray) | **POST** /anyof-array | *FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint *FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | *FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | @@ -164,6 +165,12 @@ Class | Method | HTTP request | Description - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) - [Animal](docs/Animal.md) + - [AnyOf1](docs/AnyOf1.md) + - [AnyOf2](docs/AnyOf2.md) + - [AnyofArray200Response](docs/AnyofArray200Response.md) + - [AnyofArrayOneOfParamParameter](docs/AnyofArrayOneOfParamParameter.md) + - [AnyofArrayRequest](docs/AnyofArrayRequest.md) + - [AnyofArrayRequestMapProp](docs/AnyofArrayRequestMapProp.md) - [Apple](docs/Apple.md) - [AppleReq](docs/AppleReq.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) diff --git a/samples/client/petstore/java/jersey3/api/openapi.yaml b/samples/client/petstore/java/jersey3/api/openapi.yaml index 25e78fa9e305..e71f7f21ec54 100644 --- a/samples/client/petstore/java/jersey3/api/openapi.yaml +++ b/samples/client/petstore/java/jersey3/api/openapi.yaml @@ -1177,6 +1177,37 @@ paths: - fake x-accepts: - application/json + /anyof-array: + post: + description: Response with anyof containing arrays and a oneof parameter as + well as a map request body + operationId: anyof-array + parameters: + - explode: false + in: path + name: oneOfParam + required: true + schema: + $ref: '#/components/schemas/anyof_array_oneOfParam_parameter' + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/anyof_array_request' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/anyof_array_200_response' + description: Response + tags: + - fake + x-content-type: application/json + x-accepts: + - application/json /fake/{petId}/uploadImageWithRequiredFile: post: description: "" @@ -1263,6 +1294,15 @@ paths: x-accepts: - application/json components: + parameters: + oneOfParam: + explode: false + in: path + name: oneOfParam + required: true + schema: + $ref: '#/components/schemas/anyof_array_oneOfParam_parameter' + style: simple requestBodies: UserArray: content: @@ -1483,6 +1523,30 @@ components: type: object xml: name: Pet + AnyOf1: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + AnyOf2: + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object ApiResponse: example: code: 0 @@ -2432,6 +2496,31 @@ components: someProperty: type: string type: object + anyof_array_request_mapProp: + oneOf: + - additionalProperties: true + type: object + - default: "false" + enum: + - "true" + - "false" + type: string + anyof_array_request: + properties: + mapProp: + $ref: '#/components/schemas/anyof_array_request_mapProp' + anyof_array_oneOfParam_parameter: + oneOf: + - type: integer + - type: string + anyof_array_200_response: + anyOf: + - items: + $ref: '#/components/schemas/AnyOf1' + type: array + - items: + $ref: '#/components/schemas/AnyOf2' + type: array uploadFileWithRequiredFile_request: properties: additionalMetadata: diff --git a/samples/client/petstore/java/jersey3/docs/AnyOf1.md b/samples/client/petstore/java/jersey3/docs/AnyOf1.md new file mode 100644 index 000000000000..535e88eb3b9d --- /dev/null +++ b/samples/client/petstore/java/jersey3/docs/AnyOf1.md @@ -0,0 +1,15 @@ + + +# AnyOf1 + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | | [optional] | +|**type** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/jersey3/docs/AnyOf2.md b/samples/client/petstore/java/jersey3/docs/AnyOf2.md new file mode 100644 index 000000000000..53a9d35144d4 --- /dev/null +++ b/samples/client/petstore/java/jersey3/docs/AnyOf2.md @@ -0,0 +1,15 @@ + + +# AnyOf2 + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | | [optional] | +|**type** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/samples/client/petstore/java/jersey3/docs/AnyofArray200Response.md b/samples/client/petstore/java/jersey3/docs/AnyofArray200Response.md new file mode 100644 index 000000000000..9d44d0134fe7 --- /dev/null +++ b/samples/client/petstore/java/jersey3/docs/AnyofArray200Response.md @@ -0,0 +1,37 @@ + + +# AnyofArray200Response + +## anyOf schemas +* [List<@Valid AnyOf1>](List<@Valid AnyOf1>.md) +* [List<@Valid AnyOf2>](List<@Valid AnyOf2>.md) + +## Example +```java +// Import classes: +import org.openapitools.client.model.AnyofArray200Response; +import org.openapitools.client.model.List<@Valid AnyOf1>; +import org.openapitools.client.model.List<@Valid AnyOf2>; + +public class Example { + public static void main(String[] args) { + AnyofArray200Response exampleAnyofArray200Response = new AnyofArray200Response(); + + // create a new List<@Valid AnyOf1> + List<@Valid AnyOf1> exampleList<@Valid AnyOf1> = new List<@Valid AnyOf1>(); + // set AnyofArray200Response to List<@Valid AnyOf1> + exampleAnyofArray200Response.setActualInstance(exampleList<@Valid AnyOf1>); + // to get back the List<@Valid AnyOf1> set earlier + List<@Valid AnyOf1> testList<@Valid AnyOf1> = (List<@Valid AnyOf1>) exampleAnyofArray200Response.getActualInstance(); + + // create a new List<@Valid AnyOf2> + List<@Valid AnyOf2> exampleList<@Valid AnyOf2> = new List<@Valid AnyOf2>(); + // set AnyofArray200Response to List<@Valid AnyOf2> + exampleAnyofArray200Response.setActualInstance(exampleList<@Valid AnyOf2>); + // to get back the List<@Valid AnyOf2> set earlier + List<@Valid AnyOf2> testList<@Valid AnyOf2> = (List<@Valid AnyOf2>) exampleAnyofArray200Response.getActualInstance(); + } +} +``` + + diff --git a/samples/client/petstore/java/jersey3/docs/AnyofArrayOneOfParamParameter.md b/samples/client/petstore/java/jersey3/docs/AnyofArrayOneOfParamParameter.md new file mode 100644 index 000000000000..5b032aba8efa --- /dev/null +++ b/samples/client/petstore/java/jersey3/docs/AnyofArrayOneOfParamParameter.md @@ -0,0 +1,37 @@ + + +# AnyofArrayOneOfParamParameter + +## oneOf schemas +* [Integer](Integer.md) +* [String](String.md) + +## Example +```java +// Import classes: +import org.openapitools.client.model.AnyofArrayOneOfParamParameter; +import org.openapitools.client.model.Integer; +import org.openapitools.client.model.String; + +public class Example { + public static void main(String[] args) { + AnyofArrayOneOfParamParameter exampleAnyofArrayOneOfParamParameter = new AnyofArrayOneOfParamParameter(); + + // create a new Integer + Integer exampleInteger = new Integer(); + // set AnyofArrayOneOfParamParameter to Integer + exampleAnyofArrayOneOfParamParameter.setActualInstance(exampleInteger); + // to get back the Integer set earlier + Integer testInteger = (Integer) exampleAnyofArrayOneOfParamParameter.getActualInstance(); + + // create a new String + String exampleString = new String(); + // set AnyofArrayOneOfParamParameter to String + exampleAnyofArrayOneOfParamParameter.setActualInstance(exampleString); + // to get back the String set earlier + String testString = (String) exampleAnyofArrayOneOfParamParameter.getActualInstance(); + } +} +``` + + diff --git a/samples/client/petstore/java/jersey3/docs/AnyofArrayRequest.md b/samples/client/petstore/java/jersey3/docs/AnyofArrayRequest.md new file mode 100644 index 000000000000..25da913eb2c9 --- /dev/null +++ b/samples/client/petstore/java/jersey3/docs/AnyofArrayRequest.md @@ -0,0 +1,13 @@ + + +# AnyofArrayRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**mapProp** | [**AnyofArrayRequestMapProp**](AnyofArrayRequestMapProp.md) | | [optional] | + + + diff --git a/samples/client/petstore/java/jersey3/docs/AnyofArrayRequestMapProp.md b/samples/client/petstore/java/jersey3/docs/AnyofArrayRequestMapProp.md new file mode 100644 index 000000000000..cfcae5e9129a --- /dev/null +++ b/samples/client/petstore/java/jersey3/docs/AnyofArrayRequestMapProp.md @@ -0,0 +1,37 @@ + + +# AnyofArrayRequestMapProp + +## oneOf schemas +* [Map](Map.md) +* [String](String.md) + +## Example +```java +// Import classes: +import org.openapitools.client.model.AnyofArrayRequestMapProp; +import org.openapitools.client.model.Map; +import org.openapitools.client.model.String; + +public class Example { + public static void main(String[] args) { + AnyofArrayRequestMapProp exampleAnyofArrayRequestMapProp = new AnyofArrayRequestMapProp(); + + // create a new Map + Map exampleMap = new Map(); + // set AnyofArrayRequestMapProp to Map + exampleAnyofArrayRequestMapProp.setActualInstance(exampleMap); + // to get back the Map set earlier + Map testMap = (Map) exampleAnyofArrayRequestMapProp.getActualInstance(); + + // create a new String + String exampleString = new String(); + // set AnyofArrayRequestMapProp to String + exampleAnyofArrayRequestMapProp.setActualInstance(exampleString); + // to get back the String set earlier + String testString = (String) exampleAnyofArrayRequestMapProp.getActualInstance(); + } +} +``` + + diff --git a/samples/client/petstore/java/jersey3/docs/FakeApi.md b/samples/client/petstore/java/jersey3/docs/FakeApi.md index 7d45cd6a51b8..dda89ab14997 100644 --- a/samples/client/petstore/java/jersey3/docs/FakeApi.md +++ b/samples/client/petstore/java/jersey3/docs/FakeApi.md @@ -4,6 +4,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |------------- | ------------- | -------------| +| [**anyofArray**](FakeApi.md#anyofArray) | **POST** /anyof-array | | | [**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint | | [**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | | | [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | | @@ -26,6 +27,73 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* +## anyofArray + +> AnyofArray200Response anyofArray(oneOfParam, anyofArrayRequest) + + + +Response with anyof containing arrays and a oneof parameter as well as a map request body + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.model.*; +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); + AnyofArrayOneOfParamParameter oneOfParam = new AnyofArrayOneOfParamParameter(); // AnyofArrayOneOfParamParameter | + AnyofArrayRequest anyofArrayRequest = new AnyofArrayRequest(); // AnyofArrayRequest | + try { + AnyofArray200Response result = apiInstance.anyofArray(oneOfParam, anyofArrayRequest); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#anyofArray"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **oneOfParam** | [**AnyofArrayOneOfParamParameter**](AnyofArrayOneOfParamParameter.md)| | | +| **anyofArrayRequest** | [**AnyofArrayRequest**](AnyofArrayRequest.md)| | | + +### Return type + +[**AnyofArray200Response**](AnyofArray200Response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Response | - | + + ## fakeHealthGet > HealthCheckResult fakeHealthGet() diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/api/FakeApi.java index 3bf4f20edc05..0dc628df8c56 100644 --- a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/api/FakeApi.java @@ -8,6 +8,9 @@ import jakarta.ws.rs.core.GenericType; +import org.openapitools.client.model.AnyofArray200Response; +import org.openapitools.client.model.AnyofArrayOneOfParamParameter; +import org.openapitools.client.model.AnyofArrayRequest; import java.math.BigDecimal; import org.openapitools.client.model.Client; import java.io.File; @@ -59,6 +62,56 @@ public void setApiClient(ApiClient apiClient) { this.apiClient = apiClient; } + /** + * + * Response with anyof containing arrays and a oneof parameter as well as a map request body + * @param oneOfParam (required) + * @param anyofArrayRequest (required) + * @return AnyofArray200Response + * @throws ApiException if fails to make API call + * @http.response.details + + + +
Status Code Description Response Headers
200 Response -
+ */ + public AnyofArray200Response anyofArray(AnyofArrayOneOfParamParameter oneOfParam, AnyofArrayRequest anyofArrayRequest) throws ApiException { + return anyofArrayWithHttpInfo(oneOfParam, anyofArrayRequest).getData(); + } + + /** + * + * Response with anyof containing arrays and a oneof parameter as well as a map request body + * @param oneOfParam (required) + * @param anyofArrayRequest (required) + * @return ApiResponse<AnyofArray200Response> + * @throws ApiException if fails to make API call + * @http.response.details + + + +
Status Code Description Response Headers
200 Response -
+ */ + public ApiResponse anyofArrayWithHttpInfo(AnyofArrayOneOfParamParameter oneOfParam, AnyofArrayRequest anyofArrayRequest) throws ApiException { + // Check required parameters + if (oneOfParam == null) { + throw new ApiException(400, "Missing the required parameter 'oneOfParam' when calling anyofArray"); + } + if (anyofArrayRequest == null) { + throw new ApiException(400, "Missing the required parameter 'anyofArrayRequest' when calling anyofArray"); + } + + // Path parameters + String localVarPath = "/anyof-array" + .replaceAll("\\{oneOfParam}", apiClient.escapeString(oneOfParam.toString())); + + String localVarAccept = apiClient.selectHeaderAccept("application/json"); + String localVarContentType = apiClient.selectHeaderContentType("application/json"); + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI("FakeApi.anyofArray", localVarPath, "POST", new ArrayList<>(), anyofArrayRequest, + new LinkedHashMap<>(), new LinkedHashMap<>(), new LinkedHashMap<>(), localVarAccept, localVarContentType, + null, localVarReturnType, false); + } /** * Health check endpoint * diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyOf1.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyOf1.java new file mode 100644 index 000000000000..961da2c1bfa9 --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyOf1.java @@ -0,0 +1,176 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +import org.openapitools.client.JSON; + + +/** + * AnyOf1 + */ +@JsonPropertyOrder({ + AnyOf1.JSON_PROPERTY_CODE, + AnyOf1.JSON_PROPERTY_TYPE, + AnyOf1.JSON_PROPERTY_MESSAGE +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +public class AnyOf1 { + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public AnyOf1() { + } + + public AnyOf1 code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @jakarta.annotation.Nullable + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Integer getCode() { + return code; + } + + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(Integer code) { + this.code = code; + } + + + public AnyOf1 type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @jakarta.annotation.Nullable + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + + public AnyOf1 message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @jakarta.annotation.Nullable + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getMessage() { + return message; + } + + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + + /** + * Return true if this AnyOf1 object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnyOf1 anyOf1 = (AnyOf1) o; + return Objects.equals(this.code, anyOf1.code) && + Objects.equals(this.type, anyOf1.type) && + Objects.equals(this.message, anyOf1.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnyOf1 {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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/jersey3/src/main/java/org/openapitools/client/model/AnyOf2.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyOf2.java new file mode 100644 index 000000000000..d38858068025 --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyOf2.java @@ -0,0 +1,176 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +import org.openapitools.client.JSON; + + +/** + * AnyOf2 + */ +@JsonPropertyOrder({ + AnyOf2.JSON_PROPERTY_CODE, + AnyOf2.JSON_PROPERTY_TYPE, + AnyOf2.JSON_PROPERTY_MESSAGE +}) +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +public class AnyOf2 { + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public AnyOf2() { + } + + public AnyOf2 code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @jakarta.annotation.Nullable + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Integer getCode() { + return code; + } + + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(Integer code) { + this.code = code; + } + + + public AnyOf2 type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @jakarta.annotation.Nullable + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + + public AnyOf2 message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @jakarta.annotation.Nullable + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getMessage() { + return message; + } + + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + + /** + * Return true if this AnyOf2 object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnyOf2 anyOf2 = (AnyOf2) o; + return Objects.equals(this.code, anyOf2.code) && + Objects.equals(this.type, anyOf2.type) && + Objects.equals(this.message, anyOf2.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnyOf2 {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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/jersey3/src/main/java/org/openapitools/client/model/AnyofArray200Response.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArray200Response.java new file mode 100644 index 000000000000..9dce95db571e --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArray200Response.java @@ -0,0 +1,269 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.List; +import org.openapitools.client.model.AnyOf1; +import org.openapitools.client.model.AnyOf2; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +import org.openapitools.client.JSON; + + +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.core.Response; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.openapitools.client.JSON; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +@JsonDeserialize(using=AnyofArray200Response.AnyofArray200ResponseDeserializer.class) +@JsonSerialize(using = AnyofArray200Response.AnyofArray200ResponseSerializer.class) +public class AnyofArray200Response extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AnyofArray200Response.class.getName()); + + public static class AnyofArray200ResponseSerializer extends StdSerializer { + public AnyofArray200ResponseSerializer(Class t) { + super(t); + } + + public AnyofArray200ResponseSerializer() { + this(null); + } + + @Override + public void serialize(AnyofArray200Response value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AnyofArray200ResponseDeserializer extends StdDeserializer { + public AnyofArray200ResponseDeserializer() { + this(AnyofArray200Response.class); + } + + public AnyofArray200ResponseDeserializer(Class vc) { + super(vc); + } + + @Override + public AnyofArray200Response deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize List<@Valid AnyOf1> + try { + if (token == JsonToken.START_ARRAY) { + final TypeReference> ref = new TypeReference>(){}; + deserialized = tree.traverse(jp.getCodec()).readValueAs(ref); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'List<@Valid AnyOf1>'"); + } + AnyofArray200Response ret = new AnyofArray200Response(); + ret.setActualInstance(deserialized); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'List<@Valid AnyOf1>'", e); + } + + // deserialize List<@Valid AnyOf2> + try { + if (token == JsonToken.START_ARRAY) { + final TypeReference> ref = new TypeReference>(){}; + deserialized = tree.traverse(jp.getCodec()).readValueAs(ref); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'List<@Valid AnyOf2>'"); + } + AnyofArray200Response ret = new AnyofArray200Response(); + ret.setActualInstance(deserialized); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'List<@Valid AnyOf2>'", e); + } + + throw new IOException(String.format("Failed deserialization for AnyofArray200Response: no match found")); + } + + /** + * Handle deserialization of the 'null' value. + */ + @Override + public AnyofArray200Response getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "AnyofArray200Response cannot be null"); + } + } + + // store a list of schema names defined in anyOf + public static final Map> schemas = new HashMap<>(); + + public AnyofArray200Response() { + super("anyOf", Boolean.FALSE); + } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + */ + @JsonAnySetter + public AnyofArray200Response putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap<>(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** + * Return true if this anyof_array_200_response object is equal to o. + */ + @Override + public boolean equals(Object o) { + return super.equals(o) && Objects.equals(this.additionalProperties, ((AnyofArray200Response)o).additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties); + } + public AnyofArray200Response(List o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("List<@Valid AnyOf1>", new GenericType>() { + }); + schemas.put("List<@Valid AnyOf2>", new GenericType>() { + }); + JSON.registerDescendants(AnyofArray200Response.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return AnyofArray200Response.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * List<@Valid AnyOf1>, List<@Valid AnyOf2> + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(List.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be List<@Valid AnyOf1>, List<@Valid AnyOf2>"); + } + + /** + * Get the actual instance, which can be the following: + * List<@Valid AnyOf1>, List<@Valid AnyOf2> + * + * @return The actual instance (List<@Valid AnyOf1>, List<@Valid AnyOf2>) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `List<@Valid AnyOf1>`. If the actual instance is not `List<@Valid AnyOf1>`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `List<@Valid AnyOf1>` + * @throws ClassCastException if the instance is not `List<@Valid AnyOf1>` + */ + public List<@Valid AnyOf1> getListAnyOf1() throws ClassCastException { + return (List<@Valid AnyOf1>)super.getActualInstance(); + } + + /** + * Get the actual instance of `List<@Valid AnyOf2>`. If the actual instance is not `List<@Valid AnyOf2>`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `List<@Valid AnyOf2>` + * @throws ClassCastException if the instance is not `List<@Valid AnyOf2>` + */ + public List<@Valid AnyOf2> getListAnyOf2() throws ClassCastException { + return (List<@Valid AnyOf2>)super.getActualInstance(); + } + +} + diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArrayOneOfParamParameter.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArrayOneOfParamParameter.java new file mode 100644 index 000000000000..a80df61489db --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArrayOneOfParamParameter.java @@ -0,0 +1,286 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +import org.openapitools.client.JSON; + +import com.fasterxml.jackson.core.type.TypeReference; + +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.core.Response; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.openapitools.client.JSON; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +@JsonDeserialize(using = AnyofArrayOneOfParamParameter.AnyofArrayOneOfParamParameterDeserializer.class) +@JsonSerialize(using = AnyofArrayOneOfParamParameter.AnyofArrayOneOfParamParameterSerializer.class) +public class AnyofArrayOneOfParamParameter extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AnyofArrayOneOfParamParameter.class.getName()); + + public static class AnyofArrayOneOfParamParameterSerializer extends StdSerializer { + public AnyofArrayOneOfParamParameterSerializer(Class t) { + super(t); + } + + public AnyofArrayOneOfParamParameterSerializer() { + this(null); + } + + @Override + public void serialize(AnyofArrayOneOfParamParameter value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AnyofArrayOneOfParamParameterDeserializer extends StdDeserializer { + public AnyofArrayOneOfParamParameterDeserializer() { + this(AnyofArrayOneOfParamParameter.class); + } + + public AnyofArrayOneOfParamParameterDeserializer(Class vc) { + super(vc); + } + + @Override + public AnyofArrayOneOfParamParameter deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize Integer + try { + boolean attemptParsing = true; + attemptParsing = typeCoercion; //respect type coercion setting + if (!attemptParsing) { + attemptParsing |= (token == JsonToken.VALUE_NUMBER_INT); + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Integer.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'Integer'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Integer'", e); + } + + // deserialize String + try { + boolean attemptParsing = true; + attemptParsing = typeCoercion; //respect type coercion setting + if (!attemptParsing) { + attemptParsing |= (token == JsonToken.VALUE_STRING); + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(String.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + if (match == 1) { + AnyofArrayOneOfParamParameter ret = new AnyofArrayOneOfParamParameter(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException(String.format("Failed deserialization for AnyofArrayOneOfParamParameter: %d classes match result, expected 1", match)); + } + + /** + * Handle deserialization of the 'null' value. + */ + @Override + public AnyofArrayOneOfParamParameter getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "AnyofArrayOneOfParamParameter cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public AnyofArrayOneOfParamParameter() { + super("oneOf", Boolean.FALSE); + } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + */ + @JsonAnySetter + public AnyofArrayOneOfParamParameter putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap<>(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** + * Return true if this anyof_array_oneOfParam_parameter object is equal to o. + */ + @Override + public boolean equals(Object o) { + return super.equals(o) && Objects.equals(this.additionalProperties, ((AnyofArrayOneOfParamParameter)o).additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties); + } + public AnyofArrayOneOfParamParameter(Integer o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AnyofArrayOneOfParamParameter(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("Integer", new GenericType() { + }); + schemas.put("String", new GenericType() { + }); + JSON.registerDescendants(AnyofArrayOneOfParamParameter.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return AnyofArrayOneOfParamParameter.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * Integer, String + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(Integer.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(String.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be Integer, String"); + } + + /** + * Get the actual instance, which can be the following: + * Integer, String + * + * @return The actual instance (Integer, String) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `Integer`. If the actual instance is not `Integer`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Integer` + * @throws ClassCastException if the instance is not `Integer` + */ + public Integer getInteger() throws ClassCastException { + return (Integer)super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String)super.getActualInstance(); + } + +} + diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArrayRequest.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArrayRequest.java new file mode 100644 index 000000000000..2a8963832d67 --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArrayRequest.java @@ -0,0 +1,115 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.client.model.AnyofArrayRequestMapProp; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +import org.openapitools.client.JSON; + + +/** + * AnyofArrayRequest + */ +@JsonPropertyOrder({ + AnyofArrayRequest.JSON_PROPERTY_MAP_PROP +}) +@JsonTypeName("anyof_array_request") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +public class AnyofArrayRequest { + public static final String JSON_PROPERTY_MAP_PROP = "mapProp"; + private AnyofArrayRequestMapProp mapProp; + + public AnyofArrayRequest() { + } + + public AnyofArrayRequest mapProp(AnyofArrayRequestMapProp mapProp) { + this.mapProp = mapProp; + return this; + } + + /** + * Get mapProp + * @return mapProp + */ + @jakarta.annotation.Nullable + @Valid + + @JsonProperty(JSON_PROPERTY_MAP_PROP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public AnyofArrayRequestMapProp getMapProp() { + return mapProp; + } + + + @JsonProperty(JSON_PROPERTY_MAP_PROP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMapProp(AnyofArrayRequestMapProp mapProp) { + this.mapProp = mapProp; + } + + + /** + * Return true if this anyof_array_request object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnyofArrayRequest anyofArrayRequest = (AnyofArrayRequest) o; + return Objects.equals(this.mapProp, anyofArrayRequest.mapProp); + } + + @Override + public int hashCode() { + return Objects.hash(mapProp); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnyofArrayRequest {\n"); + sb.append(" mapProp: ").append(toIndentedString(mapProp)).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/jersey3/src/main/java/org/openapitools/client/model/AnyofArrayRequestMapProp.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArrayRequestMapProp.java new file mode 100644 index 000000000000..b557143ed9a4 --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/AnyofArrayRequestMapProp.java @@ -0,0 +1,287 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +import org.openapitools.client.JSON; + +import com.fasterxml.jackson.core.type.TypeReference; + +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.core.Response; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.openapitools.client.JSON; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +@JsonDeserialize(using = AnyofArrayRequestMapProp.AnyofArrayRequestMapPropDeserializer.class) +@JsonSerialize(using = AnyofArrayRequestMapProp.AnyofArrayRequestMapPropSerializer.class) +public class AnyofArrayRequestMapProp extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AnyofArrayRequestMapProp.class.getName()); + + public static class AnyofArrayRequestMapPropSerializer extends StdSerializer { + public AnyofArrayRequestMapPropSerializer(Class t) { + super(t); + } + + public AnyofArrayRequestMapPropSerializer() { + this(null); + } + + @Override + public void serialize(AnyofArrayRequestMapProp value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AnyofArrayRequestMapPropDeserializer extends StdDeserializer { + public AnyofArrayRequestMapPropDeserializer() { + this(AnyofArrayRequestMapProp.class); + } + + public AnyofArrayRequestMapPropDeserializer(Class vc) { + super(vc); + } + + @Override + public AnyofArrayRequestMapProp deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize Map + try { + boolean attemptParsing = true; + attemptParsing = typeCoercion; //respect type coercion setting + if (!attemptParsing) { + } + if (attemptParsing) { + final TypeReference> ref = new TypeReference>(){}; + deserialized = tree.traverse(jp.getCodec()).readValueAs(ref); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'Map'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Map'", e); + } + + // deserialize String + try { + boolean attemptParsing = true; + attemptParsing = typeCoercion; //respect type coercion setting + if (!attemptParsing) { + attemptParsing |= (token == JsonToken.VALUE_STRING); + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(String.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + if (match == 1) { + AnyofArrayRequestMapProp ret = new AnyofArrayRequestMapProp(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException(String.format("Failed deserialization for AnyofArrayRequestMapProp: %d classes match result, expected 1", match)); + } + + /** + * Handle deserialization of the 'null' value. + */ + @Override + public AnyofArrayRequestMapProp getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "AnyofArrayRequestMapProp cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public AnyofArrayRequestMapProp() { + super("oneOf", Boolean.FALSE); + } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + */ + @JsonAnySetter + public AnyofArrayRequestMapProp putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap<>(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** + * Return true if this anyof_array_request_mapProp object is equal to o. + */ + @Override + public boolean equals(Object o) { + return super.equals(o) && Objects.equals(this.additionalProperties, ((AnyofArrayRequestMapProp)o).additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties); + } + public AnyofArrayRequestMapProp(Map o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AnyofArrayRequestMapProp(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("Map", new GenericType>() { + }); + schemas.put("String", new GenericType() { + }); + JSON.registerDescendants(AnyofArrayRequestMapProp.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return AnyofArrayRequestMapProp.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * Map, String + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(Map.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(String.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be Map, String"); + } + + /** + * Get the actual instance, which can be the following: + * Map, String + * + * @return The actual instance (Map, String) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `Map`. If the actual instance is not `Map`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Map` + * @throws ClassCastException if the instance is not `Map` + */ + public Map getMapStringObject() throws ClassCastException { + return (Map)super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String)super.getActualInstance(); + } + +} + diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/EnumTest.java index 61987d6cb72a..52ea4c2900f7 100644 --- a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/EnumTest.java @@ -137,9 +137,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -175,9 +175,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumIntegerOnly */ public enum EnumIntegerOnlyEnum { - NUMBER_2(2), + NUMBER_2(Integer.valueOf(2)), - NUMBER_MINUS_2(-2); + NUMBER_MINUS_2(Integer.valueOf(-2)); private Integer value; @@ -213,9 +213,9 @@ public static EnumIntegerOnlyEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/GmFruit.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/GmFruit.java index b718b0b32a3c..5616205666a3 100644 --- a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/GmFruit.java +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/GmFruit.java @@ -43,10 +43,12 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -89,26 +91,42 @@ public GmFruit deserialize(JsonParser jp, DeserializationContext ctxt) throws IO JsonNode tree = jp.readValueAsTree(); Object deserialized = null; - // deserialize Apple + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize Apple (nullable) try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Apple.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Apple.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Apple'"); + } GmFruit ret = new GmFruit(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'GmFruit'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Apple'", e); } // deserialize Banana try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Banana.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Banana.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Banana'"); + } GmFruit ret = new GmFruit(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'GmFruit'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Banana'", e); } throw new IOException(String.format("Failed deserialization for GmFruit: no match found")); @@ -131,7 +149,7 @@ public GmFruit() { } public GmFruit(Apple o) { - super("anyOf", Boolean.FALSE); + super("anyOf", Boolean.TRUE); setActualInstance(o); } @@ -188,23 +206,23 @@ public Object getActualInstance() { } /** - * Get the actual instance of `Apple`. If the actual instance is not `Apple`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Apple` - * @throws ClassCastException if the instance is not `Apple` - */ + * Get the actual instance of `Apple`. If the actual instance is not `Apple`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Apple` + * @throws ClassCastException if the instance is not `Apple` + */ public Apple getApple() throws ClassCastException { return (Apple)super.getActualInstance(); } /** - * Get the actual instance of `Banana`. If the actual instance is not `Banana`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Banana` - * @throws ClassCastException if the instance is not `Banana` - */ + * Get the actual instance of `Banana`. If the actual instance is not `Banana`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Banana` + * @throws ClassCastException if the instance is not `Banana` + */ public Banana getBanana() throws ClassCastException { return (Banana)super.getActualInstance(); } diff --git a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/MammalAnyof.java b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/MammalAnyof.java index 2bec08cf2d7a..16262aab0399 100644 --- a/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/MammalAnyof.java +++ b/samples/client/petstore/java/jersey3/src/main/java/org/openapitools/client/model/MammalAnyof.java @@ -50,10 +50,12 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -106,37 +108,60 @@ public MammalAnyof deserialize(JsonParser jp, DeserializationContext ctxt) throw ret.setActualInstance(deserialized); return ret; } - // deserialize Pig + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize Whale try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Pig.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Whale.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Whale'"); + } MammalAnyof ret = new MammalAnyof(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'MammalAnyof'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Whale'", e); } - // deserialize Whale + // deserialize Zebra try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Whale.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Zebra.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Zebra'"); + } MammalAnyof ret = new MammalAnyof(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'MammalAnyof'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Zebra'", e); } - // deserialize Zebra + // deserialize Pig try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Zebra.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Pig.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Pig'"); + } MammalAnyof ret = new MammalAnyof(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'MammalAnyof'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Pig'", e); } throw new IOException(String.format("Failed deserialization for MammalAnyof: no match found")); @@ -207,17 +232,17 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties); } - public MammalAnyof(Pig o) { + public MammalAnyof(Whale o) { super("anyOf", Boolean.FALSE); setActualInstance(o); } - public MammalAnyof(Whale o) { + public MammalAnyof(Zebra o) { super("anyOf", Boolean.FALSE); setActualInstance(o); } - public MammalAnyof(Zebra o) { + public MammalAnyof(Pig o) { super("anyOf", Boolean.FALSE); setActualInstance(o); } @@ -254,17 +279,17 @@ public Map> getSchemas() { */ @Override public void setActualInstance(Object instance) { - if (JSON.isInstanceOf(Pig.class, instance, new HashSet<>())) { + if (JSON.isInstanceOf(Whale.class, instance, new HashSet<>())) { super.setActualInstance(instance); return; } - if (JSON.isInstanceOf(Whale.class, instance, new HashSet<>())) { + if (JSON.isInstanceOf(Zebra.class, instance, new HashSet<>())) { super.setActualInstance(instance); return; } - if (JSON.isInstanceOf(Zebra.class, instance, new HashSet<>())) { + if (JSON.isInstanceOf(Pig.class, instance, new HashSet<>())) { super.setActualInstance(instance); return; } @@ -284,37 +309,37 @@ public Object getActualInstance() { } /** - * Get the actual instance of `Pig`. If the actual instance is not `Pig`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Pig` - * @throws ClassCastException if the instance is not `Pig` - */ - public Pig getPig() throws ClassCastException { - return (Pig)super.getActualInstance(); - } - - /** - * Get the actual instance of `Whale`. If the actual instance is not `Whale`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Whale` - * @throws ClassCastException if the instance is not `Whale` - */ + * Get the actual instance of `Whale`. If the actual instance is not `Whale`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Whale` + * @throws ClassCastException if the instance is not `Whale` + */ public Whale getWhale() throws ClassCastException { return (Whale)super.getActualInstance(); } /** - * Get the actual instance of `Zebra`. If the actual instance is not `Zebra`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Zebra` - * @throws ClassCastException if the instance is not `Zebra` - */ + * Get the actual instance of `Zebra`. If the actual instance is not `Zebra`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Zebra` + * @throws ClassCastException if the instance is not `Zebra` + */ public Zebra getZebra() throws ClassCastException { return (Zebra)super.getActualInstance(); } + /** + * Get the actual instance of `Pig`. If the actual instance is not `Pig`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Pig` + * @throws ClassCastException if the instance is not `Pig` + */ + public Pig getPig() throws ClassCastException { + return (Pig)super.getActualInstance(); + } + } diff --git a/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyOf1Test.java b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyOf1Test.java new file mode 100644 index 000000000000..7e2cfce74e95 --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyOf1Test.java @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyOf1 + */ +public class AnyOf1Test { + private final AnyOf1 model = new AnyOf1(); + + /** + * Model tests for AnyOf1 + */ + @Test + public void testAnyOf1() { + // TODO: test AnyOf1 + } + + /** + * Test the property 'code' + */ + @Test + public void codeTest() { + // TODO: test code + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } + +} diff --git a/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyOf2Test.java b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyOf2Test.java new file mode 100644 index 000000000000..f8b844689aa0 --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyOf2Test.java @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyOf2 + */ +public class AnyOf2Test { + private final AnyOf2 model = new AnyOf2(); + + /** + * Model tests for AnyOf2 + */ + @Test + public void testAnyOf2() { + // TODO: test AnyOf2 + } + + /** + * Test the property 'code' + */ + @Test + public void codeTest() { + // TODO: test code + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } + +} diff --git a/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArray200ResponseTest.java b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArray200ResponseTest.java new file mode 100644 index 000000000000..69dd9557b9b7 --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArray200ResponseTest.java @@ -0,0 +1,39 @@ +/* + * 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.JsonTypeName; +import java.util.List; +import org.openapitools.client.model.AnyOf1; +import org.openapitools.client.model.AnyOf2; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyofArray200Response + */ +public class AnyofArray200ResponseTest { + private final AnyofArray200Response model = new AnyofArray200Response(); + + /** + * Model tests for AnyofArray200Response + */ + @Test + public void testAnyofArray200Response() { + // TODO: test AnyofArray200Response + } + +} diff --git a/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArrayOneOfParamParameterTest.java b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArrayOneOfParamParameterTest.java new file mode 100644 index 000000000000..8ad06338017b --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArrayOneOfParamParameterTest.java @@ -0,0 +1,36 @@ +/* + * 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.JsonTypeName; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyofArrayOneOfParamParameter + */ +public class AnyofArrayOneOfParamParameterTest { + private final AnyofArrayOneOfParamParameter model = new AnyofArrayOneOfParamParameter(); + + /** + * Model tests for AnyofArrayOneOfParamParameter + */ + @Test + public void testAnyofArrayOneOfParamParameter() { + // TODO: test AnyofArrayOneOfParamParameter + } + +} diff --git a/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArrayRequestMapPropTest.java b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArrayRequestMapPropTest.java new file mode 100644 index 000000000000..c604f51c53be --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArrayRequestMapPropTest.java @@ -0,0 +1,37 @@ +/* + * 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.JsonTypeName; +import java.util.Map; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyofArrayRequestMapProp + */ +public class AnyofArrayRequestMapPropTest { + private final AnyofArrayRequestMapProp model = new AnyofArrayRequestMapProp(); + + /** + * Model tests for AnyofArrayRequestMapProp + */ + @Test + public void testAnyofArrayRequestMapProp() { + // TODO: test AnyofArrayRequestMapProp + } + +} diff --git a/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArrayRequestTest.java b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArrayRequestTest.java new file mode 100644 index 000000000000..17aaed22bcfa --- /dev/null +++ b/samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/AnyofArrayRequestTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.client.model.AnyofArrayRequestMapProp; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyofArrayRequest + */ +public class AnyofArrayRequestTest { + private final AnyofArrayRequest model = new AnyofArrayRequest(); + + /** + * Model tests for AnyofArrayRequest + */ + @Test + public void testAnyofArrayRequest() { + // TODO: test AnyofArrayRequest + } + + /** + * Test the property 'mapProp' + */ + @Test + public void mapPropTest() { + // TODO: test mapProp + } + +} diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java index f317018d0fd0..db8f3265954e 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java @@ -137,9 +137,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -175,9 +175,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumIntegerOnly */ public enum EnumIntegerOnlyEnum { - NUMBER_2(2), + NUMBER_2(Integer.valueOf(2)), - NUMBER_MINUS_2(-2); + NUMBER_MINUS_2(Integer.valueOf(-2)); private Integer value; @@ -213,9 +213,9 @@ public static EnumIntegerOnlyEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java index cdb411064b3e..fbac9197e457 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java @@ -137,9 +137,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -175,9 +175,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumIntegerOnly */ public enum EnumIntegerOnlyEnum { - NUMBER_2(2), + NUMBER_2(Integer.valueOf(2)), - NUMBER_MINUS_2(-2); + NUMBER_MINUS_2(Integer.valueOf(-2)); private Integer value; @@ -213,9 +213,9 @@ public static EnumIntegerOnlyEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/EnumTest.java index 8f076161581f..49689dddb523 100644 --- a/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/rest-assured-jackson/src/main/java/org/openapitools/client/model/EnumTest.java @@ -124,9 +124,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -162,9 +162,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/EnumTest.java index 1a526187b592..790a5199f1e6 100644 --- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/model/EnumTest.java @@ -142,9 +142,9 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti */ @JsonAdapter(EnumIntegerEnum.Adapter.class) public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -193,9 +193,9 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { */ @JsonAdapter(EnumNumberEnum.Adapter.class) public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java index bbbeefaba142..c9fa44866f8f 100644 --- a/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/restclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -132,9 +132,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -170,9 +170,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/EnumTest.java index 42f9f8e206a7..5524b4d3e040 100644 --- a/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/restclient-useSingleRequestParameter/src/main/java/org/openapitools/client/model/EnumTest.java @@ -131,9 +131,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -169,9 +169,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/EnumTest.java index 42f9f8e206a7..5524b4d3e040 100644 --- a/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/restclient/src/main/java/org/openapitools/client/model/EnumTest.java @@ -131,9 +131,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -169,9 +169,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/EnumTest.java index c84f2fa3fc8d..7f1caca5f0a9 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/resteasy/src/main/java/org/openapitools/client/model/EnumTest.java @@ -131,9 +131,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -169,9 +169,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/EnumTest.java index 92d2f1eee1f3..5fae8e2e9fec 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/model/EnumTest.java @@ -153,10 +153,10 @@ public static EnumStringRequiredEnum fromValue(String value) { @XmlEnum(Integer.class) public enum EnumIntegerEnum { @XmlEnumValue("1") - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), @XmlEnumValue("-1") - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -196,10 +196,10 @@ public static EnumIntegerEnum fromValue(Integer value) { @XmlEnum(Double.class) public enum EnumNumberEnum { @XmlEnumValue("1.1") - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), @XmlEnumValue("-1.2") - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/EnumTest.java index 836b9fc93fbb..c613e446dd78 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/model/EnumTest.java @@ -131,9 +131,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -169,9 +169,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/EnumTest.java index 268c45b7a657..9d5ca6b7a904 100644 --- a/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/retrofit2-play26/src/main/java/org/openapitools/client/model/EnumTest.java @@ -123,9 +123,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -161,9 +161,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/EnumTest.java index 7ae5e0b170b9..2e7e6dab9720 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -139,9 +139,9 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti */ @JsonAdapter(EnumIntegerEnum.Adapter.class) public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -190,9 +190,9 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { */ @JsonAdapter(EnumNumberEnum.Adapter.class) public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/EnumTest.java index 7ae5e0b170b9..2e7e6dab9720 100644 --- a/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/retrofit2rx2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -139,9 +139,9 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti */ @JsonAdapter(EnumIntegerEnum.Adapter.class) public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -190,9 +190,9 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { */ @JsonAdapter(EnumNumberEnum.Adapter.class) public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/EnumTest.java index 7ae5e0b170b9..2e7e6dab9720 100644 --- a/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/retrofit2rx3/src/main/java/org/openapitools/client/model/EnumTest.java @@ -139,9 +139,9 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti */ @JsonAdapter(EnumIntegerEnum.Adapter.class) public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -190,9 +190,9 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { */ @JsonAdapter(EnumNumberEnum.Adapter.class) public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java index 726fcf37f13d..6c368f4ff4fa 100644 --- a/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/vertx-no-nullable/src/main/java/org/openapitools/client/model/EnumTest.java @@ -121,9 +121,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -159,9 +159,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/EnumTest.java index c84f2fa3fc8d..7f1caca5f0a9 100644 --- a/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/vertx/src/main/java/org/openapitools/client/model/EnumTest.java @@ -131,9 +131,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -169,9 +169,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/EnumTest.java index 42f9f8e206a7..5524b4d3e040 100644 --- a/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/webclient-jakarta/src/main/java/org/openapitools/client/model/EnumTest.java @@ -131,9 +131,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -169,9 +169,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java index 6761607407da..6fcf8f0f9b40 100644 --- a/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/webclient-swagger2/src/main/java/org/openapitools/client/model/EnumTest.java @@ -132,9 +132,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -170,9 +170,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/EnumTest.java index c84f2fa3fc8d..7f1caca5f0a9 100644 --- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/EnumTest.java @@ -131,9 +131,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -169,9 +169,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts b/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts index 8849fa8f81d4..91a7e800b11b 100644 --- a/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts +++ b/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts @@ -97,6 +97,88 @@ export interface Animal { */ 'color'?: string; } +/** + * + * @export + * @interface AnyOf1 + */ +export interface AnyOf1 { + /** + * + * @type {number} + * @memberof AnyOf1 + */ + 'code'?: number; + /** + * + * @type {string} + * @memberof AnyOf1 + */ + 'type'?: string; + /** + * + * @type {string} + * @memberof AnyOf1 + */ + 'message'?: string; +} +/** + * + * @export + * @interface AnyOf2 + */ +export interface AnyOf2 { + /** + * + * @type {number} + * @memberof AnyOf2 + */ + 'code'?: number; + /** + * + * @type {string} + * @memberof AnyOf2 + */ + 'type'?: string; + /** + * + * @type {string} + * @memberof AnyOf2 + */ + 'message'?: string; +} +/** + * + * @export + * @interface AnyofArray200Response + */ +export interface AnyofArray200Response { +} +/** + * @type AnyofArrayOneOfParamParameter + * @export + */ +export type AnyofArrayOneOfParamParameter = number | string; + +/** + * + * @export + * @interface AnyofArrayRequest + */ +export interface AnyofArrayRequest { + /** + * + * @type {AnyofArrayRequestMapProp} + * @memberof AnyofArrayRequest + */ + 'mapProp'?: AnyofArrayRequestMapProp; +} +/** + * @type AnyofArrayRequestMapProp + * @export + */ +export type AnyofArrayRequestMapProp = string | { [key: string]: any; }; + /** * * @export @@ -1949,6 +2031,45 @@ export class DefaultApi extends BaseAPI { */ export const FakeApiAxiosParamCreator = function (configuration?: Configuration) { return { + /** + * Response with anyof containing arrays and a oneof parameter as well as a map request body + * @param {AnyofArrayOneOfParamParameter} oneOfParam + * @param {AnyofArrayRequest} anyofArrayRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + anyofArray: async (oneOfParam: AnyofArrayOneOfParamParameter, anyofArrayRequest: AnyofArrayRequest, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'oneOfParam' is not null or undefined + assertParamExists('anyofArray', 'oneOfParam', oneOfParam) + // verify required parameter 'anyofArrayRequest' is not null or undefined + assertParamExists('anyofArray', 'anyofArrayRequest', anyofArrayRequest) + const localVarPath = `/anyof-array` + .replace(`{${"oneOfParam"}}`, encodeURIComponent(String(oneOfParam))); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(anyofArrayRequest, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * * @summary Health check endpoint @@ -2819,6 +2940,19 @@ export const FakeApiAxiosParamCreator = function (configuration?: Configuration) export const FakeApiFp = function(configuration?: Configuration) { const localVarAxiosParamCreator = FakeApiAxiosParamCreator(configuration) return { + /** + * Response with anyof containing arrays and a oneof parameter as well as a map request body + * @param {AnyofArrayOneOfParamParameter} oneOfParam + * @param {AnyofArrayRequest} anyofArrayRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async anyofArray(oneOfParam: AnyofArrayOneOfParamParameter, anyofArrayRequest: AnyofArrayRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.anyofArray(oneOfParam, anyofArrayRequest, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['FakeApi.anyofArray']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, /** * * @summary Health check endpoint @@ -3098,6 +3232,16 @@ export const FakeApiFp = function(configuration?: Configuration) { export const FakeApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { const localVarFp = FakeApiFp(configuration) return { + /** + * Response with anyof containing arrays and a oneof parameter as well as a map request body + * @param {AnyofArrayOneOfParamParameter} oneOfParam + * @param {AnyofArrayRequest} anyofArrayRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + anyofArray(oneOfParam: AnyofArrayOneOfParamParameter, anyofArrayRequest: AnyofArrayRequest, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.anyofArray(oneOfParam, anyofArrayRequest, options).then((request) => request(axios, basePath)); + }, /** * * @summary Health check endpoint @@ -3320,6 +3464,18 @@ export const FakeApiFactory = function (configuration?: Configuration, basePath? * @extends {BaseAPI} */ export class FakeApi extends BaseAPI { + /** + * Response with anyof containing arrays and a oneof parameter as well as a map request body + * @param {AnyofArrayOneOfParamParameter} oneOfParam + * @param {AnyofArrayRequest} anyofArrayRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof FakeApi + */ + public anyofArray(oneOfParam: AnyofArrayOneOfParamParameter, anyofArrayRequest: AnyofArrayRequest, options?: RawAxiosRequestConfig) { + return FakeApiFp(this.configuration).anyofArray(oneOfParam, anyofArrayRequest, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @summary Health check endpoint diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/.openapi-generator/FILES b/samples/openapi3/client/petstore/java/jersey2-java8/.openapi-generator/FILES index 78d8fe209b3a..01fa6e215e48 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/java/jersey2-java8/.openapi-generator/FILES @@ -8,6 +8,12 @@ build.sbt docs/AdditionalPropertiesClass.md docs/Animal.md docs/AnotherFakeApi.md +docs/AnyOf1.md +docs/AnyOf2.md +docs/AnyofArray200Response.md +docs/AnyofArrayOneOfParamParameter.md +docs/AnyofArrayRequest.md +docs/AnyofArrayRequestMapProp.md docs/Apple.md docs/AppleReq.md docs/ArrayOfArrayOfNumberOnly.md @@ -124,6 +130,12 @@ src/main/java/org/openapitools/client/auth/OAuthFlow.java src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java src/main/java/org/openapitools/client/model/Animal.java +src/main/java/org/openapitools/client/model/AnyOf1.java +src/main/java/org/openapitools/client/model/AnyOf2.java +src/main/java/org/openapitools/client/model/AnyofArray200Response.java +src/main/java/org/openapitools/client/model/AnyofArrayOneOfParamParameter.java +src/main/java/org/openapitools/client/model/AnyofArrayRequest.java +src/main/java/org/openapitools/client/model/AnyofArrayRequestMapProp.java src/main/java/org/openapitools/client/model/Apple.java src/main/java/org/openapitools/client/model/AppleReq.java src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java @@ -197,3 +209,9 @@ src/main/java/org/openapitools/client/model/TriangleInterface.java src/main/java/org/openapitools/client/model/User.java src/main/java/org/openapitools/client/model/Whale.java src/main/java/org/openapitools/client/model/Zebra.java +src/test/java/org/openapitools/client/model/AnyOf1Test.java +src/test/java/org/openapitools/client/model/AnyOf2Test.java +src/test/java/org/openapitools/client/model/AnyofArray200ResponseTest.java +src/test/java/org/openapitools/client/model/AnyofArrayOneOfParamParameterTest.java +src/test/java/org/openapitools/client/model/AnyofArrayRequestMapPropTest.java +src/test/java/org/openapitools/client/model/AnyofArrayRequestTest.java diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/README.md b/samples/openapi3/client/petstore/java/jersey2-java8/README.md index 10ddb9fe63f7..8cb176fadcf2 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/README.md +++ b/samples/openapi3/client/petstore/java/jersey2-java8/README.md @@ -142,6 +142,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags *DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooGet) | **GET** /foo | +*FakeApi* | [**anyofArray**](docs/FakeApi.md#anyofArray) | **POST** /anyof-array | *FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint *FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | *FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | @@ -189,6 +190,12 @@ Class | Method | HTTP request | Description - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) - [Animal](docs/Animal.md) + - [AnyOf1](docs/AnyOf1.md) + - [AnyOf2](docs/AnyOf2.md) + - [AnyofArray200Response](docs/AnyofArray200Response.md) + - [AnyofArrayOneOfParamParameter](docs/AnyofArrayOneOfParamParameter.md) + - [AnyofArrayRequest](docs/AnyofArrayRequest.md) + - [AnyofArrayRequestMapProp](docs/AnyofArrayRequestMapProp.md) - [Apple](docs/Apple.md) - [AppleReq](docs/AppleReq.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/api/openapi.yaml b/samples/openapi3/client/petstore/java/jersey2-java8/api/openapi.yaml index 25e78fa9e305..e71f7f21ec54 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/api/openapi.yaml +++ b/samples/openapi3/client/petstore/java/jersey2-java8/api/openapi.yaml @@ -1177,6 +1177,37 @@ paths: - fake x-accepts: - application/json + /anyof-array: + post: + description: Response with anyof containing arrays and a oneof parameter as + well as a map request body + operationId: anyof-array + parameters: + - explode: false + in: path + name: oneOfParam + required: true + schema: + $ref: '#/components/schemas/anyof_array_oneOfParam_parameter' + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/anyof_array_request' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/anyof_array_200_response' + description: Response + tags: + - fake + x-content-type: application/json + x-accepts: + - application/json /fake/{petId}/uploadImageWithRequiredFile: post: description: "" @@ -1263,6 +1294,15 @@ paths: x-accepts: - application/json components: + parameters: + oneOfParam: + explode: false + in: path + name: oneOfParam + required: true + schema: + $ref: '#/components/schemas/anyof_array_oneOfParam_parameter' + style: simple requestBodies: UserArray: content: @@ -1483,6 +1523,30 @@ components: type: object xml: name: Pet + AnyOf1: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + AnyOf2: + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object ApiResponse: example: code: 0 @@ -2432,6 +2496,31 @@ components: someProperty: type: string type: object + anyof_array_request_mapProp: + oneOf: + - additionalProperties: true + type: object + - default: "false" + enum: + - "true" + - "false" + type: string + anyof_array_request: + properties: + mapProp: + $ref: '#/components/schemas/anyof_array_request_mapProp' + anyof_array_oneOfParam_parameter: + oneOf: + - type: integer + - type: string + anyof_array_200_response: + anyOf: + - items: + $ref: '#/components/schemas/AnyOf1' + type: array + - items: + $ref: '#/components/schemas/AnyOf2' + type: array uploadFileWithRequiredFile_request: properties: additionalMetadata: diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyOf1.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyOf1.md new file mode 100644 index 000000000000..535e88eb3b9d --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyOf1.md @@ -0,0 +1,15 @@ + + +# AnyOf1 + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | | [optional] | +|**type** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyOf2.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyOf2.md new file mode 100644 index 000000000000..53a9d35144d4 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyOf2.md @@ -0,0 +1,15 @@ + + +# AnyOf2 + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**code** | **Integer** | | [optional] | +|**type** | **String** | | [optional] | +|**message** | **String** | | [optional] | + + + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArray200Response.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArray200Response.md new file mode 100644 index 000000000000..6240d001949a --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArray200Response.md @@ -0,0 +1,37 @@ + + +# AnyofArray200Response + +## anyOf schemas +* [List](List.md) +* [List](List.md) + +## Example +```java +// Import classes: +import org.openapitools.client.model.AnyofArray200Response; +import org.openapitools.client.model.List; +import org.openapitools.client.model.List; + +public class Example { + public static void main(String[] args) { + AnyofArray200Response exampleAnyofArray200Response = new AnyofArray200Response(); + + // create a new List + List exampleList = new List(); + // set AnyofArray200Response to List + exampleAnyofArray200Response.setActualInstance(exampleList); + // to get back the List set earlier + List testList = (List) exampleAnyofArray200Response.getActualInstance(); + + // create a new List + List exampleList = new List(); + // set AnyofArray200Response to List + exampleAnyofArray200Response.setActualInstance(exampleList); + // to get back the List set earlier + List testList = (List) exampleAnyofArray200Response.getActualInstance(); + } +} +``` + + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArrayOneOfParamParameter.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArrayOneOfParamParameter.md new file mode 100644 index 000000000000..5b032aba8efa --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArrayOneOfParamParameter.md @@ -0,0 +1,37 @@ + + +# AnyofArrayOneOfParamParameter + +## oneOf schemas +* [Integer](Integer.md) +* [String](String.md) + +## Example +```java +// Import classes: +import org.openapitools.client.model.AnyofArrayOneOfParamParameter; +import org.openapitools.client.model.Integer; +import org.openapitools.client.model.String; + +public class Example { + public static void main(String[] args) { + AnyofArrayOneOfParamParameter exampleAnyofArrayOneOfParamParameter = new AnyofArrayOneOfParamParameter(); + + // create a new Integer + Integer exampleInteger = new Integer(); + // set AnyofArrayOneOfParamParameter to Integer + exampleAnyofArrayOneOfParamParameter.setActualInstance(exampleInteger); + // to get back the Integer set earlier + Integer testInteger = (Integer) exampleAnyofArrayOneOfParamParameter.getActualInstance(); + + // create a new String + String exampleString = new String(); + // set AnyofArrayOneOfParamParameter to String + exampleAnyofArrayOneOfParamParameter.setActualInstance(exampleString); + // to get back the String set earlier + String testString = (String) exampleAnyofArrayOneOfParamParameter.getActualInstance(); + } +} +``` + + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArrayRequest.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArrayRequest.md new file mode 100644 index 000000000000..25da913eb2c9 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArrayRequest.md @@ -0,0 +1,13 @@ + + +# AnyofArrayRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**mapProp** | [**AnyofArrayRequestMapProp**](AnyofArrayRequestMapProp.md) | | [optional] | + + + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArrayRequestMapProp.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArrayRequestMapProp.md new file mode 100644 index 000000000000..cfcae5e9129a --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/AnyofArrayRequestMapProp.md @@ -0,0 +1,37 @@ + + +# AnyofArrayRequestMapProp + +## oneOf schemas +* [Map](Map.md) +* [String](String.md) + +## Example +```java +// Import classes: +import org.openapitools.client.model.AnyofArrayRequestMapProp; +import org.openapitools.client.model.Map; +import org.openapitools.client.model.String; + +public class Example { + public static void main(String[] args) { + AnyofArrayRequestMapProp exampleAnyofArrayRequestMapProp = new AnyofArrayRequestMapProp(); + + // create a new Map + Map exampleMap = new Map(); + // set AnyofArrayRequestMapProp to Map + exampleAnyofArrayRequestMapProp.setActualInstance(exampleMap); + // to get back the Map set earlier + Map testMap = (Map) exampleAnyofArrayRequestMapProp.getActualInstance(); + + // create a new String + String exampleString = new String(); + // set AnyofArrayRequestMapProp to String + exampleAnyofArrayRequestMapProp.setActualInstance(exampleString); + // to get back the String set earlier + String testString = (String) exampleAnyofArrayRequestMapProp.getActualInstance(); + } +} +``` + + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/FakeApi.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/FakeApi.md index 3816afc1ce7c..a48b3fe0e745 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/FakeApi.md @@ -4,6 +4,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |------------- | ------------- | -------------| +| [**anyofArray**](FakeApi.md#anyofArray) | **POST** /anyof-array | | | [**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint | | [**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | | | [**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | | @@ -26,6 +27,73 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* +## anyofArray + +> AnyofArray200Response anyofArray(oneOfParam, anyofArrayRequest) + + + +Response with anyof containing arrays and a oneof parameter as well as a map request body + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.model.*; +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); + AnyofArrayOneOfParamParameter oneOfParam = new AnyofArrayOneOfParamParameter(); // AnyofArrayOneOfParamParameter | + AnyofArrayRequest anyofArrayRequest = new AnyofArrayRequest(); // AnyofArrayRequest | + try { + AnyofArray200Response result = apiInstance.anyofArray(oneOfParam, anyofArrayRequest); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FakeApi#anyofArray"); + 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 | +|------------- | ------------- | ------------- | -------------| +| **oneOfParam** | [**AnyofArrayOneOfParamParameter**](AnyofArrayOneOfParamParameter.md)| | | +| **anyofArrayRequest** | [**AnyofArrayRequest**](AnyofArrayRequest.md)| | | + +### Return type + +[**AnyofArray200Response**](AnyofArray200Response.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Response | - | + + ## fakeHealthGet > HealthCheckResult fakeHealthGet() diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeApi.java index 2255b220e146..8a4153de15bb 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/api/FakeApi.java @@ -8,6 +8,9 @@ import javax.ws.rs.core.GenericType; +import org.openapitools.client.model.AnyofArray200Response; +import org.openapitools.client.model.AnyofArrayOneOfParamParameter; +import org.openapitools.client.model.AnyofArrayRequest; import java.math.BigDecimal; import org.openapitools.client.model.Client; import java.io.File; @@ -56,6 +59,56 @@ public void setApiClient(ApiClient apiClient) { this.apiClient = apiClient; } + /** + * + * Response with anyof containing arrays and a oneof parameter as well as a map request body + * @param oneOfParam (required) + * @param anyofArrayRequest (required) + * @return AnyofArray200Response + * @throws ApiException if fails to make API call + * @http.response.details + + + +
Status Code Description Response Headers
200 Response -
+ */ + public AnyofArray200Response anyofArray(AnyofArrayOneOfParamParameter oneOfParam, AnyofArrayRequest anyofArrayRequest) throws ApiException { + return anyofArrayWithHttpInfo(oneOfParam, anyofArrayRequest).getData(); + } + + /** + * + * Response with anyof containing arrays and a oneof parameter as well as a map request body + * @param oneOfParam (required) + * @param anyofArrayRequest (required) + * @return ApiResponse<AnyofArray200Response> + * @throws ApiException if fails to make API call + * @http.response.details + + + +
Status Code Description Response Headers
200 Response -
+ */ + public ApiResponse anyofArrayWithHttpInfo(AnyofArrayOneOfParamParameter oneOfParam, AnyofArrayRequest anyofArrayRequest) throws ApiException { + // Check required parameters + if (oneOfParam == null) { + throw new ApiException(400, "Missing the required parameter 'oneOfParam' when calling anyofArray"); + } + if (anyofArrayRequest == null) { + throw new ApiException(400, "Missing the required parameter 'anyofArrayRequest' when calling anyofArray"); + } + + // Path parameters + String localVarPath = "/anyof-array" + .replaceAll("\\{oneOfParam}", apiClient.escapeString(oneOfParam.toString())); + + String localVarAccept = apiClient.selectHeaderAccept("application/json"); + String localVarContentType = apiClient.selectHeaderContentType("application/json"); + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI("FakeApi.anyofArray", localVarPath, "POST", new ArrayList<>(), anyofArrayRequest, + new LinkedHashMap<>(), new LinkedHashMap<>(), new LinkedHashMap<>(), localVarAccept, localVarContentType, + null, localVarReturnType, false); + } /** * Health check endpoint * diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyOf1.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyOf1.java new file mode 100644 index 000000000000..ff460059c073 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyOf1.java @@ -0,0 +1,171 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +/** + * AnyOf1 + */ +@JsonPropertyOrder({ + AnyOf1.JSON_PROPERTY_CODE, + AnyOf1.JSON_PROPERTY_TYPE, + AnyOf1.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +public class AnyOf1 { + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public AnyOf1() { + } + + public AnyOf1 code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Integer getCode() { + return code; + } + + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(Integer code) { + this.code = code; + } + + + public AnyOf1 type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + + public AnyOf1 message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getMessage() { + return message; + } + + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + + /** + * Return true if this AnyOf1 object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnyOf1 anyOf1 = (AnyOf1) o; + return Objects.equals(this.code, anyOf1.code) && + Objects.equals(this.type, anyOf1.type) && + Objects.equals(this.message, anyOf1.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnyOf1 {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyOf2.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyOf2.java new file mode 100644 index 000000000000..c7692c2d3404 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyOf2.java @@ -0,0 +1,171 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +/** + * AnyOf2 + */ +@JsonPropertyOrder({ + AnyOf2.JSON_PROPERTY_CODE, + AnyOf2.JSON_PROPERTY_TYPE, + AnyOf2.JSON_PROPERTY_MESSAGE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +public class AnyOf2 { + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public AnyOf2() { + } + + public AnyOf2 code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * @return code + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Integer getCode() { + return code; + } + + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(Integer code) { + this.code = code; + } + + + public AnyOf2 type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getType() { + return type; + } + + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + + public AnyOf2 message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * @return message + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getMessage() { + return message; + } + + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + + /** + * Return true if this AnyOf2 object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnyOf2 anyOf2 = (AnyOf2) o; + return Objects.equals(this.code, anyOf2.code) && + Objects.equals(this.type, anyOf2.type) && + Objects.equals(this.message, anyOf2.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnyOf2 {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArray200Response.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArray200Response.java new file mode 100644 index 000000000000..a27239cbd1c5 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArray200Response.java @@ -0,0 +1,267 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.List; +import org.openapitools.client.model.AnyOf1; +import org.openapitools.client.model.AnyOf2; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.openapitools.client.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +@JsonDeserialize(using=AnyofArray200Response.AnyofArray200ResponseDeserializer.class) +@JsonSerialize(using = AnyofArray200Response.AnyofArray200ResponseSerializer.class) +public class AnyofArray200Response extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AnyofArray200Response.class.getName()); + + public static class AnyofArray200ResponseSerializer extends StdSerializer { + public AnyofArray200ResponseSerializer(Class t) { + super(t); + } + + public AnyofArray200ResponseSerializer() { + this(null); + } + + @Override + public void serialize(AnyofArray200Response value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AnyofArray200ResponseDeserializer extends StdDeserializer { + public AnyofArray200ResponseDeserializer() { + this(AnyofArray200Response.class); + } + + public AnyofArray200ResponseDeserializer(Class vc) { + super(vc); + } + + @Override + public AnyofArray200Response deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize List + try { + if (token == JsonToken.START_ARRAY) { + final TypeReference> ref = new TypeReference>(){}; + deserialized = tree.traverse(jp.getCodec()).readValueAs(ref); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'List'"); + } + AnyofArray200Response ret = new AnyofArray200Response(); + ret.setActualInstance(deserialized); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'List'", e); + } + + // deserialize List + try { + if (token == JsonToken.START_ARRAY) { + final TypeReference> ref = new TypeReference>(){}; + deserialized = tree.traverse(jp.getCodec()).readValueAs(ref); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'List'"); + } + AnyofArray200Response ret = new AnyofArray200Response(); + ret.setActualInstance(deserialized); + return ret; + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'List'", e); + } + + throw new IOException(String.format("Failed deserialization for AnyofArray200Response: no match found")); + } + + /** + * Handle deserialization of the 'null' value. + */ + @Override + public AnyofArray200Response getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "AnyofArray200Response cannot be null"); + } + } + + // store a list of schema names defined in anyOf + public static final Map> schemas = new HashMap<>(); + + public AnyofArray200Response() { + super("anyOf", Boolean.FALSE); + } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + */ + @JsonAnySetter + public AnyofArray200Response putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap<>(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** + * Return true if this anyof_array_200_response object is equal to o. + */ + @Override + public boolean equals(Object o) { + return super.equals(o) && Objects.equals(this.additionalProperties, ((AnyofArray200Response)o).additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties); + } + public AnyofArray200Response(List o) { + super("anyOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("List", new GenericType>() { + }); + schemas.put("List", new GenericType>() { + }); + JSON.registerDescendants(AnyofArray200Response.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return AnyofArray200Response.schemas; + } + + /** + * Set the instance that matches the anyOf child schema, check + * the instance parameter is valid against the anyOf child schemas: + * List, List + * + * It could be an instance of the 'anyOf' schemas. + * The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(List.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be List, List"); + } + + /** + * Get the actual instance, which can be the following: + * List, List + * + * @return The actual instance (List, List) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `List`. If the actual instance is not `List`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `List` + * @throws ClassCastException if the instance is not `List` + */ + public List getListAnyOf1() throws ClassCastException { + return (List)super.getActualInstance(); + } + + /** + * Get the actual instance of `List`. If the actual instance is not `List`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `List` + * @throws ClassCastException if the instance is not `List` + */ + public List getListAnyOf2() throws ClassCastException { + return (List)super.getActualInstance(); + } + +} + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArrayOneOfParamParameter.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArrayOneOfParamParameter.java new file mode 100644 index 000000000000..ea982de39d9e --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArrayOneOfParamParameter.java @@ -0,0 +1,284 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + +import com.fasterxml.jackson.core.type.TypeReference; + +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.openapitools.client.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +@JsonDeserialize(using = AnyofArrayOneOfParamParameter.AnyofArrayOneOfParamParameterDeserializer.class) +@JsonSerialize(using = AnyofArrayOneOfParamParameter.AnyofArrayOneOfParamParameterSerializer.class) +public class AnyofArrayOneOfParamParameter extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AnyofArrayOneOfParamParameter.class.getName()); + + public static class AnyofArrayOneOfParamParameterSerializer extends StdSerializer { + public AnyofArrayOneOfParamParameterSerializer(Class t) { + super(t); + } + + public AnyofArrayOneOfParamParameterSerializer() { + this(null); + } + + @Override + public void serialize(AnyofArrayOneOfParamParameter value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AnyofArrayOneOfParamParameterDeserializer extends StdDeserializer { + public AnyofArrayOneOfParamParameterDeserializer() { + this(AnyofArrayOneOfParamParameter.class); + } + + public AnyofArrayOneOfParamParameterDeserializer(Class vc) { + super(vc); + } + + @Override + public AnyofArrayOneOfParamParameter deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize Integer + try { + boolean attemptParsing = true; + attemptParsing = typeCoercion; //respect type coercion setting + if (!attemptParsing) { + attemptParsing |= (token == JsonToken.VALUE_NUMBER_INT); + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Integer.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'Integer'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Integer'", e); + } + + // deserialize String + try { + boolean attemptParsing = true; + attemptParsing = typeCoercion; //respect type coercion setting + if (!attemptParsing) { + attemptParsing |= (token == JsonToken.VALUE_STRING); + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(String.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + if (match == 1) { + AnyofArrayOneOfParamParameter ret = new AnyofArrayOneOfParamParameter(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException(String.format("Failed deserialization for AnyofArrayOneOfParamParameter: %d classes match result, expected 1", match)); + } + + /** + * Handle deserialization of the 'null' value. + */ + @Override + public AnyofArrayOneOfParamParameter getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "AnyofArrayOneOfParamParameter cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public AnyofArrayOneOfParamParameter() { + super("oneOf", Boolean.FALSE); + } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + */ + @JsonAnySetter + public AnyofArrayOneOfParamParameter putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap<>(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** + * Return true if this anyof_array_oneOfParam_parameter object is equal to o. + */ + @Override + public boolean equals(Object o) { + return super.equals(o) && Objects.equals(this.additionalProperties, ((AnyofArrayOneOfParamParameter)o).additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties); + } + public AnyofArrayOneOfParamParameter(Integer o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AnyofArrayOneOfParamParameter(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("Integer", new GenericType() { + }); + schemas.put("String", new GenericType() { + }); + JSON.registerDescendants(AnyofArrayOneOfParamParameter.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return AnyofArrayOneOfParamParameter.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * Integer, String + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(Integer.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(String.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be Integer, String"); + } + + /** + * Get the actual instance, which can be the following: + * Integer, String + * + * @return The actual instance (Integer, String) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `Integer`. If the actual instance is not `Integer`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Integer` + * @throws ClassCastException if the instance is not `Integer` + */ + public Integer getInteger() throws ClassCastException { + return (Integer)super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String)super.getActualInstance(); + } + +} + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArrayRequest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArrayRequest.java new file mode 100644 index 000000000000..bd9e793c85a8 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArrayRequest.java @@ -0,0 +1,111 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.client.model.AnyofArrayRequestMapProp; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + + +/** + * AnyofArrayRequest + */ +@JsonPropertyOrder({ + AnyofArrayRequest.JSON_PROPERTY_MAP_PROP +}) +@JsonTypeName("anyof_array_request") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +public class AnyofArrayRequest { + public static final String JSON_PROPERTY_MAP_PROP = "mapProp"; + private AnyofArrayRequestMapProp mapProp; + + public AnyofArrayRequest() { + } + + public AnyofArrayRequest mapProp(AnyofArrayRequestMapProp mapProp) { + this.mapProp = mapProp; + return this; + } + + /** + * Get mapProp + * @return mapProp + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MAP_PROP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public AnyofArrayRequestMapProp getMapProp() { + return mapProp; + } + + + @JsonProperty(JSON_PROPERTY_MAP_PROP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMapProp(AnyofArrayRequestMapProp mapProp) { + this.mapProp = mapProp; + } + + + /** + * Return true if this anyof_array_request object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnyofArrayRequest anyofArrayRequest = (AnyofArrayRequest) o; + return Objects.equals(this.mapProp, anyofArrayRequest.mapProp); + } + + @Override + public int hashCode() { + return Objects.hash(mapProp); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnyofArrayRequest {\n"); + sb.append(" mapProp: ").append(toIndentedString(mapProp)).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/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArrayRequestMapProp.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArrayRequestMapProp.java new file mode 100644 index 000000000000..4d23543102c9 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/AnyofArrayRequestMapProp.java @@ -0,0 +1,285 @@ +/* + * 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.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import java.util.Objects; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import org.openapitools.client.JSON; + +import com.fasterxml.jackson.core.type.TypeReference; + +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import org.openapitools.client.JSON; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT") +@JsonDeserialize(using = AnyofArrayRequestMapProp.AnyofArrayRequestMapPropDeserializer.class) +@JsonSerialize(using = AnyofArrayRequestMapProp.AnyofArrayRequestMapPropSerializer.class) +public class AnyofArrayRequestMapProp extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AnyofArrayRequestMapProp.class.getName()); + + public static class AnyofArrayRequestMapPropSerializer extends StdSerializer { + public AnyofArrayRequestMapPropSerializer(Class t) { + super(t); + } + + public AnyofArrayRequestMapPropSerializer() { + this(null); + } + + @Override + public void serialize(AnyofArrayRequestMapProp value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AnyofArrayRequestMapPropDeserializer extends StdDeserializer { + public AnyofArrayRequestMapPropDeserializer() { + this(AnyofArrayRequestMapProp.class); + } + + public AnyofArrayRequestMapPropDeserializer(Class vc) { + super(vc); + } + + @Override + public AnyofArrayRequestMapProp deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize Map + try { + boolean attemptParsing = true; + attemptParsing = typeCoercion; //respect type coercion setting + if (!attemptParsing) { + } + if (attemptParsing) { + final TypeReference> ref = new TypeReference>(){}; + deserialized = tree.traverse(jp.getCodec()).readValueAs(ref); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'Map'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Map'", e); + } + + // deserialize String + try { + boolean attemptParsing = true; + attemptParsing = typeCoercion; //respect type coercion setting + if (!attemptParsing) { + attemptParsing |= (token == JsonToken.VALUE_STRING); + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(String.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + if (match == 1) { + AnyofArrayRequestMapProp ret = new AnyofArrayRequestMapProp(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException(String.format("Failed deserialization for AnyofArrayRequestMapProp: %d classes match result, expected 1", match)); + } + + /** + * Handle deserialization of the 'null' value. + */ + @Override + public AnyofArrayRequestMapProp getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "AnyofArrayRequestMapProp cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public AnyofArrayRequestMapProp() { + super("oneOf", Boolean.FALSE); + } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + */ + @JsonAnySetter + public AnyofArrayRequestMapProp putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap<>(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** + * Return true if this anyof_array_request_mapProp object is equal to o. + */ + @Override + public boolean equals(Object o) { + return super.equals(o) && Objects.equals(this.additionalProperties, ((AnyofArrayRequestMapProp)o).additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties); + } + public AnyofArrayRequestMapProp(Map o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AnyofArrayRequestMapProp(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("Map", new GenericType>() { + }); + schemas.put("String", new GenericType() { + }); + JSON.registerDescendants(AnyofArrayRequestMapProp.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return AnyofArrayRequestMapProp.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check + * the instance parameter is valid against the oneOf child schemas: + * Map, String + * + * It could be an instance of the 'oneOf' schemas. + * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(Map.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(String.class, instance, new HashSet<>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be Map, String"); + } + + /** + * Get the actual instance, which can be the following: + * Map, String + * + * @return The actual instance (Map, String) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `Map`. If the actual instance is not `Map`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Map` + * @throws ClassCastException if the instance is not `Map` + */ + public Map getMapStringObject() throws ClassCastException { + return (Map)super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String)super.getActualInstance(); + } + +} + diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java index 210b4f21aaa4..28b1a4f24979 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/EnumTest.java @@ -135,9 +135,9 @@ public static EnumStringRequiredEnum fromValue(String value) { * Gets or Sets enumInteger */ public enum EnumIntegerEnum { - NUMBER_1(1), + NUMBER_1(Integer.valueOf(1)), - NUMBER_MINUS_1(-1); + NUMBER_MINUS_1(Integer.valueOf(-1)); private Integer value; @@ -173,9 +173,9 @@ public static EnumIntegerEnum fromValue(Integer value) { * Gets or Sets enumIntegerOnly */ public enum EnumIntegerOnlyEnum { - NUMBER_2(2), + NUMBER_2(Integer.valueOf(2)), - NUMBER_MINUS_2(-2); + NUMBER_MINUS_2(Integer.valueOf(-2)); private Integer value; @@ -211,9 +211,9 @@ public static EnumIntegerOnlyEnum fromValue(Integer value) { * Gets or Sets enumNumber */ public enum EnumNumberEnum { - NUMBER_1_DOT_1(1.1), + NUMBER_1_DOT_1(Double.valueOf(1.1)), - NUMBER_MINUS_1_DOT_2(-1.2); + NUMBER_MINUS_1_DOT_2(Double.valueOf(-1.2)); private Double value; diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/GmFruit.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/GmFruit.java index 2206205198b2..5396cb028e1c 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/GmFruit.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/GmFruit.java @@ -41,10 +41,12 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -87,26 +89,42 @@ public GmFruit deserialize(JsonParser jp, DeserializationContext ctxt) throws IO JsonNode tree = jp.readValueAsTree(); Object deserialized = null; - // deserialize Apple + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize Apple (nullable) try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Apple.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Apple.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Apple'"); + } GmFruit ret = new GmFruit(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'GmFruit'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Apple'", e); } // deserialize Banana try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Banana.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Banana.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Banana'"); + } GmFruit ret = new GmFruit(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'GmFruit'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Banana'", e); } throw new IOException(String.format("Failed deserialization for GmFruit: no match found")); @@ -129,7 +147,7 @@ public GmFruit() { } public GmFruit(Apple o) { - super("anyOf", Boolean.FALSE); + super("anyOf", Boolean.TRUE); setActualInstance(o); } @@ -186,23 +204,23 @@ public Object getActualInstance() { } /** - * Get the actual instance of `Apple`. If the actual instance is not `Apple`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Apple` - * @throws ClassCastException if the instance is not `Apple` - */ + * Get the actual instance of `Apple`. If the actual instance is not `Apple`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Apple` + * @throws ClassCastException if the instance is not `Apple` + */ public Apple getApple() throws ClassCastException { return (Apple)super.getActualInstance(); } /** - * Get the actual instance of `Banana`. If the actual instance is not `Banana`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Banana` - * @throws ClassCastException if the instance is not `Banana` - */ + * Get the actual instance of `Banana`. If the actual instance is not `Banana`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Banana` + * @throws ClassCastException if the instance is not `Banana` + */ public Banana getBanana() throws ClassCastException { return (Banana)super.getActualInstance(); } diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/MammalAnyof.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/MammalAnyof.java index f50608c5960f..e53bd13b7135 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/MammalAnyof.java +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/model/MammalAnyof.java @@ -48,10 +48,12 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -104,37 +106,60 @@ public MammalAnyof deserialize(JsonParser jp, DeserializationContext ctxt) throw ret.setActualInstance(deserialized); return ret; } - // deserialize Pig + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize Whale try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Pig.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Whale.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Whale'"); + } MammalAnyof ret = new MammalAnyof(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'MammalAnyof'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Whale'", e); } - // deserialize Whale + // deserialize Zebra try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Whale.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Zebra.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Zebra'"); + } MammalAnyof ret = new MammalAnyof(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'MammalAnyof'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Zebra'", e); } - // deserialize Zebra + // deserialize Pig try { - deserialized = tree.traverse(jp.getCodec()).readValueAs(Zebra.class); + boolean attemptParsing = true; + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(Pig.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + log.log(Level.FINER, "Input data matches schema 'Pig'"); + } MammalAnyof ret = new MammalAnyof(); ret.setActualInstance(deserialized); return ret; } catch (Exception e) { - // deserialization failed, continue, log to help debugging - log.log(Level.FINER, "Input data does not match 'MammalAnyof'", e); + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'Pig'", e); } throw new IOException(String.format("Failed deserialization for MammalAnyof: no match found")); @@ -205,17 +230,17 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties); } - public MammalAnyof(Pig o) { + public MammalAnyof(Whale o) { super("anyOf", Boolean.FALSE); setActualInstance(o); } - public MammalAnyof(Whale o) { + public MammalAnyof(Zebra o) { super("anyOf", Boolean.FALSE); setActualInstance(o); } - public MammalAnyof(Zebra o) { + public MammalAnyof(Pig o) { super("anyOf", Boolean.FALSE); setActualInstance(o); } @@ -252,17 +277,17 @@ public Map> getSchemas() { */ @Override public void setActualInstance(Object instance) { - if (JSON.isInstanceOf(Pig.class, instance, new HashSet<>())) { + if (JSON.isInstanceOf(Whale.class, instance, new HashSet<>())) { super.setActualInstance(instance); return; } - if (JSON.isInstanceOf(Whale.class, instance, new HashSet<>())) { + if (JSON.isInstanceOf(Zebra.class, instance, new HashSet<>())) { super.setActualInstance(instance); return; } - if (JSON.isInstanceOf(Zebra.class, instance, new HashSet<>())) { + if (JSON.isInstanceOf(Pig.class, instance, new HashSet<>())) { super.setActualInstance(instance); return; } @@ -282,37 +307,37 @@ public Object getActualInstance() { } /** - * Get the actual instance of `Pig`. If the actual instance is not `Pig`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Pig` - * @throws ClassCastException if the instance is not `Pig` - */ - public Pig getPig() throws ClassCastException { - return (Pig)super.getActualInstance(); - } - - /** - * Get the actual instance of `Whale`. If the actual instance is not `Whale`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Whale` - * @throws ClassCastException if the instance is not `Whale` - */ + * Get the actual instance of `Whale`. If the actual instance is not `Whale`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Whale` + * @throws ClassCastException if the instance is not `Whale` + */ public Whale getWhale() throws ClassCastException { return (Whale)super.getActualInstance(); } /** - * Get the actual instance of `Zebra`. If the actual instance is not `Zebra`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Zebra` - * @throws ClassCastException if the instance is not `Zebra` - */ + * Get the actual instance of `Zebra`. If the actual instance is not `Zebra`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Zebra` + * @throws ClassCastException if the instance is not `Zebra` + */ public Zebra getZebra() throws ClassCastException { return (Zebra)super.getActualInstance(); } + /** + * Get the actual instance of `Pig`. If the actual instance is not `Pig`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `Pig` + * @throws ClassCastException if the instance is not `Pig` + */ + public Pig getPig() throws ClassCastException { + return (Pig)super.getActualInstance(); + } + } diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyOf1Test.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyOf1Test.java new file mode 100644 index 000000000000..7e2cfce74e95 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyOf1Test.java @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyOf1 + */ +public class AnyOf1Test { + private final AnyOf1 model = new AnyOf1(); + + /** + * Model tests for AnyOf1 + */ + @Test + public void testAnyOf1() { + // TODO: test AnyOf1 + } + + /** + * Test the property 'code' + */ + @Test + public void codeTest() { + // TODO: test code + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } + +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyOf2Test.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyOf2Test.java new file mode 100644 index 000000000000..f8b844689aa0 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyOf2Test.java @@ -0,0 +1,65 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyOf2 + */ +public class AnyOf2Test { + private final AnyOf2 model = new AnyOf2(); + + /** + * Model tests for AnyOf2 + */ + @Test + public void testAnyOf2() { + // TODO: test AnyOf2 + } + + /** + * Test the property 'code' + */ + @Test + public void codeTest() { + // TODO: test code + } + + /** + * Test the property 'type' + */ + @Test + public void typeTest() { + // TODO: test type + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } + +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArray200ResponseTest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArray200ResponseTest.java new file mode 100644 index 000000000000..69dd9557b9b7 --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArray200ResponseTest.java @@ -0,0 +1,39 @@ +/* + * 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.JsonTypeName; +import java.util.List; +import org.openapitools.client.model.AnyOf1; +import org.openapitools.client.model.AnyOf2; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyofArray200Response + */ +public class AnyofArray200ResponseTest { + private final AnyofArray200Response model = new AnyofArray200Response(); + + /** + * Model tests for AnyofArray200Response + */ + @Test + public void testAnyofArray200Response() { + // TODO: test AnyofArray200Response + } + +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArrayOneOfParamParameterTest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArrayOneOfParamParameterTest.java new file mode 100644 index 000000000000..8ad06338017b --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArrayOneOfParamParameterTest.java @@ -0,0 +1,36 @@ +/* + * 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.JsonTypeName; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyofArrayOneOfParamParameter + */ +public class AnyofArrayOneOfParamParameterTest { + private final AnyofArrayOneOfParamParameter model = new AnyofArrayOneOfParamParameter(); + + /** + * Model tests for AnyofArrayOneOfParamParameter + */ + @Test + public void testAnyofArrayOneOfParamParameter() { + // TODO: test AnyofArrayOneOfParamParameter + } + +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArrayRequestMapPropTest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArrayRequestMapPropTest.java new file mode 100644 index 000000000000..c604f51c53be --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArrayRequestMapPropTest.java @@ -0,0 +1,37 @@ +/* + * 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.JsonTypeName; +import java.util.Map; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyofArrayRequestMapProp + */ +public class AnyofArrayRequestMapPropTest { + private final AnyofArrayRequestMapProp model = new AnyofArrayRequestMapProp(); + + /** + * Model tests for AnyofArrayRequestMapProp + */ + @Test + public void testAnyofArrayRequestMapProp() { + // TODO: test AnyofArrayRequestMapProp + } + +} diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArrayRequestTest.java b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArrayRequestTest.java new file mode 100644 index 000000000000..17aaed22bcfa --- /dev/null +++ b/samples/openapi3/client/petstore/java/jersey2-java8/src/test/java/org/openapitools/client/model/AnyofArrayRequestTest.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import org.openapitools.client.model.AnyofArrayRequestMapProp; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for AnyofArrayRequest + */ +public class AnyofArrayRequestTest { + private final AnyofArrayRequest model = new AnyofArrayRequest(); + + /** + * Model tests for AnyofArrayRequest + */ + @Test + public void testAnyofArrayRequest() { + // TODO: test AnyofArrayRequest + } + + /** + * Test the property 'mapProp' + */ + @Test + public void mapPropTest() { + // TODO: test mapProp + } + +}