Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix enum value without escaping HTML special characters #1193

Merged
merged 1 commit into from
Oct 8, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class {{classname}} {
{{#description}}
/// {{description}}
{{/description}}
static const {{classname}} {{name}} = const {{classname}}._internal({{value}});
static const {{classname}} {{{name}}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}}
{{/allowableValues}}
}
Expand All @@ -29,7 +29,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
switch (data) {
{{#allowableValues}}
{{#enumVars}}
case {{value}}: return {{classname}}.{{name}};
case {{{value}}}: return {{classname}}.{{{name}}}};
{{/enumVars}}
{{/allowableValues}}
default: throw('Unknown enum value to decode: $data');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class {{classname}} {
{{#description}}
/// {{description}}
{{/description}}
static const {{classname}} {{name}} = const {{classname}}._internal({{value}});
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}}
{{/allowableValues}}
}
Expand All @@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
switch (data) {
{{#allowableValues}}
{{#enumVars}}
case {{value}}: return {{classname}}.{{name}};
case {{{value}}}: return {{classname}}.{{{name}}};
{{/enumVars}}
{{/allowableValues}}
default: throw('Unknown enum value to decode: $data');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class {{classname}} {
{{#description}}
/// {{description}}
{{/description}}
static const {{classname}} {{name}} = const {{classname}}._internal({{value}});
static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}}
{{/allowableValues}}
}
Expand All @@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
switch (data) {
{{#allowableValues}}
{{#enumVars}}
case {{value}}: return {{classname}}.{{name}};
case {{{value}}}: return {{classname}}.{{{name}}};
{{/enumVars}}
{{/allowableValues}}
default: throw('Unknown enum value to decode: $data');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object {{classname}} {
{{/operation}}

{{#unknownStatusCodes}}
ApiInvoker.addCustomStatusCode({{value}}, isSuccess = false)
ApiInvoker.addCustomStatusCode({{{value}}}, isSuccess = false)
{{/unknownStatusCodes}}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0-SNAPSHOT
3.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:

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

## Requirements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete |
**apiKey** | **String**| | [optional]
**petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] [default to null]

### Return type

Expand Down Expand Up @@ -133,7 +133,7 @@ try {

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

### Return type

Expand Down Expand Up @@ -178,7 +178,7 @@ try {

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

### Return type

Expand Down Expand Up @@ -225,7 +225,7 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return |
**petId** | **int**| ID of pet to return | [default to null]

### Return type

Expand Down Expand Up @@ -311,7 +311,7 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet that needs to be updated |
**petId** | **int**| ID of pet that needs to be updated | [default to null]
**name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null]

Expand Down Expand Up @@ -358,7 +358,7 @@ try {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ try {

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

### Return type

Expand Down Expand Up @@ -126,7 +126,7 @@ try {

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

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ try {

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

### Return type

Expand Down Expand Up @@ -207,7 +207,7 @@ try {

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

### Return type

Expand Down Expand Up @@ -249,8 +249,8 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login |
**password** | **String**| The password for login in clear text |
**username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | [default to null]

### Return type

Expand Down Expand Up @@ -329,7 +329,7 @@ try {

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

### Return type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,100 +18,100 @@ import 'package:openapi/model/pet.dart';
import 'package:openapi/model/tag.dart';
import 'package:openapi/model/user.dart';


final jsonJaguarRepo = JsonRepo()
..add(ApiResponseSerializer())
..add(CategorySerializer())
..add(OrderSerializer())
..add(PetSerializer())
..add(TagSerializer())
..add(UserSerializer())
;

final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
..add(ApiResponseSerializer())
..add(CategorySerializer())
..add(OrderSerializer())
..add(PetSerializer())
..add(TagSerializer())
..add(UserSerializer());

final _defaultInterceptors = [
OAuthInterceptor(),
BasicAuthInterceptor(),
ApiKeyAuthInterceptor()
];

class JaguarApiGen {
List<Interceptor> interceptors;
String basePath = "http://petstore.swagger.io/v2";
Route _baseRoute;
List<Interceptor> interceptors;
String basePath = "http://petstore.swagger.io/v2";
Route _baseRoute;

/**
/**
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
*/
JaguarApiGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl}) {
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
if(interceptors == null) {
this.interceptors = _defaultInterceptors;
}
else if(overrideInterceptors){
this.interceptors = interceptors;
}
else {
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
}

this.interceptors.forEach((interceptor) {
_baseRoute.before(interceptor.before);
_baseRoute.after(interceptor.after);
});
JaguarApiGen(
{List<Interceptor> interceptors,
bool overrideInterceptors = false,
String baseUrl}) {
_baseRoute =
Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
if (interceptors == null) {
this.interceptors = _defaultInterceptors;
} else if (overrideInterceptors) {
this.interceptors = interceptors;
} else {
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
}

void setOAuthToken(String name, String token) {
(_defaultInterceptors[0] as OAuthInterceptor).tokens[name] = token;
}
this.interceptors.forEach((interceptor) {
_baseRoute.before(interceptor.before);
_baseRoute.after(interceptor.after);
});
}

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

void setApiKey(String name, String apiKey) {
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
}
void setBasicAuth(String name, String username, String password) {
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] =
BasicAuthInfo(username, password);
}


/**
void setApiKey(String name, String apiKey) {
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
}

/**
* Get PetApi instance, base route and serializer can be overridden by a given but be careful,
* by doing that all interceptors will not be executed
*/
PetApi getPetApi({Route base, SerializerRepo serializers}) {
if(base == null) {
base = _baseRoute;
}
if(serializers == null) {
serializers = jsonJaguarRepo;
}
return PetApi(base: base, serializers: serializers);
PetApi getPetApi({Route base, SerializerRepo serializers}) {
if (base == null) {
base = _baseRoute;
}
if (serializers == null) {
serializers = jsonJaguarRepo;
}
return PetApi(base: base, serializers: serializers);
}


/**
/**
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
* by doing that all interceptors will not be executed
*/
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
if(base == null) {
base = _baseRoute;
}
if(serializers == null) {
serializers = jsonJaguarRepo;
}
return StoreApi(base: base, serializers: serializers);
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
if (base == null) {
base = _baseRoute;
}
if (serializers == null) {
serializers = jsonJaguarRepo;
}
return StoreApi(base: base, serializers: serializers);
}


/**
/**
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
* by doing that all interceptors will not be executed
*/
UserApi getUserApi({Route base, SerializerRepo serializers}) {
if(base == null) {
base = _baseRoute;
}
if(serializers == null) {
serializers = jsonJaguarRepo;
}
return UserApi(base: base, serializers: serializers);
UserApi getUserApi({Route base, SerializerRepo serializers}) {
if (base == null) {
base = _baseRoute;
}


if (serializers == null) {
serializers = jsonJaguarRepo;
}
return UserApi(base: base, serializers: serializers);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import 'dart:async';
import 'package:jaguar_retrofit/jaguar_retrofit.dart';

abstract class AuthInterceptor extends Interceptor {
/*
/*
* Get auth information on given route for the given type
* Can return null if type is not present on auth data or if route doesn't need authentication
*/
List<Map<String, dynamic>> getAuthInfo(RouteBase route, String type) {
if (route.metadataMap.containsKey("auth")) {
final auth = route.metadataMap["auth"];
List<Map<String, dynamic>> results = [];
for (var info in auth) {
if(info["type"] == type) {
results.add(info);
}
}
return results;
List<Map<String, dynamic>> getAuthInfo(RouteBase route, String type) {
if (route.metadataMap.containsKey("auth")) {
final auth = route.metadataMap["auth"];
List<Map<String, dynamic>> results = [];
for (var info in auth) {
if (info["type"] == type) {
results.add(info);
}
return [];
}
return results;
}
}
return [];
}
}
Loading