Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/utils/test_file_list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/ClientTest.java"
sha256: 325fdd5d7e2c97790c0fb44f712ab7b2ba022d7e1a5b0056f47b07f342682b6d
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java"
sha256: b1b1d31e0df17f0b68cf2747a4a53879f12acb1bf2860e45385c679c1efe9894
sha256: 074f090e5df50448f3309af83ce30690cd50c83d3675e555de7d359f42d26020
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/api/PetApiTest.java"
sha256: 8b1b8f2a2ad00ccb090873a94a5f73e328b98317d2ec715f53bd7a1accb2a023
- filename: "samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/PetTest.java"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
}
{{/isString}}
{{#isModel}}
{{^isEnum}}
{{#required}}
{{#isNullable}}
if (jsonObj.get("{{{baseName}}}") != null && !jsonObj.get("{{{baseName}}}").isJsonNull()) {
Expand All @@ -450,6 +451,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{{dataType}}}.validateJsonElement(jsonObj.get("{{{baseName}}}"));
}
{{/required}}
{{/isEnum}}
{{/isModel}}
{{#isEnum}}
{{#required}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,20 @@ paths:
- type: array
items:
type: integer
/fake/nullable-required-fields-anyof:
get:
tags:
- fake
summary: test anyOf with map of objects containing nullable required fields
description: 'Tests that anyOf deserialization works when object values contain required fields that are nullable (e.g. Record<string, { before: string | null, after: string | null }>)'
operationId: testNullableRequiredFieldsAnyOf
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/NullableFieldsMapResponse'
/fake/anyOfWIthSameErasure:
get:
description: Test route, this shouldn't cause a compiler error
Expand Down Expand Up @@ -2866,3 +2880,46 @@ components:
allOf:
- $ref: '#/components/schemas/Height'
default: 32.1
NullableFieldsValue:
description: "Object with required but nullable string fields"
type: object
properties:
before:
type: string
nullable: true
after:
type: string
nullable: true
required:
- before
- after
NullableFieldsMapSuccess:
description: "Success response containing a map of objects with nullable fields"
type: object
additionalProperties: false
properties:
status:
type: string
positions:
type: object
additionalProperties:
$ref: '#/components/schemas/NullableFieldsValue'
required:
- status
- positions
NullableFieldsMapError:
description: "Error response"
type: object
additionalProperties: false
properties:
status:
type: string
reason:
type: string
required:
- status
- reason
NullableFieldsMapResponse:
anyOf:
- $ref: '#/components/schemas/NullableFieldsMapSuccess'
- $ref: '#/components/schemas/NullableFieldsMapError'
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ docs/NewPetCategoryInlineAllof.md
docs/NewPetCategoryInlineAllofAllOfCategoryTag.md
docs/NullableClass.md
docs/NullableEnum.md
docs/NullableFieldsMapError.md
docs/NullableFieldsMapResponse.md
docs/NullableFieldsMapSuccess.md
docs/NullableFieldsValue.md
docs/NullableShape.md
docs/NumberOnly.md
docs/ObjectWithDeprecatedFields.md
Expand Down Expand Up @@ -231,6 +235,10 @@ src/main/java/org/openapitools/client/model/NewPetCategoryInlineAllof.java
src/main/java/org/openapitools/client/model/NewPetCategoryInlineAllofAllOfCategoryTag.java
src/main/java/org/openapitools/client/model/NullableClass.java
src/main/java/org/openapitools/client/model/NullableEnum.java
src/main/java/org/openapitools/client/model/NullableFieldsMapError.java
src/main/java/org/openapitools/client/model/NullableFieldsMapResponse.java
src/main/java/org/openapitools/client/model/NullableFieldsMapSuccess.java
src/main/java/org/openapitools/client/model/NullableFieldsValue.java
src/main/java/org/openapitools/client/model/NullableShape.java
src/main/java/org/openapitools/client/model/NumberOnly.java
src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java
Expand Down
5 changes: 5 additions & 0 deletions samples/client/petstore/java/okhttp-gson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Class | Method | HTTP request | Description
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**testInlineFreeformAdditionalProperties**](docs/FakeApi.md#testInlineFreeformAdditionalProperties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeApi* | [**testNullableRequiredFieldsAnyOf**](docs/FakeApi.md#testNullableRequiredFieldsAnyOf) | **GET** /fake/nullable-required-fields-anyof | test anyOf with map of objects containing nullable required fields
*FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters |
*FakeApi* | [**testStringMapReference**](docs/FakeApi.md#testStringMapReference) | **POST** /fake/stringMap-reference | test referenced string map
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
Expand Down Expand Up @@ -242,6 +243,10 @@ Class | Method | HTTP request | Description
- [NewPetCategoryInlineAllofAllOfCategoryTag](docs/NewPetCategoryInlineAllofAllOfCategoryTag.md)
- [NullableClass](docs/NullableClass.md)
- [NullableEnum](docs/NullableEnum.md)
- [NullableFieldsMapError](docs/NullableFieldsMapError.md)
- [NullableFieldsMapResponse](docs/NullableFieldsMapResponse.md)
- [NullableFieldsMapSuccess](docs/NullableFieldsMapSuccess.md)
- [NullableFieldsValue](docs/NullableFieldsValue.md)
- [NullableShape](docs/NullableShape.md)
- [NumberOnly](docs/NumberOnly.md)
- [ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
Expand Down
70 changes: 70 additions & 0 deletions samples/client/petstore/java/okhttp-gson/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,24 @@ paths:
description: successful response
x-accepts:
- application/json
/fake/nullable-required-fields-anyof:
get:
description: "Tests that anyOf deserialization works when object values contain\
\ required fields that are nullable (e.g. Record<string, { before: string\
\ | null, after: string | null }>)"
operationId: testNullableRequiredFieldsAnyOf
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/NullableFieldsMapResponse"
description: successful operation
summary: test anyOf with map of objects containing nullable required fields
tags:
- fake
x-accepts:
- application/json
/fake/anyOfWIthSameErasure:
get:
description: "Test route, this shouldn't cause a compiler error"
Expand Down Expand Up @@ -2998,6 +3016,58 @@ components:
- $ref: "#/components/schemas/Height"
default: 32.1
type: object
NullableFieldsValue:
description: Object with required but nullable string fields
example:
before: before
after: after
properties:
before:
nullable: true
type: string
after:
nullable: true
type: string
required:
- after
- before
type: object
NullableFieldsMapSuccess:
additionalProperties: false
description: Success response containing a map of objects with nullable fields
example:
positions:
key:
before: before
after: after
status: status
properties:
status:
type: string
positions:
additionalProperties:
$ref: "#/components/schemas/NullableFieldsValue"
type: object
required:
- positions
- status
type: object
NullableFieldsMapError:
additionalProperties: false
description: Error response
properties:
status:
type: string
reason:
type: string
required:
- reason
- status
type: object
NullableFieldsMapResponse:
anyOf:
- $ref: "#/components/schemas/NullableFieldsMapSuccess"
- $ref: "#/components/schemas/NullableFieldsMapError"
_foo_get_default_response:
example:
string:
Expand Down
59 changes: 59 additions & 0 deletions samples/client/petstore/java/okhttp-gson/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
| [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties |
| [**testInlineFreeformAdditionalProperties**](FakeApi.md#testInlineFreeformAdditionalProperties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties |
| [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data |
| [**testNullableRequiredFieldsAnyOf**](FakeApi.md#testNullableRequiredFieldsAnyOf) | **GET** /fake/nullable-required-fields-anyof | test anyOf with map of objects containing nullable required fields |
| [**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters | |
| [**testStringMapReference**](FakeApi.md#testStringMapReference) | **POST** /fake/stringMap-reference | test referenced string map |

Expand Down Expand Up @@ -1380,6 +1381,64 @@ No authorization required
|-------------|-------------|------------------|
| **200** | successful operation | - |

<a id="testNullableRequiredFieldsAnyOf"></a>
# **testNullableRequiredFieldsAnyOf**
> NullableFieldsMapResponse testNullableRequiredFieldsAnyOf()

test anyOf with map of objects containing nullable required fields

Tests that anyOf deserialization works when object values contain required fields that are nullable (e.g. Record&lt;string, { before: string | null, after: string | null }&gt;)

### Example
```java
// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.FakeApi;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");

FakeApi apiInstance = new FakeApi(defaultClient);
try {
NullableFieldsMapResponse result = apiInstance.testNullableRequiredFieldsAnyOf();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testNullableRequiredFieldsAnyOf");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```

### Parameters
This endpoint does not need any parameter.

### Return type

[**NullableFieldsMapResponse**](NullableFieldsMapResponse.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | successful operation | - |

<a id="testQueryParameterCollectionFormat"></a>
# **testQueryParameterCollectionFormat**
> testQueryParameterCollectionFormat(pipe, ioutil, http, url, context)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


# NullableFieldsMapError

Error response

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**status** | **String** | | |
|**reason** | **String** | | |



Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


# NullableFieldsMapResponse


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**status** | **String** | | |
|**positions** | [**Map&lt;String, NullableFieldsValue&gt;**](NullableFieldsValue.md) | | |
|**reason** | **String** | | |



Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


# NullableFieldsMapSuccess

Success response containing a map of objects with nullable fields

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**status** | **String** | | |
|**positions** | [**Map&lt;String, NullableFieldsValue&gt;**](NullableFieldsValue.md) | | |



Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


# NullableFieldsValue

Object with required but nullable string fields

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**before** | **String** | | |
|**after** | **String** | | |



Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NewPetCategoryInlineAllof.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NewPetCategoryInlineAllofAllOfCategoryTag.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NullableClass.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NullableFieldsMapError.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NullableFieldsMapResponse.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NullableFieldsMapSuccess.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NullableFieldsValue.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NullableShape.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.NumberOnly.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ObjectWithDeprecatedFields.CustomTypeAdapterFactory());
Expand Down
Loading
Loading