Skip to content

Commit 24f0a6a

Browse files
committed
Add a test schema with enum properties
1 parent d584f65 commit 24f0a6a

File tree

32 files changed

+740
-0
lines changed

32 files changed

+740
-0
lines changed

modules/openapi-generator/src/test/resources/3_0/dart/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,3 +2062,22 @@ components:
20622062
enum:
20632063
- admin
20642064
- user
2065+
TestEnum:
2066+
type: string
2067+
enum:
2068+
- ""
2069+
- "1"
2070+
- "2"
2071+
title: TestEnum
2072+
TestItem:
2073+
type: object
2074+
required:
2075+
- test
2076+
properties:
2077+
test:
2078+
type: integer
2079+
title: test
2080+
testEmum:
2081+
$ref: '#/components/schemas/TestEnum'
2082+
default: ""
2083+
title: TestItem

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ doc/SingleRefType.md
5656
doc/SpecialModelName.md
5757
doc/StoreApi.md
5858
doc/Tag.md
59+
doc/TestEnum.md
5960
doc/TestInlineFreeformAdditionalPropertiesRequest.md
61+
doc/TestItem.md
6062
doc/User.md
6163
doc/UserApi.md
6264
lib/openapi.dart
@@ -122,6 +124,8 @@ lib/src/model/read_only_first.dart
122124
lib/src/model/single_ref_type.dart
123125
lib/src/model/special_model_name.dart
124126
lib/src/model/tag.dart
127+
lib/src/model/test_enum.dart
125128
lib/src/model/test_inline_freeform_additional_properties_request.dart
129+
lib/src/model/test_item.dart
126130
lib/src/model/user.dart
127131
pubspec.yaml

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ Class | Method | HTTP request | Description
164164
- [SingleRefType](doc/SingleRefType.md)
165165
- [SpecialModelName](doc/SpecialModelName.md)
166166
- [Tag](doc/Tag.md)
167+
- [TestEnum](doc/TestEnum.md)
167168
- [TestInlineFreeformAdditionalPropertiesRequest](doc/TestInlineFreeformAdditionalPropertiesRequest.md)
169+
- [TestItem](doc/TestItem.md)
168170
- [User](doc/User.md)
169171

170172

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# openapi.model.TestEnum
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+
12+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
13+
14+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# openapi.model.TestItem
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+
**test** | **int** | |
12+
**testEmum** | [**TestEnum**](TestEnum.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+

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export 'package:openapi/src/model/read_only_first.dart';
6565
export 'package:openapi/src/model/single_ref_type.dart';
6666
export 'package:openapi/src/model/special_model_name.dart';
6767
export 'package:openapi/src/model/tag.dart';
68+
export 'package:openapi/src/model/test_enum.dart';
6869
export 'package:openapi/src/model/test_inline_freeform_additional_properties_request.dart';
70+
export 'package:openapi/src/model/test_item.dart';
6971
export 'package:openapi/src/model/user.dart';
7072

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import 'package:openapi/src/model/read_only_first.dart';
4141
import 'package:openapi/src/model/special_model_name.dart';
4242
import 'package:openapi/src/model/tag.dart';
4343
import 'package:openapi/src/model/test_inline_freeform_additional_properties_request.dart';
44+
import 'package:openapi/src/model/test_item.dart';
4445
import 'package:openapi/src/model/user.dart';
4546

4647
final _regList = RegExp(r'^List<(.*)>$');
@@ -163,8 +164,13 @@ final _regMap = RegExp(r'^Map<String,(.*)>$');
163164
return SpecialModelName.fromJson(value as Map<String, dynamic>) as ReturnType;
164165
case 'Tag':
165166
return Tag.fromJson(value as Map<String, dynamic>) as ReturnType;
167+
case 'TestEnum':
168+
169+
166170
case 'TestInlineFreeformAdditionalPropertiesRequest':
167171
return TestInlineFreeformAdditionalPropertiesRequest.fromJson(value as Map<String, dynamic>) as ReturnType;
172+
case 'TestItem':
173+
return TestItem.fromJson(value as Map<String, dynamic>) as ReturnType;
168174
case 'User':
169175
return User.fromJson(value as Map<String, dynamic>) as ReturnType;
170176
default:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// AUTO-GENERATED FILE, DO NOT MODIFY!
3+
//
4+
5+
// ignore_for_file: unused_element
6+
import 'package:json_annotation/json_annotation.dart';
7+
8+
9+
enum TestEnum {
10+
@JsonValue(r'')
11+
empty(r''),
12+
@JsonValue(r'1')
13+
n1(r'1'),
14+
@JsonValue(r'2')
15+
n2(r'2'),
16+
@JsonValue(r'unknown_default_open_api')
17+
unknownDefaultOpenApi(r'unknown_default_open_api');
18+
19+
const TestEnum(this.value);
20+
21+
final String value;
22+
23+
@override
24+
String toString() => value;
25+
}
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/test_enum.dart';
7+
import 'package:json_annotation/json_annotation.dart';
8+
9+
part 'test_item.g.dart';
10+
11+
12+
@JsonSerializable(
13+
checked: true,
14+
createToJson: true,
15+
disallowUnrecognizedKeys: false,
16+
explicitToJson: true,
17+
)
18+
class TestItem {
19+
/// Returns a new [TestItem] instance.
20+
TestItem({
21+
22+
required this.test,
23+
24+
this.testEmum,
25+
});
26+
27+
@JsonKey(
28+
29+
name: r'test',
30+
required: true,
31+
includeIfNull: false,
32+
)
33+
34+
35+
final int test;
36+
37+
38+
39+
@JsonKey(
40+
41+
name: r'testEmum',
42+
required: false,
43+
includeIfNull: false,
44+
unknownEnumValue: TestEnum.unknownDefaultOpenApi,
45+
)
46+
47+
48+
final TestEnum? testEmum;
49+
50+
51+
52+
53+
54+
@override
55+
bool operator ==(Object other) => identical(this, other) || other is TestItem &&
56+
other.test == test &&
57+
other.testEmum == testEmum;
58+
59+
@override
60+
int get hashCode =>
61+
test.hashCode +
62+
testEmum.hashCode;
63+
64+
factory TestItem.fromJson(Map<String, dynamic> json) => _$TestItemFromJson(json);
65+
66+
Map<String, dynamic> toJson() => _$TestItemToJson(this);
67+
68+
@override
69+
String toString() {
70+
return toJson().toString();
71+
}
72+
73+
}
74+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import 'package:test/test.dart';
2+
import 'package:openapi/openapi.dart';
3+
4+
// tests for TestEnum
5+
void main() {
6+
7+
group(TestEnum, () {
8+
});
9+
}

0 commit comments

Comments
 (0)