Skip to content

Commit 67fd3cc

Browse files
authored
fix enum value, update dart petstore samples (OpenAPITools#1193)
1 parent 8aab647 commit 67fd3cc

File tree

78 files changed

+984
-1317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+984
-1317
lines changed

modules/openapi-generator/src/main/resources/dart-jaguar/enum.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class {{classname}} {
1212
{{#description}}
1313
/// {{description}}
1414
{{/description}}
15-
static const {{classname}} {{name}} = const {{classname}}._internal({{value}});
15+
static const {{classname}} {{{name}}}} = const {{classname}}._internal({{{value}}});
1616
{{/enumVars}}
1717
{{/allowableValues}}
1818
}
@@ -29,7 +29,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
2929
switch (data) {
3030
{{#allowableValues}}
3131
{{#enumVars}}
32-
case {{value}}: return {{classname}}.{{name}};
32+
case {{{value}}}: return {{classname}}.{{{name}}}};
3333
{{/enumVars}}
3434
{{/allowableValues}}
3535
default: throw('Unknown enum value to decode: $data');

modules/openapi-generator/src/main/resources/dart/enum.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class {{classname}} {
1010
{{#description}}
1111
/// {{description}}
1212
{{/description}}
13-
static const {{classname}} {{name}} = const {{classname}}._internal({{value}});
13+
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
1414
{{/enumVars}}
1515
{{/allowableValues}}
1616
}
@@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
2727
switch (data) {
2828
{{#allowableValues}}
2929
{{#enumVars}}
30-
case {{value}}: return {{classname}}.{{name}};
30+
case {{{value}}}: return {{classname}}.{{{name}}};
3131
{{/enumVars}}
3232
{{/allowableValues}}
3333
default: throw('Unknown enum value to decode: $data');

modules/openapi-generator/src/main/resources/dart2/enum.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class {{classname}} {
1010
{{#description}}
1111
/// {{description}}
1212
{{/description}}
13-
static const {{classname}} {{name}} = const {{classname}}._internal({{value}});
13+
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
1414
{{/enumVars}}
1515
{{/allowableValues}}
1616
}
@@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
2727
switch (data) {
2828
{{#allowableValues}}
2929
{{#enumVars}}
30-
case {{value}}: return {{classname}}.{{name}};
30+
case {{{value}}}: return {{classname}}.{{{name}}};
3131
{{/enumVars}}
3232
{{/allowableValues}}
3333
default: throw('Unknown enum value to decode: $data');

modules/openapi-generator/src/main/resources/scala-akka-client/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object {{classname}} {
3636
{{/operation}}
3737

3838
{{#unknownStatusCodes}}
39-
ApiInvoker.addCustomStatusCode({{value}}, isSuccess = false)
39+
ApiInvoker.addCustomStatusCode({{{value}}}, isSuccess = false)
4040
{{/unknownStatusCodes}}
4141

4242
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.0-SNAPSHOT
1+
3.3.1-SNAPSHOT

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke
44
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
55

66
- API version: 1.0.0
7-
- Build date: 2018-09-21T14:54:05.021285+02:00[Europe/Paris]
7+
- Build date: 2018-10-08T15:27:22.304+08:00[Asia/Hong_Kong]
88
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
99

1010
## Requirements

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/docs/PetApi.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ try {
8787

8888
Name | Type | Description | Notes
8989
------------- | ------------- | ------------- | -------------
90-
**petId** | **int**| Pet id to delete |
91-
**apiKey** | **String**| | [optional]
90+
**petId** | **int**| Pet id to delete | [default to null]
91+
**apiKey** | **String**| | [optional] [default to null]
9292

9393
### Return type
9494

@@ -133,7 +133,7 @@ try {
133133

134134
Name | Type | Description | Notes
135135
------------- | ------------- | ------------- | -------------
136-
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter |
136+
**status** | [**List&lt;String&gt;**](String.md)| Status values that need to be considered for filter | [default to const []]
137137

138138
### Return type
139139

@@ -178,7 +178,7 @@ try {
178178

179179
Name | Type | Description | Notes
180180
------------- | ------------- | ------------- | -------------
181-
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by |
181+
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to const []]
182182

183183
### Return type
184184

@@ -225,7 +225,7 @@ try {
225225

226226
Name | Type | Description | Notes
227227
------------- | ------------- | ------------- | -------------
228-
**petId** | **int**| ID of pet to return |
228+
**petId** | **int**| ID of pet to return | [default to null]
229229

230230
### Return type
231231

@@ -311,7 +311,7 @@ try {
311311

312312
Name | Type | Description | Notes
313313
------------- | ------------- | ------------- | -------------
314-
**petId** | **int**| ID of pet that needs to be updated |
314+
**petId** | **int**| ID of pet that needs to be updated | [default to null]
315315
**name** | **String**| Updated name of the pet | [optional] [default to null]
316316
**status** | **String**| Updated status of the pet | [optional] [default to null]
317317

@@ -358,7 +358,7 @@ try {
358358

359359
Name | Type | Description | Notes
360360
------------- | ------------- | ------------- | -------------
361-
**petId** | **int**| ID of pet to update |
361+
**petId** | **int**| ID of pet to update | [default to null]
362362
**additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
363363
**file** | **MultipartFile****MultipartFile**| file to upload | [optional] [default to null]
364364

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/docs/StoreApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ try {
4040

4141
Name | Type | Description | Notes
4242
------------- | ------------- | ------------- | -------------
43-
**orderId** | **String**| ID of the order that needs to be deleted |
43+
**orderId** | **String**| ID of the order that needs to be deleted | [default to null]
4444

4545
### Return type
4646

@@ -126,7 +126,7 @@ try {
126126

127127
Name | Type | Description | Notes
128128
------------- | ------------- | ------------- | -------------
129-
**orderId** | **int**| ID of pet that needs to be fetched |
129+
**orderId** | **int**| ID of pet that needs to be fetched | [default to null]
130130

131131
### Return type
132132

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/docs/UserApi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ try {
166166

167167
Name | Type | Description | Notes
168168
------------- | ------------- | ------------- | -------------
169-
**username** | **String**| The name that needs to be deleted |
169+
**username** | **String**| The name that needs to be deleted | [default to null]
170170

171171
### Return type
172172

@@ -207,7 +207,7 @@ try {
207207

208208
Name | Type | Description | Notes
209209
------------- | ------------- | ------------- | -------------
210-
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
210+
**username** | **String**| The name that needs to be fetched. Use user1 for testing. | [default to null]
211211

212212
### Return type
213213

@@ -249,8 +249,8 @@ try {
249249

250250
Name | Type | Description | Notes
251251
------------- | ------------- | ------------- | -------------
252-
**username** | **String**| The user name for login |
253-
**password** | **String**| The password for login in clear text |
252+
**username** | **String**| The user name for login | [default to null]
253+
**password** | **String**| The password for login in clear text | [default to null]
254254

255255
### Return type
256256

@@ -329,7 +329,7 @@ try {
329329

330330
Name | Type | Description | Notes
331331
------------- | ------------- | ------------- | -------------
332-
**username** | **String**| name that need to be deleted |
332+
**username** | **String**| name that need to be deleted | [default to null]
333333
**user** | [**User**](User.md)| Updated user object |
334334

335335
### Return type

samples/client/petstore/dart-jaguar/flutter_petstore/openapi/lib/api.dart

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -18,100 +18,100 @@ import 'package:openapi/model/pet.dart';
1818
import 'package:openapi/model/tag.dart';
1919
import 'package:openapi/model/user.dart';
2020

21-
2221
final jsonJaguarRepo = JsonRepo()
23-
..add(ApiResponseSerializer())
24-
..add(CategorySerializer())
25-
..add(OrderSerializer())
26-
..add(PetSerializer())
27-
..add(TagSerializer())
28-
..add(UserSerializer())
29-
;
30-
31-
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
22+
..add(ApiResponseSerializer())
23+
..add(CategorySerializer())
24+
..add(OrderSerializer())
25+
..add(PetSerializer())
26+
..add(TagSerializer())
27+
..add(UserSerializer());
28+
29+
final _defaultInterceptors = [
30+
OAuthInterceptor(),
31+
BasicAuthInterceptor(),
32+
ApiKeyAuthInterceptor()
33+
];
3234

3335
class JaguarApiGen {
34-
List<Interceptor> interceptors;
35-
String basePath = "http://petstore.swagger.io/v2";
36-
Route _baseRoute;
36+
List<Interceptor> interceptors;
37+
String basePath = "http://petstore.swagger.io/v2";
38+
Route _baseRoute;
3739

38-
/**
40+
/**
3941
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
4042
*/
41-
JaguarApiGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl}) {
42-
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
43-
if(interceptors == null) {
44-
this.interceptors = _defaultInterceptors;
45-
}
46-
else if(overrideInterceptors){
47-
this.interceptors = interceptors;
48-
}
49-
else {
50-
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
51-
}
52-
53-
this.interceptors.forEach((interceptor) {
54-
_baseRoute.before(interceptor.before);
55-
_baseRoute.after(interceptor.after);
56-
});
43+
JaguarApiGen(
44+
{List<Interceptor> interceptors,
45+
bool overrideInterceptors = false,
46+
String baseUrl}) {
47+
_baseRoute =
48+
Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
49+
if (interceptors == null) {
50+
this.interceptors = _defaultInterceptors;
51+
} else if (overrideInterceptors) {
52+
this.interceptors = interceptors;
53+
} else {
54+
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
5755
}
5856

59-
void setOAuthToken(String name, String token) {
60-
(_defaultInterceptors[0] as OAuthInterceptor).tokens[name] = token;
61-
}
57+
this.interceptors.forEach((interceptor) {
58+
_baseRoute.before(interceptor.before);
59+
_baseRoute.after(interceptor.after);
60+
});
61+
}
6262

63-
void setBasicAuth(String name, String username, String password) {
64-
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
65-
}
63+
void setOAuthToken(String name, String token) {
64+
(_defaultInterceptors[0] as OAuthInterceptor).tokens[name] = token;
65+
}
6666

67-
void setApiKey(String name, String apiKey) {
68-
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
69-
}
67+
void setBasicAuth(String name, String username, String password) {
68+
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] =
69+
BasicAuthInfo(username, password);
70+
}
7071

71-
72-
/**
72+
void setApiKey(String name, String apiKey) {
73+
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
74+
}
75+
76+
/**
7377
* Get PetApi instance, base route and serializer can be overridden by a given but be careful,
7478
* by doing that all interceptors will not be executed
7579
*/
76-
PetApi getPetApi({Route base, SerializerRepo serializers}) {
77-
if(base == null) {
78-
base = _baseRoute;
79-
}
80-
if(serializers == null) {
81-
serializers = jsonJaguarRepo;
82-
}
83-
return PetApi(base: base, serializers: serializers);
80+
PetApi getPetApi({Route base, SerializerRepo serializers}) {
81+
if (base == null) {
82+
base = _baseRoute;
83+
}
84+
if (serializers == null) {
85+
serializers = jsonJaguarRepo;
8486
}
87+
return PetApi(base: base, serializers: serializers);
88+
}
8589

86-
87-
/**
90+
/**
8891
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
8992
* by doing that all interceptors will not be executed
9093
*/
91-
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
92-
if(base == null) {
93-
base = _baseRoute;
94-
}
95-
if(serializers == null) {
96-
serializers = jsonJaguarRepo;
97-
}
98-
return StoreApi(base: base, serializers: serializers);
94+
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
95+
if (base == null) {
96+
base = _baseRoute;
97+
}
98+
if (serializers == null) {
99+
serializers = jsonJaguarRepo;
99100
}
101+
return StoreApi(base: base, serializers: serializers);
102+
}
100103

101-
102-
/**
104+
/**
103105
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
104106
* by doing that all interceptors will not be executed
105107
*/
106-
UserApi getUserApi({Route base, SerializerRepo serializers}) {
107-
if(base == null) {
108-
base = _baseRoute;
109-
}
110-
if(serializers == null) {
111-
serializers = jsonJaguarRepo;
112-
}
113-
return UserApi(base: base, serializers: serializers);
108+
UserApi getUserApi({Route base, SerializerRepo serializers}) {
109+
if (base == null) {
110+
base = _baseRoute;
114111
}
115-
116-
112+
if (serializers == null) {
113+
serializers = jsonJaguarRepo;
114+
}
115+
return UserApi(base: base, serializers: serializers);
116+
}
117117
}

0 commit comments

Comments
 (0)