Skip to content

Commit 92925e7

Browse files
committed
#21582 [BUG][dart-dio] Bug generating inline enums with common names. Added generated files that were missed.
1 parent 64b5b29 commit 92925e7

32 files changed

Lines changed: 1212 additions & 15 deletions

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/.openapi-generator/FILES

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ doc/ModelReturn.md
4040
doc/Name.md
4141
doc/NullableClass.md
4242
doc/NumberOnly.md
43+
doc/ObjectThatReferencesObjectsWithDuplicateInlineEnums.md
4344
doc/ObjectWithDeprecatedFields.md
45+
doc/ObjectWithDuplicateInlineEnum.md
46+
doc/ObjectWithInlineEnum.md
4447
doc/Order.md
4548
doc/OuterComposite.md
4649
doc/OuterEnum.md
@@ -110,7 +113,10 @@ lib/src/model/model_return.dart
110113
lib/src/model/name.dart
111114
lib/src/model/nullable_class.dart
112115
lib/src/model/number_only.dart
116+
lib/src/model/object_that_references_objects_with_duplicate_inline_enums.dart
113117
lib/src/model/object_with_deprecated_fields.dart
118+
lib/src/model/object_with_duplicate_inline_enum.dart
119+
lib/src/model/object_with_inline_enum.dart
114120
lib/src/model/order.dart
115121
lib/src/model/outer_composite.dart
116122
lib/src/model/outer_enum.dart
@@ -129,3 +135,6 @@ lib/src/model/test_inline_freeform_additional_properties_request.dart
129135
lib/src/model/test_item.dart
130136
lib/src/model/user.dart
131137
pubspec.yaml
138+
test/object_that_references_objects_with_duplicate_inline_enums_test.dart
139+
test/object_with_duplicate_inline_enum_test.dart
140+
test/object_with_inline_enum_test.dart

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Class | Method | HTTP request | Description
6969
[*AnotherFakeApi*](doc/AnotherFakeApi.md) | [**call123testSpecialTags**](doc/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
7070
[*DefaultApi*](doc/DefaultApi.md) | [**fooGet**](doc/DefaultApi.md#fooget) | **GET** /foo |
7171
[*FakeApi*](doc/FakeApi.md) | [**fakeBigDecimalMap**](doc/FakeApi.md#fakebigdecimalmap) | **GET** /fake/BigDecimalMap |
72+
[*FakeApi*](doc/FakeApi.md) | [**fakeDuplicateInlineEnum**](doc/FakeApi.md#fakeduplicateinlineenum) | **GET** /fake/duplicate-inline-enums | test objects with duplicate inline enums see issue# 21582
7273
[*FakeApi*](doc/FakeApi.md) | [**fakeHealthGet**](doc/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
7374
[*FakeApi*](doc/FakeApi.md) | [**fakeHttpSignatureTest**](doc/FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication
7475
[*FakeApi*](doc/FakeApi.md) | [**fakeOuterBooleanSerialize**](doc/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
@@ -150,7 +151,10 @@ Class | Method | HTTP request | Description
150151
- [Name](doc/Name.md)
151152
- [NullableClass](doc/NullableClass.md)
152153
- [NumberOnly](doc/NumberOnly.md)
154+
- [ObjectThatReferencesObjectsWithDuplicateInlineEnums](doc/ObjectThatReferencesObjectsWithDuplicateInlineEnums.md)
153155
- [ObjectWithDeprecatedFields](doc/ObjectWithDeprecatedFields.md)
156+
- [ObjectWithDuplicateInlineEnum](doc/ObjectWithDuplicateInlineEnum.md)
157+
- [ObjectWithInlineEnum](doc/ObjectWithInlineEnum.md)
154158
- [Order](doc/Order.md)
155159
- [OuterComposite](doc/OuterComposite.md)
156160
- [OuterEnum](doc/OuterEnum.md)

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/FakeApi.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
1010
Method | HTTP request | Description
1111
------------- | ------------- | -------------
1212
[**fakeBigDecimalMap**](FakeApi.md#fakebigdecimalmap) | **GET** /fake/BigDecimalMap |
13+
[**fakeDuplicateInlineEnum**](FakeApi.md#fakeduplicateinlineenum) | **GET** /fake/duplicate-inline-enums | test objects with duplicate inline enums see issue# 21582
1314
[**fakeHealthGet**](FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
1415
[**fakeHttpSignatureTest**](FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication
1516
[**fakeOuterBooleanSerialize**](FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
@@ -72,6 +73,43 @@ No authorization required
7273

7374
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
7475

76+
# **fakeDuplicateInlineEnum**
77+
> ObjectThatReferencesObjectsWithDuplicateInlineEnums fakeDuplicateInlineEnum()
78+
79+
test objects with duplicate inline enums see issue# 21582
80+
81+
### Example
82+
```dart
83+
import 'package:openapi/api.dart';
84+
85+
final api = Openapi().getFakeApi();
86+
87+
try {
88+
final response = api.fakeDuplicateInlineEnum();
89+
print(response);
90+
} catch on DioException (e) {
91+
print('Exception when calling FakeApi->fakeDuplicateInlineEnum: $e\n');
92+
}
93+
```
94+
95+
### Parameters
96+
This endpoint does not need any parameter.
97+
98+
### Return type
99+
100+
[**ObjectThatReferencesObjectsWithDuplicateInlineEnums**](ObjectThatReferencesObjectsWithDuplicateInlineEnums.md)
101+
102+
### Authorization
103+
104+
No authorization required
105+
106+
### HTTP request headers
107+
108+
- **Content-Type**: Not defined
109+
- **Accept**: application/json
110+
111+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
112+
75113
# **fakeHealthGet**
76114
> HealthCheckResult fakeHealthGet()
77115
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# openapi.model.ObjectThatReferencesObjectsWithDuplicateInlineEnums
2+
3+
## Load the model package
4+
```dart
5+
import 'package:openapi/api.dart';
6+
```
7+
8+
## Properties
9+
Name | Type | Description | Notes
10+
------------ | ------------- | ------------- | -------------
11+
**objectOne** | [**ObjectWithInlineEnum**](ObjectWithInlineEnum.md) | | [optional]
12+
**objectTwo** | [**ObjectWithDuplicateInlineEnum**](ObjectWithDuplicateInlineEnum.md) | | [optional]
13+
14+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
15+
16+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# openapi.model.ObjectWithDuplicateInlineEnum
2+
3+
## Load the model package
4+
```dart
5+
import 'package:openapi/api.dart';
6+
```
7+
8+
## Properties
9+
Name | Type | Description | Notes
10+
------------ | ------------- | ------------- | -------------
11+
**attribute** | **Set<String>** | Object two attribute enum | [optional]
12+
13+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
14+
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# openapi.model.ObjectWithInlineEnum
2+
3+
## Load the model package
4+
```dart
5+
import 'package:openapi/api.dart';
6+
```
7+
8+
## Properties
9+
Name | Type | Description | Notes
10+
------------ | ------------- | ------------- | -------------
11+
**attribute** | **Set<String>** | Object one attribute enum | [optional]
12+
13+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
14+
15+

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/openapi.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export 'package:openapi/src/model/model_return.dart';
5151
export 'package:openapi/src/model/name.dart';
5252
export 'package:openapi/src/model/nullable_class.dart';
5353
export 'package:openapi/src/model/number_only.dart';
54+
export 'package:openapi/src/model/object_that_references_objects_with_duplicate_inline_enums.dart';
5455
export 'package:openapi/src/model/object_with_deprecated_fields.dart';
56+
export 'package:openapi/src/model/object_with_duplicate_inline_enum.dart';
57+
export 'package:openapi/src/model/object_with_inline_enum.dart';
5558
export 'package:openapi/src/model/order.dart';
5659
export 'package:openapi/src/model/outer_composite.dart';
5760
export 'package:openapi/src/model/outer_enum.dart';

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/api/fake_api.dart

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:openapi/src/model/file_schema_test_class.dart';
1515
import 'package:openapi/src/model/health_check_result.dart';
1616
import 'package:openapi/src/model/model_client.dart';
1717
import 'package:openapi/src/model/model_enum_class.dart';
18+
import 'package:openapi/src/model/object_that_references_objects_with_duplicate_inline_enums.dart';
1819
import 'package:openapi/src/model/outer_composite.dart';
1920
import 'package:openapi/src/model/outer_object_with_enum_property.dart';
2021
import 'package:openapi/src/model/pet.dart';
@@ -97,6 +98,76 @@ _responseData = rawData == null ? null : deserialize<FakeBigDecimalMap200Respons
9798
);
9899
}
99100

101+
/// test objects with duplicate inline enums see issue# 21582
102+
///
103+
///
104+
/// Parameters:
105+
/// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
106+
/// * [headers] - Can be used to add additional headers to the request
107+
/// * [extras] - Can be used to add flags to the request
108+
/// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
109+
/// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
110+
/// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
111+
///
112+
/// Returns a [Future] containing a [Response] with a [ObjectThatReferencesObjectsWithDuplicateInlineEnums] as data
113+
/// Throws [DioException] if API call or serialization fails
114+
Future<Response<ObjectThatReferencesObjectsWithDuplicateInlineEnums>> fakeDuplicateInlineEnum({
115+
CancelToken? cancelToken,
116+
Map<String, dynamic>? headers,
117+
Map<String, dynamic>? extra,
118+
ValidateStatus? validateStatus,
119+
ProgressCallback? onSendProgress,
120+
ProgressCallback? onReceiveProgress,
121+
}) async {
122+
final _path = r'/fake/duplicate-inline-enums';
123+
final _options = Options(
124+
method: r'GET',
125+
headers: <String, dynamic>{
126+
...?headers,
127+
},
128+
extra: <String, dynamic>{
129+
'secure': <Map<String, String>>[],
130+
...?extra,
131+
},
132+
validateStatus: validateStatus,
133+
);
134+
135+
final _response = await _dio.request<Object>(
136+
_path,
137+
options: _options,
138+
cancelToken: cancelToken,
139+
onSendProgress: onSendProgress,
140+
onReceiveProgress: onReceiveProgress,
141+
);
142+
143+
ObjectThatReferencesObjectsWithDuplicateInlineEnums? _responseData;
144+
145+
try {
146+
final rawData = _response.data;
147+
_responseData = rawData == null ? null : deserialize<ObjectThatReferencesObjectsWithDuplicateInlineEnums, ObjectThatReferencesObjectsWithDuplicateInlineEnums>(rawData, 'ObjectThatReferencesObjectsWithDuplicateInlineEnums', growable: true);
148+
149+
} catch (error, stackTrace) {
150+
throw DioException(
151+
requestOptions: _response.requestOptions,
152+
response: _response,
153+
type: DioExceptionType.unknown,
154+
error: error,
155+
stackTrace: stackTrace,
156+
);
157+
}
158+
159+
return Response<ObjectThatReferencesObjectsWithDuplicateInlineEnums>(
160+
data: _responseData,
161+
headers: _response.headers,
162+
isRedirect: _response.isRedirect,
163+
requestOptions: _response.requestOptions,
164+
redirects: _response.redirects,
165+
statusCode: _response.statusCode,
166+
statusMessage: _response.statusMessage,
167+
extra: _response.extra,
168+
);
169+
}
170+
100171
/// Health check endpoint
101172
///
102173
///

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/deserialize.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ import 'package:openapi/src/model/model_return.dart';
3131
import 'package:openapi/src/model/name.dart';
3232
import 'package:openapi/src/model/nullable_class.dart';
3333
import 'package:openapi/src/model/number_only.dart';
34+
import 'package:openapi/src/model/object_that_references_objects_with_duplicate_inline_enums.dart';
3435
import 'package:openapi/src/model/object_with_deprecated_fields.dart';
36+
import 'package:openapi/src/model/object_with_duplicate_inline_enum.dart';
37+
import 'package:openapi/src/model/object_with_inline_enum.dart';
3538
import 'package:openapi/src/model/order.dart';
3639
import 'package:openapi/src/model/outer_composite.dart';
3740
import 'package:openapi/src/model/outer_object_with_enum_property.dart';
@@ -131,8 +134,14 @@ final _regMap = RegExp(r'^Map<String,(.*)>$');
131134
return NullableClass.fromJson(value as Map<String, dynamic>) as ReturnType;
132135
case 'NumberOnly':
133136
return NumberOnly.fromJson(value as Map<String, dynamic>) as ReturnType;
137+
case 'ObjectThatReferencesObjectsWithDuplicateInlineEnums':
138+
return ObjectThatReferencesObjectsWithDuplicateInlineEnums.fromJson(value as Map<String, dynamic>) as ReturnType;
134139
case 'ObjectWithDeprecatedFields':
135140
return ObjectWithDeprecatedFields.fromJson(value as Map<String, dynamic>) as ReturnType;
141+
case 'ObjectWithDuplicateInlineEnum':
142+
return ObjectWithDuplicateInlineEnum.fromJson(value as Map<String, dynamic>) as ReturnType;
143+
case 'ObjectWithInlineEnum':
144+
return ObjectWithInlineEnum.fromJson(value as Map<String, dynamic>) as ReturnType;
136145
case 'Order':
137146
return Order.fromJson(value as Map<String, dynamic>) as ReturnType;
138147
case 'OuterComposite':
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//
2+
// AUTO-GENERATED FILE, DO NOT MODIFY!
3+
//
4+
5+
// ignore_for_file: unused_element
6+
import 'package:openapi/src/model/object_with_duplicate_inline_enum.dart';
7+
import 'package:openapi/src/model/object_with_inline_enum.dart';
8+
import 'package:json_annotation/json_annotation.dart';
9+
10+
part 'object_that_references_objects_with_duplicate_inline_enums.g.dart';
11+
12+
13+
@JsonSerializable(
14+
checked: true,
15+
createToJson: true,
16+
disallowUnrecognizedKeys: false,
17+
explicitToJson: true,
18+
)
19+
class ObjectThatReferencesObjectsWithDuplicateInlineEnums {
20+
/// Returns a new [ObjectThatReferencesObjectsWithDuplicateInlineEnums] instance.
21+
ObjectThatReferencesObjectsWithDuplicateInlineEnums({
22+
23+
this.objectOne,
24+
25+
this.objectTwo,
26+
});
27+
28+
@JsonKey(
29+
30+
name: r'object_one',
31+
required: false,
32+
includeIfNull: false,
33+
)
34+
35+
36+
final ObjectWithInlineEnum? objectOne;
37+
38+
39+
40+
@JsonKey(
41+
42+
name: r'object_two',
43+
required: false,
44+
includeIfNull: false,
45+
)
46+
47+
48+
final ObjectWithDuplicateInlineEnum? objectTwo;
49+
50+
51+
52+
53+
54+
@override
55+
bool operator ==(Object other) => identical(this, other) || other is ObjectThatReferencesObjectsWithDuplicateInlineEnums &&
56+
other.objectOne == objectOne &&
57+
other.objectTwo == objectTwo;
58+
59+
@override
60+
int get hashCode =>
61+
objectOne.hashCode +
62+
objectTwo.hashCode;
63+
64+
factory ObjectThatReferencesObjectsWithDuplicateInlineEnums.fromJson(Map<String, dynamic> json) => _$ObjectThatReferencesObjectsWithDuplicateInlineEnumsFromJson(json);
65+
66+
Map<String, dynamic> toJson() => _$ObjectThatReferencesObjectsWithDuplicateInlineEnumsToJson(this);
67+
68+
@override
69+
String toString() {
70+
return toJson().toString();
71+
}
72+
73+
}
74+

0 commit comments

Comments
 (0)