fix enum value, update dart petstore samples (#1193)

This commit is contained in:
William Cheng 2018-10-09 07:08:04 +08:00 committed by GitHub
parent 7d58f308d9
commit 22049db8c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 972 additions and 1305 deletions

View File

@ -12,7 +12,7 @@ class {{classname}} {
{{#description}} {{#description}}
/// {{description}} /// {{description}}
{{/description}} {{/description}}
static const {{classname}} {{name}} = const {{classname}}._internal({{value}}); static const {{classname}} {{{name}}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
} }
@ -29,7 +29,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
switch (data) { switch (data) {
{{#allowableValues}} {{#allowableValues}}
{{#enumVars}} {{#enumVars}}
case {{value}}: return {{classname}}.{{name}}; case {{{value}}}: return {{classname}}.{{{name}}}};
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
default: throw('Unknown enum value to decode: $data'); default: throw('Unknown enum value to decode: $data');

View File

@ -10,7 +10,7 @@ class {{classname}} {
{{#description}} {{#description}}
/// {{description}} /// {{description}}
{{/description}} {{/description}}
static const {{classname}} {{name}} = const {{classname}}._internal({{value}}); static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
} }
@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
switch (data) { switch (data) {
{{#allowableValues}} {{#allowableValues}}
{{#enumVars}} {{#enumVars}}
case {{value}}: return {{classname}}.{{name}}; case {{{value}}}: return {{classname}}.{{{name}}};
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
default: throw('Unknown enum value to decode: $data'); default: throw('Unknown enum value to decode: $data');

View File

@ -10,7 +10,7 @@ class {{classname}} {
{{#description}} {{#description}}
/// {{description}} /// {{description}}
{{/description}} {{/description}}
static const {{classname}} {{name}} = const {{classname}}._internal({{value}}); static const {{classname}} {{{name}}} = const {{classname}}._internal({{{value}}});
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
} }
@ -27,7 +27,7 @@ class {{classname}}TypeTransformer extends TypeTransformer<{{classname}}> {
switch (data) { switch (data) {
{{#allowableValues}} {{#allowableValues}}
{{#enumVars}} {{#enumVars}}
case {{value}}: return {{classname}}.{{name}}; case {{{value}}}: return {{classname}}.{{{name}}};
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
default: throw('Unknown enum value to decode: $data'); default: throw('Unknown enum value to decode: $data');

View File

@ -36,7 +36,7 @@ object {{classname}} {
{{/operation}} {{/operation}}
{{#unknownStatusCodes}} {{#unknownStatusCodes}}
ApiInvoker.addCustomStatusCode({{value}}, isSuccess = false) ApiInvoker.addCustomStatusCode({{{value}}}, isSuccess = false)
{{/unknownStatusCodes}} {{/unknownStatusCodes}}
} }

View File

@ -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: This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
- API version: 1.0.0 - 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 - Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
## Requirements ## Requirements

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | **petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] **apiKey** | **String**| | [optional] [default to null]
### Return type ### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | **petId** | **int**| ID of pet to return | [default to null]
### Return type ### Return type
@ -311,7 +311,7 @@ try {
Name | Type | Description | Notes 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] **name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null] **status** | **String**| Updated status of the pet | [optional] [default to null]
@ -358,7 +358,7 @@ try {
Name | Type | Description | Notes 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] **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile****MultipartFile**| file to upload | [optional] [default to null] **file** | **MultipartFile****MultipartFile**| file to upload | [optional] [default to null]

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes 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 ### Return type

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | **username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | **password** | **String**| The password for login in clear text | [default to null]
### Return type ### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes 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 | **user** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@ -18,17 +18,19 @@ import 'package:openapi/model/pet.dart';
import 'package:openapi/model/tag.dart'; import 'package:openapi/model/tag.dart';
import 'package:openapi/model/user.dart'; import 'package:openapi/model/user.dart';
final jsonJaguarRepo = JsonRepo() final jsonJaguarRepo = JsonRepo()
..add(ApiResponseSerializer()) ..add(ApiResponseSerializer())
..add(CategorySerializer()) ..add(CategorySerializer())
..add(OrderSerializer()) ..add(OrderSerializer())
..add(PetSerializer()) ..add(PetSerializer())
..add(TagSerializer()) ..add(TagSerializer())
..add(UserSerializer()) ..add(UserSerializer());
;
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()]; final _defaultInterceptors = [
OAuthInterceptor(),
BasicAuthInterceptor(),
ApiKeyAuthInterceptor()
];
class JaguarApiGen { class JaguarApiGen {
List<Interceptor> interceptors; List<Interceptor> interceptors;
@ -38,15 +40,17 @@ class JaguarApiGen {
/** /**
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added) * 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}) { JaguarApiGen(
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient()); {List<Interceptor> interceptors,
bool overrideInterceptors = false,
String baseUrl}) {
_baseRoute =
Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
if (interceptors == null) { if (interceptors == null) {
this.interceptors = _defaultInterceptors; this.interceptors = _defaultInterceptors;
} } else if (overrideInterceptors) {
else if(overrideInterceptors){
this.interceptors = interceptors; this.interceptors = interceptors;
} } else {
else {
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors); this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
} }
@ -61,14 +65,14 @@ class JaguarApiGen {
} }
void setBasicAuth(String name, String username, String password) { void setBasicAuth(String name, String username, String password) {
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); (_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] =
BasicAuthInfo(username, password);
} }
void setApiKey(String name, String apiKey) { void setApiKey(String name, String apiKey) {
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; (_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
} }
/** /**
* Get PetApi instance, base route and serializer can be overridden by a given but be careful, * 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 * by doing that all interceptors will not be executed
@ -83,7 +87,6 @@ class JaguarApiGen {
return PetApi(base: base, serializers: serializers); return PetApi(base: base, serializers: serializers);
} }
/** /**
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful, * 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 * by doing that all interceptors will not be executed
@ -98,7 +101,6 @@ class JaguarApiGen {
return StoreApi(base: base, serializers: serializers); return StoreApi(base: base, serializers: serializers);
} }
/** /**
* Get UserApi instance, base route and serializer can be overridden by a given but be careful, * 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 * by doing that all interceptors will not be executed
@ -112,6 +114,4 @@ class JaguarApiGen {
} }
return UserApi(base: base, serializers: serializers); return UserApi(base: base, serializers: serializers);
} }
} }

View File

@ -3,7 +3,6 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'api_response.jser.dart'; part 'api_response.jser.dart';
class ApiResponse { class ApiResponse {
@Alias('code') @Alias('code')
final int code; final int code;
@ -13,17 +12,7 @@ class ApiResponse {
@Alias('message') @Alias('message')
final String message; final String message;
ApiResponse({this.code = null, this.type = null, this.message = null});
ApiResponse(
{
this.code = null,
this.type = null,
this.message = null
}
);
@override @override
String toString() { String toString() {
@ -32,6 +21,5 @@ class ApiResponse {
} }
@GenSerializer() @GenSerializer()
class ApiResponseSerializer extends Serializer<ApiResponse> with _$ApiResponseSerializer { class ApiResponseSerializer extends Serializer<ApiResponse>
with _$ApiResponseSerializer {}
}

View File

@ -3,23 +3,13 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'category.jser.dart'; part 'category.jser.dart';
class Category { class Category {
@Alias('id') @Alias('id')
final int id; final int id;
@Alias('name') @Alias('name')
final String name; final String name;
Category({this.id = null, this.name = null});
Category(
{
this.id = null,
this.name = null
}
);
@override @override
String toString() { String toString() {
@ -28,6 +18,5 @@ class Category {
} }
@GenSerializer() @GenSerializer()
class CategorySerializer extends Serializer<Category> with _$CategorySerializer { class CategorySerializer extends Serializer<Category>
with _$CategorySerializer {}
}

View File

@ -3,7 +3,6 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'order.jser.dart'; part 'order.jser.dart';
class Order { class Order {
@Alias('id') @Alias('id')
final int id; final int id;
@ -22,20 +21,13 @@ class Order {
@Alias('complete') @Alias('complete')
final bool complete; final bool complete;
Order( Order(
{this.id = null,
{
this.id = null,
this.petId = null, this.petId = null,
this.quantity = null, this.quantity = null,
this.shipDate = null, this.shipDate = null,
this.status = null, this.status = null,
this.complete = false this.complete = false});
}
);
@override @override
String toString() { String toString() {
@ -44,6 +36,4 @@ class Order {
} }
@GenSerializer() @GenSerializer()
class OrderSerializer extends Serializer<Order> with _$OrderSerializer { class OrderSerializer extends Serializer<Order> with _$OrderSerializer {}
}

View File

@ -5,7 +5,6 @@ import 'package:openapi/model/category.dart';
part 'pet.jser.dart'; part 'pet.jser.dart';
class Pet { class Pet {
@Alias('id') @Alias('id')
final int id; final int id;
@ -26,18 +25,12 @@ class Pet {
//enum statusEnum { available, pending, sold, }; //enum statusEnum { available, pending, sold, };
Pet( Pet(
{this.id = null,
{
this.id = null,
this.category = null, this.category = null,
this.name = null, this.name = null,
this.photoUrls = const [], this.tags = const [], this.photoUrls = const [],
this.status = null this.tags = const [],
this.status = null});
}
);
@override @override
String toString() { String toString() {
@ -46,6 +39,4 @@ class Pet {
} }
@GenSerializer() @GenSerializer()
class PetSerializer extends Serializer<Pet> with _$PetSerializer { class PetSerializer extends Serializer<Pet> with _$PetSerializer {}
}

View File

@ -3,23 +3,13 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'tag.jser.dart'; part 'tag.jser.dart';
class Tag { class Tag {
@Alias('id') @Alias('id')
final int id; final int id;
@Alias('name') @Alias('name')
final String name; final String name;
Tag({this.id = null, this.name = null});
Tag(
{
this.id = null,
this.name = null
}
);
@override @override
String toString() { String toString() {
@ -28,6 +18,4 @@ class Tag {
} }
@GenSerializer() @GenSerializer()
class TagSerializer extends Serializer<Tag> with _$TagSerializer { class TagSerializer extends Serializer<Tag> with _$TagSerializer {}
}

View File

@ -3,7 +3,6 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'user.jser.dart'; part 'user.jser.dart';
class User { class User {
@Alias('id') @Alias('id')
final int id; final int id;
@ -28,22 +27,15 @@ class User {
@Alias('userStatus') @Alias('userStatus')
final int userStatus; final int userStatus;
User( User(
{this.id = null,
{
this.id = null,
this.username = null, this.username = null,
this.firstName = null, this.firstName = null,
this.lastName = null, this.lastName = null,
this.email = null, this.email = null,
this.password = null, this.password = null,
this.phone = null, this.phone = null,
this.userStatus = null this.userStatus = null});
}
);
@override @override
String toString() { String toString() {
@ -52,6 +44,4 @@ class User {
} }
@GenSerializer() @GenSerializer()
class UserSerializer extends Serializer<User> with _$UserSerializer { class UserSerializer extends Serializer<User> with _$UserSerializer {}
}

View File

@ -1 +1 @@
3.3.0-SNAPSHOT 3.3.1-SNAPSHOT

View File

@ -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: This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
- API version: 1.0.0 - API version: 1.0.0
- Build date: 2018-09-21T14:54:03.562304+02:00[Europe/Paris] - Build date: 2018-10-08T15:27:15.700+08:00[Asia/Hong_Kong]
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen - Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
## Requirements ## Requirements

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | **petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] **apiKey** | **String**| | [optional] [default to null]
### Return type ### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | **petId** | **int**| ID of pet to return | [default to null]
### Return type ### Return type
@ -311,7 +311,7 @@ try {
Name | Type | Description | Notes 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] **name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null] **status** | **String**| Updated status of the pet | [optional] [default to null]
@ -358,7 +358,7 @@ try {
Name | Type | Description | Notes 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] **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile****MultipartFile**| file to upload | [optional] [default to null] **file** | **MultipartFile****MultipartFile**| file to upload | [optional] [default to null]

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes 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 ### Return type

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | **username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | **password** | **String**| The password for login in clear text | [default to null]
### Return type ### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes 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 | **user** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@ -18,17 +18,19 @@ import 'package:openapi/model/pet.dart';
import 'package:openapi/model/tag.dart'; import 'package:openapi/model/tag.dart';
import 'package:openapi/model/user.dart'; import 'package:openapi/model/user.dart';
final jsonJaguarRepo = JsonRepo() final jsonJaguarRepo = JsonRepo()
..add(ApiResponseSerializer()) ..add(ApiResponseSerializer())
..add(CategorySerializer()) ..add(CategorySerializer())
..add(OrderSerializer()) ..add(OrderSerializer())
..add(PetSerializer()) ..add(PetSerializer())
..add(TagSerializer()) ..add(TagSerializer())
..add(UserSerializer()) ..add(UserSerializer());
;
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()]; final _defaultInterceptors = [
OAuthInterceptor(),
BasicAuthInterceptor(),
ApiKeyAuthInterceptor()
];
class JaguarApiGen { class JaguarApiGen {
List<Interceptor> interceptors; List<Interceptor> interceptors;
@ -38,15 +40,17 @@ class JaguarApiGen {
/** /**
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added) * 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}) { JaguarApiGen(
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient()); {List<Interceptor> interceptors,
bool overrideInterceptors = false,
String baseUrl}) {
_baseRoute =
Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
if (interceptors == null) { if (interceptors == null) {
this.interceptors = _defaultInterceptors; this.interceptors = _defaultInterceptors;
} } else if (overrideInterceptors) {
else if(overrideInterceptors){
this.interceptors = interceptors; this.interceptors = interceptors;
} } else {
else {
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors); this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
} }
@ -61,14 +65,14 @@ class JaguarApiGen {
} }
void setBasicAuth(String name, String username, String password) { void setBasicAuth(String name, String username, String password) {
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password); (_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] =
BasicAuthInfo(username, password);
} }
void setApiKey(String name, String apiKey) { void setApiKey(String name, String apiKey) {
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey; (_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
} }
/** /**
* Get PetApi instance, base route and serializer can be overridden by a given but be careful, * 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 * by doing that all interceptors will not be executed
@ -83,7 +87,6 @@ class JaguarApiGen {
return PetApi(base: base, serializers: serializers); return PetApi(base: base, serializers: serializers);
} }
/** /**
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful, * 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 * by doing that all interceptors will not be executed
@ -98,7 +101,6 @@ class JaguarApiGen {
return StoreApi(base: base, serializers: serializers); return StoreApi(base: base, serializers: serializers);
} }
/** /**
* Get UserApi instance, base route and serializer can be overridden by a given but be careful, * 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 * by doing that all interceptors will not be executed
@ -112,6 +114,4 @@ class JaguarApiGen {
} }
return UserApi(base: base, serializers: serializers); return UserApi(base: base, serializers: serializers);
} }
} }

View File

@ -3,7 +3,6 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'api_response.jser.dart'; part 'api_response.jser.dart';
class ApiResponse { class ApiResponse {
@Alias('code') @Alias('code')
final int code; final int code;
@ -13,17 +12,7 @@ class ApiResponse {
@Alias('message') @Alias('message')
final String message; final String message;
ApiResponse({this.code = null, this.type = null, this.message = null});
ApiResponse(
{
this.code = null,
this.type = null,
this.message = null
}
);
@override @override
String toString() { String toString() {
@ -32,6 +21,5 @@ class ApiResponse {
} }
@GenSerializer() @GenSerializer()
class ApiResponseSerializer extends Serializer<ApiResponse> with _$ApiResponseSerializer { class ApiResponseSerializer extends Serializer<ApiResponse>
with _$ApiResponseSerializer {}
}

View File

@ -3,23 +3,13 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'category.jser.dart'; part 'category.jser.dart';
class Category { class Category {
@Alias('id') @Alias('id')
final int id; final int id;
@Alias('name') @Alias('name')
final String name; final String name;
Category({this.id = null, this.name = null});
Category(
{
this.id = null,
this.name = null
}
);
@override @override
String toString() { String toString() {
@ -28,6 +18,5 @@ class Category {
} }
@GenSerializer() @GenSerializer()
class CategorySerializer extends Serializer<Category> with _$CategorySerializer { class CategorySerializer extends Serializer<Category>
with _$CategorySerializer {}
}

View File

@ -3,7 +3,6 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'order.jser.dart'; part 'order.jser.dart';
class Order { class Order {
@Alias('id') @Alias('id')
final int id; final int id;
@ -22,20 +21,13 @@ class Order {
@Alias('complete') @Alias('complete')
final bool complete; final bool complete;
Order( Order(
{this.id = null,
{
this.id = null,
this.petId = null, this.petId = null,
this.quantity = null, this.quantity = null,
this.shipDate = null, this.shipDate = null,
this.status = null, this.status = null,
this.complete = false this.complete = false});
}
);
@override @override
String toString() { String toString() {
@ -44,6 +36,4 @@ class Order {
} }
@GenSerializer() @GenSerializer()
class OrderSerializer extends Serializer<Order> with _$OrderSerializer { class OrderSerializer extends Serializer<Order> with _$OrderSerializer {}
}

View File

@ -5,7 +5,6 @@ import 'package:openapi/model/category.dart';
part 'pet.jser.dart'; part 'pet.jser.dart';
class Pet { class Pet {
@Alias('id') @Alias('id')
final int id; final int id;
@ -26,18 +25,12 @@ class Pet {
//enum statusEnum { available, pending, sold, }; //enum statusEnum { available, pending, sold, };
Pet( Pet(
{this.id = null,
{
this.id = null,
this.category = null, this.category = null,
this.name = null, this.name = null,
this.photoUrls = const [], this.tags = const [], this.photoUrls = const [],
this.status = null this.tags = const [],
this.status = null});
}
);
@override @override
String toString() { String toString() {
@ -46,6 +39,4 @@ class Pet {
} }
@GenSerializer() @GenSerializer()
class PetSerializer extends Serializer<Pet> with _$PetSerializer { class PetSerializer extends Serializer<Pet> with _$PetSerializer {}
}

View File

@ -3,23 +3,13 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'tag.jser.dart'; part 'tag.jser.dart';
class Tag { class Tag {
@Alias('id') @Alias('id')
final int id; final int id;
@Alias('name') @Alias('name')
final String name; final String name;
Tag({this.id = null, this.name = null});
Tag(
{
this.id = null,
this.name = null
}
);
@override @override
String toString() { String toString() {
@ -28,6 +18,4 @@ class Tag {
} }
@GenSerializer() @GenSerializer()
class TagSerializer extends Serializer<Tag> with _$TagSerializer { class TagSerializer extends Serializer<Tag> with _$TagSerializer {}
}

View File

@ -3,7 +3,6 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
part 'user.jser.dart'; part 'user.jser.dart';
class User { class User {
@Alias('id') @Alias('id')
final int id; final int id;
@ -28,22 +27,15 @@ class User {
@Alias('userStatus') @Alias('userStatus')
final int userStatus; final int userStatus;
User( User(
{this.id = null,
{
this.id = null,
this.username = null, this.username = null,
this.firstName = null, this.firstName = null,
this.lastName = null, this.lastName = null,
this.email = null, this.email = null,
this.password = null, this.password = null,
this.phone = null, this.phone = null,
this.userStatus = null this.userStatus = null});
}
);
@override @override
String toString() { String toString() {
@ -52,6 +44,4 @@ class User {
} }
@GenSerializer() @GenSerializer()
class UserSerializer extends Serializer<User> with _$UserSerializer { class UserSerializer extends Serializer<User> with _$UserSerializer {}
}

View File

@ -1 +1 @@
3.3.0-SNAPSHOT 3.3.1-SNAPSHOT

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | **petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] **apiKey** | **String**| | [optional] [default to null]
### Return type ### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | **petId** | **int**| ID of pet to return | [default to null]
### Return type ### Return type
@ -311,7 +311,7 @@ try {
Name | Type | Description | Notes 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] **name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null] **status** | **String**| Updated status of the pet | [optional] [default to null]
@ -358,7 +358,7 @@ try {
Name | Type | Description | Notes 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] **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null] **file** | **MultipartFile**| file to upload | [optional] [default to null]

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes 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 ### Return type

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | **username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | **password** | **String**| The password for login in clear text | [default to null]
### Return type ### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes 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 | **user** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@ -1 +1 @@
3.3.0-SNAPSHOT 3.3.1-SNAPSHOT

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | **petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] **apiKey** | **String**| | [optional] [default to null]
### Return type ### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | **petId** | **int**| ID of pet to return | [default to null]
### Return type ### Return type
@ -311,7 +311,7 @@ try {
Name | Type | Description | Notes 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] **name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null] **status** | **String**| Updated status of the pet | [optional] [default to null]
@ -358,7 +358,7 @@ try {
Name | Type | Description | Notes 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] **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null] **file** | **MultipartFile**| file to upload | [optional] [default to null]

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes 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 ### Return type

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | **username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | **password** | **String**| The password for login in clear text | [default to null]
### Return type ### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes 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 | **user** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@ -1 +1 @@
3.3.0-SNAPSHOT 3.3.1-SNAPSHOT

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | **petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] **apiKey** | **String**| | [optional] [default to null]
### Return type ### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | **petId** | **int**| ID of pet to return | [default to null]
### Return type ### Return type
@ -311,7 +311,7 @@ try {
Name | Type | Description | Notes 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] **name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null] **status** | **String**| Updated status of the pet | [optional] [default to null]
@ -358,7 +358,7 @@ try {
Name | Type | Description | Notes 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] **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null] **file** | **MultipartFile**| file to upload | [optional] [default to null]

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes 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 ### Return type

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | **username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | **password** | **String**| The password for login in clear text | [default to null]
### Return type ### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes 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 | **user** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@ -1 +1 @@
3.3.0-SNAPSHOT 3.3.1-SNAPSHOT

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | **petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] **apiKey** | **String**| | [optional] [default to null]
### Return type ### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | **petId** | **int**| ID of pet to return | [default to null]
### Return type ### Return type
@ -311,7 +311,7 @@ try {
Name | Type | Description | Notes 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] **name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null] **status** | **String**| Updated status of the pet | [optional] [default to null]
@ -358,7 +358,7 @@ try {
Name | Type | Description | Notes 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] **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null] **file** | **MultipartFile**| file to upload | [optional] [default to null]

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes 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 ### Return type

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | **username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | **password** | **String**| The password for login in clear text | [default to null]
### Return type ### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes 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 | **user** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@ -41,8 +41,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -86,8 +85,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -267,8 +265,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -322,8 +319,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }

View File

@ -43,8 +43,7 @@ class StoreApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }

View File

@ -41,8 +41,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -83,8 +82,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -125,8 +123,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -169,8 +166,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -303,8 +299,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -350,8 +345,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }

View File

@ -1 +1 @@
3.3.0-SNAPSHOT 3.3.1-SNAPSHOT

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | **petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] **apiKey** | **String**| | [optional] [default to null]
### Return type ### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | **petId** | **int**| ID of pet to return | [default to null]
### Return type ### Return type
@ -311,7 +311,7 @@ try {
Name | Type | Description | Notes 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] **name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null] **status** | **String**| Updated status of the pet | [optional] [default to null]
@ -358,7 +358,7 @@ try {
Name | Type | Description | Notes 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] **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null] **file** | **MultipartFile**| file to upload | [optional] [default to null]

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes 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 ### Return type

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | **username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | **password** | **String**| The password for login in clear text | [default to null]
### Return type ### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes 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 | **user** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@ -41,8 +41,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -86,8 +85,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -267,8 +265,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -322,8 +319,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }

View File

@ -43,8 +43,7 @@ class StoreApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }

View File

@ -41,8 +41,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -83,8 +82,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -125,8 +123,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -169,8 +166,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -303,8 +299,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -350,8 +345,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }

View File

@ -1 +1 @@
3.3.0-SNAPSHOT 3.3.1-SNAPSHOT

View File

@ -87,8 +87,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| Pet id to delete | **petId** | **int**| Pet id to delete | [default to null]
**apiKey** | **String**| | [optional] **apiKey** | **String**| | [optional] [default to null]
### Return type ### Return type
@ -133,7 +133,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -178,7 +178,7 @@ try {
Name | Type | Description | Notes 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 []]
### Return type ### Return type
@ -225,7 +225,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to return | **petId** | **int**| ID of pet to return | [default to null]
### Return type ### Return type
@ -311,7 +311,7 @@ try {
Name | Type | Description | Notes 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] **name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] [default to null] **status** | **String**| Updated status of the pet | [optional] [default to null]
@ -358,7 +358,7 @@ try {
Name | Type | Description | Notes 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] **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] [default to null] **file** | **MultipartFile**| file to upload | [optional] [default to null]

View File

@ -40,7 +40,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -126,7 +126,7 @@ try {
Name | Type | Description | Notes 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 ### Return type

View File

@ -166,7 +166,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -207,7 +207,7 @@ try {
Name | Type | Description | Notes 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 ### Return type
@ -249,8 +249,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login | **username** | **String**| The user name for login | [default to null]
**password** | **String**| The password for login in clear text | **password** | **String**| The password for login in clear text | [default to null]
### Return type ### Return type
@ -329,7 +329,7 @@ try {
Name | Type | Description | Notes 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 | **user** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@ -41,8 +41,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -86,8 +85,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -267,8 +265,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -322,8 +319,7 @@ class PetApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }

View File

@ -43,8 +43,7 @@ class StoreApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }

View File

@ -41,8 +41,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -83,8 +82,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -125,8 +123,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -169,8 +166,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -303,8 +299,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }
@ -350,8 +345,7 @@ class UserApi {
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) { } else if (response.body != null) {} else {
} else {
return; return;
} }
} }

View File

@ -1 +1 @@
3.3.0-SNAPSHOT 3.3.1-SNAPSHOT

View File

@ -17,8 +17,7 @@ import scala.reflect.ClassTag
object EnumsSerializers { object EnumsSerializers {
def all: Seq[Serializer[_]] = def all: Seq[Serializer[_]] = Seq[Serializer[_]]() :+
Seq[Serializer[_]]() :+
new EnumNameSerializer(OrderEnums.Status) :+ new EnumNameSerializer(OrderEnums.Status) :+
new EnumNameSerializer(PetEnums.Status) new EnumNameSerializer(PetEnums.Status)
@ -28,15 +27,14 @@ object EnumsSerializers {
val EnumerationClass: Class[E#Value] = classOf[E#Value] val EnumerationClass: Class[E#Value] = classOf[E#Value]
def deserialize(implicit format: Formats) def deserialize(implicit format: Formats):
: PartialFunction[(TypeInfo, JValue), E#Value] = { PartialFunction[(TypeInfo, JValue), E#Value] = {
case (t @ TypeInfo(EnumerationClass, _), json) if isValid(json) => case (t @ TypeInfo(EnumerationClass, _), json) if isValid(json) =>
json match { json match {
case JString(value) => case JString(value) =>
enum.withName(value) enum.withName(value)
case value => case value =>
throw new MappingException( throw new MappingException(s"Can't convert $value to $EnumerationClass")
s"Can't convert $value to $EnumerationClass")
} }
} }

View File

@ -27,13 +27,9 @@ object PetApi {
* @param pet Pet object that needs to be added to the store * @param pet Pet object that needs to be added to the store
*/ */
def addPet(pet: Pet): ApiRequest[Unit] = def addPet(pet: Pet): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet", "application/json")
"http://petstore.swagger.io/v2",
"/pet",
"application/json")
.withBody(pet) .withBody(pet)
.withErrorResponse[Unit](405) .withErrorResponse[Unit](405)
/** /**
* Expected answers: * Expected answers:
* code 400 : (Invalid pet value) * code 400 : (Invalid pet value)
@ -42,14 +38,10 @@ object PetApi {
* @param apiKey * @param apiKey
*/ */
def deletePet(petId: Long, apiKey: Option[String] = None): ApiRequest[Unit] = def deletePet(petId: Long, apiKey: Option[String] = None): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.DELETE, ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json")
"http://petstore.swagger.io/v2",
"/pet/{petId}",
"application/json")
.withPathParam("petId", petId) .withPathParam("petId", petId)
.withHeaderParam("api_key", apiKey) .withHeaderParam("api_key", apiKey)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
/** /**
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* *
@ -60,14 +52,10 @@ object PetApi {
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
def findPetsByStatus(status: Seq[String]): ApiRequest[Seq[Pet]] = def findPetsByStatus(status: Seq[String]): ApiRequest[Seq[Pet]] =
ApiRequest[Seq[Pet]](ApiMethods.GET, ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByStatus", "application/json")
"http://petstore.swagger.io/v2",
"/pet/findByStatus",
"application/json")
.withQueryParam("status", ArrayValues(status, CSV)) .withQueryParam("status", ArrayValues(status, CSV))
.withSuccessResponse[Seq[Pet]](200) .withSuccessResponse[Seq[Pet]](200)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
/** /**
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* *
@ -78,14 +66,10 @@ object PetApi {
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
def findPetsByTags(tags: Seq[String]): ApiRequest[Seq[Pet]] = def findPetsByTags(tags: Seq[String]): ApiRequest[Seq[Pet]] =
ApiRequest[Seq[Pet]](ApiMethods.GET, ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByTags", "application/json")
"http://petstore.swagger.io/v2",
"/pet/findByTags",
"application/json")
.withQueryParam("tags", ArrayValues(tags, CSV)) .withQueryParam("tags", ArrayValues(tags, CSV))
.withSuccessResponse[Seq[Pet]](200) .withSuccessResponse[Seq[Pet]](200)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
/** /**
* Returns a single pet * Returns a single pet
* *
@ -100,16 +84,12 @@ object PetApi {
* @param petId ID of pet to return * @param petId ID of pet to return
*/ */
def getPetById(petId: Long)(implicit apiKey: ApiKeyValue): ApiRequest[Unit] = def getPetById(petId: Long)(implicit apiKey: ApiKeyValue): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.GET, ApiRequest[Unit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json")
"http://petstore.swagger.io/v2",
"/pet/{petId}",
"application/json")
.withApiKey(apiKey, "api_key", HEADER) .withApiKey(apiKey, "api_key", HEADER)
.withPathParam("petId", petId) .withPathParam("petId", petId)
.withSuccessResponse[Pet](200) .withSuccessResponse[Pet](200)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
.withErrorResponse[Unit](404) .withErrorResponse[Unit](404)
/** /**
* Expected answers: * Expected answers:
* code 400 : (Invalid ID supplied) * code 400 : (Invalid ID supplied)
@ -119,15 +99,11 @@ object PetApi {
* @param pet Pet object that needs to be added to the store * @param pet Pet object that needs to be added to the store
*/ */
def updatePet(pet: Pet): ApiRequest[Unit] = def updatePet(pet: Pet): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.PUT, ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/pet", "application/json")
"http://petstore.swagger.io/v2",
"/pet",
"application/json")
.withBody(pet) .withBody(pet)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
.withErrorResponse[Unit](404) .withErrorResponse[Unit](404)
.withErrorResponse[Unit](405) .withErrorResponse[Unit](405)
/** /**
* Expected answers: * Expected answers:
* code 405 : (Invalid input) * code 405 : (Invalid input)
@ -136,18 +112,12 @@ object PetApi {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
def updatePetWithForm(petId: Long, def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None): ApiRequest[Unit] =
name: Option[String] = None, ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/x-www-form-urlencoded")
status: Option[String] = None): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST,
"http://petstore.swagger.io/v2",
"/pet/{petId}",
"application/x-www-form-urlencoded")
.withFormParam("name", name) .withFormParam("name", name)
.withFormParam("status", status) .withFormParam("status", status)
.withPathParam("petId", petId) .withPathParam("petId", petId)
.withErrorResponse[Unit](405) .withErrorResponse[Unit](405)
/** /**
* Expected answers: * Expected answers:
* code 200 : ApiResponse (successful operation) * code 200 : ApiResponse (successful operation)
@ -156,16 +126,13 @@ object PetApi {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
def uploadFile(petId: Long, def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): ApiRequest[Unit] =
additionalMetadata: Option[String] = None, ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}/uploadImage", "multipart/form-data")
file: Option[File] = None): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST,
"http://petstore.swagger.io/v2",
"/pet/{petId}/uploadImage",
"multipart/form-data")
.withFormParam("additionalMetadata", additionalMetadata) .withFormParam("additionalMetadata", additionalMetadata)
.withFormParam("file", file) .withFormParam("file", file)
.withPathParam("petId", petId) .withPathParam("petId", petId)
.withSuccessResponse[ApiResponse](200) .withSuccessResponse[ApiResponse](200)
} }

View File

@ -28,14 +28,10 @@ object StoreApi {
* @param orderId ID of the order that needs to be deleted * @param orderId ID of the order that needs to be deleted
*/ */
def deleteOrder(orderId: String): ApiRequest[Unit] = def deleteOrder(orderId: String): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.DELETE, ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json")
"http://petstore.swagger.io/v2",
"/store/order/{orderId}",
"application/json")
.withPathParam("orderId", orderId) .withPathParam("orderId", orderId)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
.withErrorResponse[Unit](404) .withErrorResponse[Unit](404)
/** /**
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
* *
@ -45,15 +41,10 @@ object StoreApi {
* Available security schemes: * Available security schemes:
* api_key (apiKey) * api_key (apiKey)
*/ */
def getInventory()( def getInventory()(implicit apiKey: ApiKeyValue): ApiRequest[Map[String, Int]] =
implicit apiKey: ApiKeyValue): ApiRequest[Map[String, Int]] = ApiRequest[Map[String, Int]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/inventory", "application/json")
ApiRequest[Map[String, Int]](ApiMethods.GET,
"http://petstore.swagger.io/v2",
"/store/inventory",
"application/json")
.withApiKey(apiKey, "api_key", HEADER) .withApiKey(apiKey, "api_key", HEADER)
.withSuccessResponse[Map[String, Int]](200) .withSuccessResponse[Map[String, Int]](200)
/** /**
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
* *
@ -65,15 +56,11 @@ object StoreApi {
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
def getOrderById(orderId: Long): ApiRequest[Unit] = def getOrderById(orderId: Long): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.GET, ApiRequest[Unit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json")
"http://petstore.swagger.io/v2",
"/store/order/{orderId}",
"application/json")
.withPathParam("orderId", orderId) .withPathParam("orderId", orderId)
.withSuccessResponse[Order](200) .withSuccessResponse[Order](200)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
.withErrorResponse[Unit](404) .withErrorResponse[Unit](404)
/** /**
* Expected answers: * Expected answers:
* code 200 : Order (successful operation) * code 200 : Order (successful operation)
@ -82,12 +69,11 @@ object StoreApi {
* @param order order placed for purchasing the pet * @param order order placed for purchasing the pet
*/ */
def placeOrder(order: Order): ApiRequest[Unit] = def placeOrder(order: Order): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/store/order", "application/json")
"http://petstore.swagger.io/v2",
"/store/order",
"application/json")
.withBody(order) .withBody(order)
.withSuccessResponse[Order](200) .withSuccessResponse[Order](200)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
} }

View File

@ -27,13 +27,9 @@ object UserApi {
* @param user Created user object * @param user Created user object
*/ */
def createUser(user: User): ApiRequest[Unit] = def createUser(user: User): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user", "application/json")
"http://petstore.swagger.io/v2",
"/user",
"application/json")
.withBody(user) .withBody(user)
.withDefaultSuccessResponse[Unit] .withDefaultSuccessResponse[Unit]
/** /**
* Expected answers: * Expected answers:
* code 0 : (successful operation) * code 0 : (successful operation)
@ -41,13 +37,9 @@ object UserApi {
* @param user List of user object * @param user List of user object
*/ */
def createUsersWithArrayInput(user: Seq[User]): ApiRequest[Unit] = def createUsersWithArrayInput(user: Seq[User]): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithArray", "application/json")
"http://petstore.swagger.io/v2",
"/user/createWithArray",
"application/json")
.withBody(user) .withBody(user)
.withDefaultSuccessResponse[Unit] .withDefaultSuccessResponse[Unit]
/** /**
* Expected answers: * Expected answers:
* code 0 : (successful operation) * code 0 : (successful operation)
@ -55,13 +47,9 @@ object UserApi {
* @param user List of user object * @param user List of user object
*/ */
def createUsersWithListInput(user: Seq[User]): ApiRequest[Unit] = def createUsersWithListInput(user: Seq[User]): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithList", "application/json")
"http://petstore.swagger.io/v2",
"/user/createWithList",
"application/json")
.withBody(user) .withBody(user)
.withDefaultSuccessResponse[Unit] .withDefaultSuccessResponse[Unit]
/** /**
* This can only be done by the logged in user. * This can only be done by the logged in user.
* *
@ -72,14 +60,10 @@ object UserApi {
* @param username The name that needs to be deleted * @param username The name that needs to be deleted
*/ */
def deleteUser(username: String): ApiRequest[Unit] = def deleteUser(username: String): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.DELETE, ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
"http://petstore.swagger.io/v2",
"/user/{username}",
"application/json")
.withPathParam("username", username) .withPathParam("username", username)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
.withErrorResponse[Unit](404) .withErrorResponse[Unit](404)
/** /**
* Expected answers: * Expected answers:
* code 200 : User (successful operation) * code 200 : User (successful operation)
@ -89,15 +73,11 @@ object UserApi {
* @param username The name that needs to be fetched. Use user1 for testing. * @param username The name that needs to be fetched. Use user1 for testing.
*/ */
def getUserByName(username: String): ApiRequest[Unit] = def getUserByName(username: String): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.GET, ApiRequest[Unit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
"http://petstore.swagger.io/v2",
"/user/{username}",
"application/json")
.withPathParam("username", username) .withPathParam("username", username)
.withSuccessResponse[User](200) .withSuccessResponse[User](200)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
.withErrorResponse[Unit](404) .withErrorResponse[Unit](404)
/** /**
* Expected answers: * Expected answers:
* code 200 : String (successful operation) * code 200 : String (successful operation)
@ -110,10 +90,7 @@ object UserApi {
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
def loginUser(username: String, password: String): ApiRequest[Unit] = def loginUser(username: String, password: String): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.GET, ApiRequest[Unit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/login", "application/json")
"http://petstore.swagger.io/v2",
"/user/login",
"application/json")
.withQueryParam("username", username) .withQueryParam("username", username)
.withQueryParam("password", password) .withQueryParam("password", password)
.withSuccessResponse[String](200) .withSuccessResponse[String](200)
@ -121,21 +98,15 @@ object UserApi {
object LoginUserHeaders { object LoginUserHeaders {
def xRateLimit(r: ApiReturnWithHeaders) = r.getIntHeader("X-Rate-Limit") def xRateLimit(r: ApiReturnWithHeaders) = r.getIntHeader("X-Rate-Limit")
def xExpiresAfter(r: ApiReturnWithHeaders) = def xExpiresAfter(r: ApiReturnWithHeaders) = r.getDateTimeHeader("X-Expires-After")
r.getDateTimeHeader("X-Expires-After")
} }
/** /**
* Expected answers: * Expected answers:
* code 0 : (successful operation) * code 0 : (successful operation)
*/ */
def logoutUser(): ApiRequest[Unit] = def logoutUser(): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.GET, ApiRequest[Unit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/logout", "application/json")
"http://petstore.swagger.io/v2",
"/user/logout",
"application/json")
.withDefaultSuccessResponse[Unit] .withDefaultSuccessResponse[Unit]
/** /**
* This can only be done by the logged in user. * This can only be done by the logged in user.
* *
@ -147,13 +118,12 @@ object UserApi {
* @param user Updated user object * @param user Updated user object
*/ */
def updateUser(username: String, user: User): ApiRequest[Unit] = def updateUser(username: String, user: User): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.PUT, ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
"http://petstore.swagger.io/v2",
"/user/{username}",
"application/json")
.withBody(user) .withBody(user)
.withPathParam("username", username) .withPathParam("username", username)
.withErrorResponse[Unit](400) .withErrorResponse[Unit](400)
.withErrorResponse[Unit](404) .withErrorResponse[Unit](404)
} }

View File

@ -46,29 +46,17 @@ object ApiInvoker {
def apply()(implicit system: ActorSystem): ApiInvoker = def apply()(implicit system: ActorSystem): ApiInvoker =
apply(DefaultFormats + DateTimeSerializer) apply(DefaultFormats + DateTimeSerializer)
def apply(serializers: Traversable[Serializer[_]])( def apply(serializers: Traversable[Serializer[_]])(implicit system: ActorSystem): ApiInvoker =
implicit system: ActorSystem): ApiInvoker =
apply(DefaultFormats + DateTimeSerializer ++ serializers) apply(DefaultFormats + DateTimeSerializer ++ serializers)
def apply(formats: Formats)(implicit system: ActorSystem): ApiInvoker = def apply(formats: Formats)(implicit system: ActorSystem): ApiInvoker = new ApiInvoker(formats)
new ApiInvoker(formats)
case class CustomStatusCode( case class CustomStatusCode(value: Int, reason: String = "Application-defined status code", isSuccess: Boolean = true)
value: Int,
reason: String = "Application-defined status code",
isSuccess: Boolean = true)
def addCustomStatusCode(code: CustomStatusCode): Unit = def addCustomStatusCode(code: CustomStatusCode): Unit = addCustomStatusCode(code.value, code.reason, code.isSuccess)
addCustomStatusCode(code.value, code.reason, code.isSuccess)
def addCustomStatusCode(code: Int, def addCustomStatusCode(code: Int, reason: String = "Application defined code", isSuccess: Boolean = true): Unit = {
reason: String = "Application defined code",
isSuccess: Boolean = true): Unit = {
StatusCodes.getForKey(code) foreach { _ => StatusCodes.getForKey(code) foreach { _ =>
StatusCodes.registerCustom(code, StatusCodes.registerCustom(code, reason, reason, isSuccess, allowsEntity = true)
reason,
reason,
isSuccess,
allowsEntity = true)
} }
} }
@ -81,20 +69,13 @@ object ApiInvoker {
*/ */
implicit class ApiRequestImprovements[T](request: ApiRequest[T]) { implicit class ApiRequestImprovements[T](request: ApiRequest[T]) {
def response(invoker: ApiInvoker)( def response(invoker: ApiInvoker)(implicit ec: ExecutionContext, system: ActorSystem): Future[ApiResponse[T]] =
implicit ec: ExecutionContext,
system: ActorSystem): Future[ApiResponse[T]] =
response(ec, system, invoker) response(ec, system, invoker)
def response(implicit ec: ExecutionContext, def response(implicit ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[ApiResponse[T]] =
system: ActorSystem,
invoker: ApiInvoker): Future[ApiResponse[T]] =
invoker.execute(request) invoker.execute(request)
def result[U <: T](implicit c: ClassTag[U], def result[U <: T](implicit c: ClassTag[U], ec: ExecutionContext, system: ActorSystem, invoker: ApiInvoker): Future[U] =
ec: ExecutionContext,
system: ActorSystem,
invoker: ApiInvoker): Future[U] =
invoker.execute(request).map(_.content).mapTo[U] invoker.execute(request).map(_.content).mapTo[U]
} }
@ -104,13 +85,10 @@ object ApiInvoker {
* @param method the ApiMethod to be converted * @param method the ApiMethod to be converted
*/ */
implicit class ApiMethodExtensions(val method: ApiMethod) { implicit class ApiMethodExtensions(val method: ApiMethod) {
def toSprayMethod: HttpMethod = def toSprayMethod: HttpMethod = HttpMethods.getForKey(method.value).getOrElse(HttpMethods.GET)
HttpMethods.getForKey(method.value).getOrElse(HttpMethods.GET)
} }
case object DateTimeSerializer case object DateTimeSerializer extends CustomSerializer[DateTime](format => ( {
extends CustomSerializer[DateTime](format =>
({
case JString(s) => case JString(s) =>
ISODateTimeFormat.dateOptionalTimeParser().parseDateTime(s) ISODateTimeFormat.dateOptionalTimeParser().parseDateTime(s)
}, { }, {
@ -119,9 +97,7 @@ object ApiInvoker {
})) }))
} }
class ApiInvoker(formats: Formats)(implicit system: ActorSystem) class ApiInvoker(formats: Formats)(implicit system: ActorSystem) extends UntrustedSslContext with CustomContentTypes {
extends UntrustedSslContext
with CustomContentTypes {
import org.openapitools.client.core.ApiInvoker._ import org.openapitools.client.core.ApiInvoker._
import org.openapitools.client.core.ParametersMap._ import org.openapitools.client.core.ParametersMap._
@ -133,27 +109,23 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem)
import spray.http.MessagePredicate._ import spray.http.MessagePredicate._
val CompressionFilter: MessagePredicate = MessagePredicate({ _ => val CompressionFilter: MessagePredicate= MessagePredicate({ _ => settings.compressionEnabled}) &&
settings.compressionEnabled
}) &&
Encoder.DefaultFilter && minEntitySize(settings.compressionSizeThreshold) Encoder.DefaultFilter && minEntitySize(settings.compressionSizeThreshold)
settings.customCodes.foreach(addCustomStatusCode) settings.customCodes.foreach(addCustomStatusCode)
private def addAuthentication( private def addAuthentication(credentialsSeq: Seq[Credentials]): pipelining.RequestTransformer =
credentialsSeq: Seq[Credentials]): pipelining.RequestTransformer =
request => request =>
credentialsSeq.foldLeft(request) { credentialsSeq.foldLeft(request) {
case (req, BasicCredentials(login, password)) => case (req, BasicCredentials(login, password)) =>
req ~> addCredentials(BasicHttpCredentials(login, password)) req ~> addCredentials(BasicHttpCredentials(login, password))
case (req, case (req, ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
ApiKeyCredentials(keyValue, keyName, ApiKeyLocations.HEADER)) =>
req ~> addHeader(RawHeader(keyName, keyValue.value)) req ~> addHeader(RawHeader(keyName, keyValue.value))
case (req, _) => req case (req, _) => req
} }
private def addHeaders( private def addHeaders(headers: Map[String, Any]): pipelining.RequestTransformer = { request =>
headers: Map[String, Any]): pipelining.RequestTransformer = { request =>
val rawHeaders = for { val rawHeaders = for {
(name, value) <- headers.asFormattedParams (name, value) <- headers.asFormattedParams
header = RawHeader(name, String.valueOf(value)) header = RawHeader(name, String.valueOf(value))
@ -183,9 +155,7 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem)
Some( Some(
normalizedContentType(request.contentType).mediaType match { normalizedContentType(request.contentType).mediaType match {
case MediaTypes.`multipart/form-data` => case MediaTypes.`multipart/form-data` =>
MultipartFormData(params.map { MultipartFormData(params.map { case (name, value) => (name, bodyPart(name, value))})
case (name, value) => (name, bodyPart(name, value))
})
case MediaTypes.`application/x-www-form-urlencoded` => case MediaTypes.`application/x-www-form-urlencoded` =>
FormData(params.mapValues(String.valueOf)) FormData(params.mapValues(String.valueOf))
case m: MediaType => // Default : application/x-www-form-urlencoded. case m: MediaType => // Default : application/x-www-form-urlencoded.
@ -210,13 +180,9 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem)
case Some(c: MultipartFormData) => case Some(c: MultipartFormData) =>
builder.apply(uri, c) builder.apply(uri, c)
case Some(c: String) => case Some(c: String) =>
builder.apply( builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), c))
uri,
HttpEntity(normalizedContentType(request.contentType), c))
case _ => case _ =>
builder.apply( builder.apply(uri, HttpEntity(normalizedContentType(request.contentType), " "))
uri,
HttpEntity(normalizedContentType(request.contentType), " "))
} }
case _ => builder.apply(uri) case _ => builder.apply(uri)
} }
@ -228,13 +194,11 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem)
} }
def makeQuery(r: ApiRequest[_]): Query = { def makeQuery(r: ApiRequest[_]): Query = {
r.credentials r.credentials.foldLeft(r.queryParams) {
.foldLeft(r.queryParams) {
case (params, ApiKeyCredentials(key, keyName, ApiKeyLocations.QUERY)) => case (params, ApiKeyCredentials(key, keyName, ApiKeyLocations.QUERY)) =>
params + (keyName -> key.value) params + (keyName -> key.value)
case (params, _) => params case (params, _) => params
} }.asFormattedParams
.asFormattedParams
.mapValues(String.valueOf) .mapValues(String.valueOf)
.foldRight[Query](Uri.Query.Empty) { .foldRight[Query](Uri.Query.Empty) {
case ((name, value), acc) => acc.+:(name, value) case ((name, value), acc) => acc.+:(name, value)
@ -263,9 +227,7 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem)
uri.authority.host.toString, uri.authority.host.toString,
uri.effectivePort, uri.effectivePort,
sslEncryption = "https".equals(uri.scheme), sslEncryption = "https".equals(uri.scheme),
defaultHeaders = settings.defaultHeaders ++ List( defaultHeaders = settings.defaultHeaders ++ List(`Accept-Encoding`(gzip, deflate)))
`Accept-Encoding`(gzip, deflate))
)
val request = createRequest(uri, r) val request = createRequest(uri, r)
@ -275,62 +237,46 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem)
} yield { } yield {
response ~> decode(Deflate) ~> decode(Gzip) ~> unmarshallApiResponse(r) response ~> decode(Deflate) ~> decode(Gzip) ~> unmarshallApiResponse(r)
} }
} catch { }
catch {
case NonFatal(x) => Future.failed(x) case NonFatal(x) => Future.failed(x)
} }
} }
def unmarshallApiResponse[T](request: ApiRequest[T])( def unmarshallApiResponse[T](request: ApiRequest[T])(response: HttpResponse): ApiResponse[T] = {
response: HttpResponse): ApiResponse[T] = {
request.responseForCode(response.status.intValue) match { request.responseForCode(response.status.intValue) match {
case Some( (manifest: Manifest[T], state: ResponseState) ) => case Some( (manifest: Manifest[T], state: ResponseState) ) =>
entityUnmarshaller(manifest)(response.entity) match { entityUnmarshaller(manifest)(response.entity) match {
case Right(value) case Right(value)
state match { state match {
case ResponseState.Success => case ResponseState.Success =>
ApiResponse(response.status.intValue, ApiResponse(response.status.intValue, value, response.headers.map(header => (header.name, header.value)).toMap)
value,
response.headers
.map(header => (header.name, header.value))
.toMap)
case ResponseState.Error => case ResponseState.Error =>
throw ApiError(response.status.intValue, throw ApiError(response.status.intValue, "Error response received",
"Error response received",
Some(value), Some(value),
headers = response.headers headers = response.headers.map(header => (header.name, header.value)).toMap)
.map(header => (header.name, header.value))
.toMap)
} }
case Left(MalformedContent(error, Some(cause))) case Left(MalformedContent(error, Some(cause)))
throw ApiError(response.status.intValue, throw ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString), cause)
s"Unable to unmarshall content to [$manifest]",
Some(response.entity.toString),
cause)
case Left(MalformedContent(error, None)) case Left(MalformedContent(error, None))
throw ApiError(response.status.intValue, throw ApiError(response.status.intValue, s"Unable to unmarshall content to [$manifest]", Some(response.entity.toString))
s"Unable to unmarshall content to [$manifest]",
Some(response.entity.toString))
case Left(ContentExpected) case Left(ContentExpected)
throw ApiError( throw ApiError(response.status.intValue, s"Unable to unmarshall empty response to [$manifest]", Some(response.entity.toString))
response.status.intValue,
s"Unable to unmarshall empty response to [$manifest]",
Some(response.entity.toString))
} }
case _ => case _ => throw ApiError(response.status.intValue, "Unexpected response code", Some(response.entity.toString))
throw ApiError(response.status.intValue,
"Unexpected response code",
Some(response.entity.toString))
} }
} }
def entityUnmarshaller[T](implicit mf: Manifest[T]): Unmarshaller[T] = def entityUnmarshaller[T](implicit mf: Manifest[T]): Unmarshaller[T] =
Unmarshaller[T](MediaTypes.`application/json`) { Unmarshaller[T](MediaTypes.`application/json`) {
case x: HttpEntity.NonEmpty case x: HttpEntity.NonEmpty
parse(x.asString(defaultCharset = HttpCharsets.`UTF-8`)).noNulls.camelizeKeys parse(x.asString(defaultCharset = HttpCharsets.`UTF-8`))
.noNulls
.camelizeKeys
.extract[T] .extract[T]
} }
@ -339,12 +285,10 @@ class ApiInvoker(formats: Formats)(implicit system: ActorSystem)
sealed trait CustomContentTypes { sealed trait CustomContentTypes {
def normalizedContentType(original: String): ContentType = def normalizedContentType(original: String): ContentType =
MediaTypes.forExtension(original) map (ContentType(_)) getOrElse parseContentType( MediaTypes.forExtension(original) map (ContentType(_)) getOrElse parseContentType(original)
original)
def parseContentType(contentType: String): ContentType = { def parseContentType(contentType: String): ContentType = {
val contentTypeAsRawHeader = val contentTypeAsRawHeader = HttpHeaders.RawHeader("Content-Type", contentType)
HttpHeaders.RawHeader("Content-Type", contentType)
val parsedContentTypeHeader = HttpParser.parseHeader(contentTypeAsRawHeader) val parsedContentTypeHeader = HttpParser.parseHeader(contentTypeAsRawHeader)
(parsedContentTypeHeader: @unchecked) match { (parsedContentTypeHeader: @unchecked) match {
case Right(ct: HttpHeaders.`Content-Type`) => case Right(ct: HttpHeaders.`Content-Type`) =>
@ -366,11 +310,9 @@ sealed trait UntrustedSslContext {
case true => case true =>
class IgnoreX509TrustManager extends X509TrustManager { class IgnoreX509TrustManager extends X509TrustManager {
def checkClientTrusted(chain: Array[X509Certificate], def checkClientTrusted(chain: Array[X509Certificate], authType: String): Unit = {}
authType: String): Unit = {}
def checkServerTrusted(chain: Array[X509Certificate], def checkServerTrusted(chain: Array[X509Certificate], authType: String): Unit = {}
authType: String): Unit = {}
def getAcceptedIssuers = null def getAcceptedIssuers = null
} }
@ -382,7 +324,8 @@ sealed trait UntrustedSslContext {
} }
implicit val clientSSLEngineProvider = implicit val clientSSLEngineProvider =
ClientSSLEngineProvider { _ => ClientSSLEngineProvider {
_ =>
val engine = trustfulSslContext.createSSLEngine() val engine = trustfulSslContext.createSSLEngine()
engine.setUseClientMode(true) engine.setUseClientMode(true)
engine engine

View File

@ -27,9 +27,9 @@ case class ApiRequest[U](
basePath: String, basePath: String,
operationPath: String, operationPath: String,
contentType: String, contentType: String,
// optional fields // optional fields
responses: Map[Int, (Manifest[_], ResponseState)] = responses: Map[Int, (Manifest[_], ResponseState)] = Map.empty,
Map.empty,
bodyParam: Option[Any] = None, bodyParam: Option[Any] = None,
formParams: Map[String, Any] = Map.empty, formParams: Map[String, Any] = Map.empty,
pathParams: Map[String, Any] = Map.empty, pathParams: Map[String, Any] = Map.empty,
@ -37,43 +37,29 @@ case class ApiRequest[U](
headerParams: Map[String, Any] = Map.empty, headerParams: Map[String, Any] = Map.empty,
credentials: Seq[Credentials] = List.empty) { credentials: Seq[Credentials] = List.empty) {
def withCredentials(cred: Credentials): ApiRequest[U] = def withCredentials(cred: Credentials): ApiRequest[U] = copy[U](credentials = credentials :+ cred)
copy[U](credentials = credentials :+ cred)
def withApiKey(key: ApiKeyValue, def withApiKey(key: ApiKeyValue, keyName: String, location: ApiKeyLocation): ApiRequest[U] = withCredentials(ApiKeyCredentials(key, keyName, location))
keyName: String,
location: ApiKeyLocation): ApiRequest[U] =
withCredentials(ApiKeyCredentials(key, keyName, location))
def withSuccessResponse[T](code: Int)( def withSuccessResponse[T](code: Int)(implicit m: Manifest[T]): ApiRequest[U] = copy[U](responses = responses + (code -> (m, ResponseState.Success)))
implicit m: Manifest[T]): ApiRequest[U] =
copy[U](responses = responses + (code -> (m, ResponseState.Success)))
def withErrorResponse[T](code: Int)(implicit m: Manifest[T]): ApiRequest[U] = def withErrorResponse[T](code: Int)(implicit m: Manifest[T]): ApiRequest[U] = copy[U](responses = responses + (code -> (m, ResponseState.Error)))
copy[U](responses = responses + (code -> (m, ResponseState.Error)))
def withDefaultSuccessResponse[T](implicit m: Manifest[T]): ApiRequest[U] = def withDefaultSuccessResponse[T](implicit m: Manifest[T]): ApiRequest[U] = withSuccessResponse[T](0)
withSuccessResponse[T](0)
def withDefaultErrorResponse[T](implicit m: Manifest[T]): ApiRequest[U] = def withDefaultErrorResponse[T](implicit m: Manifest[T]): ApiRequest[U] = withErrorResponse[T](0)
withErrorResponse[T](0)
def responseForCode(statusCode: Int): Option[(Manifest[_], ResponseState)] = def responseForCode(statusCode: Int): Option[(Manifest[_], ResponseState)] = responses.get(statusCode) orElse responses.get(0)
responses.get(statusCode) orElse responses.get(0)
def withoutBody(): ApiRequest[U] = copy[U](bodyParam = None) def withoutBody(): ApiRequest[U] = copy[U](bodyParam = None)
def withBody(body: Any): ApiRequest[U] = copy[U](bodyParam = Some(body)) def withBody(body: Any): ApiRequest[U] = copy[U](bodyParam = Some(body))
def withFormParam(name: String, value: Any): ApiRequest[U] = def withFormParam(name: String, value: Any): ApiRequest[U] = copy[U](formParams = formParams + (name -> value))
copy[U](formParams = formParams + (name -> value))
def withPathParam(name: String, value: Any): ApiRequest[U] = def withPathParam(name: String, value: Any): ApiRequest[U] = copy[U](pathParams = pathParams + (name -> value))
copy[U](pathParams = pathParams + (name -> value))
def withQueryParam(name: String, value: Any): ApiRequest[U] = def withQueryParam(name: String, value: Any): ApiRequest[U] = copy[U](queryParams = queryParams + (name -> value))
copy[U](queryParams = queryParams + (name -> value))
def withHeaderParam(name: String, value: Any): ApiRequest[U] = def withHeaderParam(name: String, value: Any): ApiRequest[U] = copy[U](headerParams = headerParams + (name -> value))
copy[U](headerParams = headerParams + (name -> value))
} }

View File

@ -27,20 +27,13 @@ class ApiSettings(config: Config) extends Extension {
private def cfg = config.getConfig("org.openapitools.client.apiRequest") private def cfg = config.getConfig("org.openapitools.client.apiRequest")
val alwaysTrustCertificates: Boolean = cfg.getBoolean("trust-certificates") val alwaysTrustCertificates: Boolean = cfg.getBoolean("trust-certificates")
val defaultHeaders: List[RawHeader] = cfg val defaultHeaders: List[RawHeader] = cfg.getConfig("default-headers").entrySet.toList.map(c => RawHeader(c.getKey, c.getValue.render))
.getConfig("default-headers") val connectionTimeout = FiniteDuration(cfg.getDuration("connection-timeout", TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS)
.entrySet
.toList
.map(c => RawHeader(c.getKey, c.getValue.render))
val connectionTimeout = FiniteDuration(
cfg.getDuration("connection-timeout", TimeUnit.MILLISECONDS),
TimeUnit.MILLISECONDS)
val compressionEnabled: Boolean = cfg.getBoolean("compression.enabled") val compressionEnabled: Boolean = cfg.getBoolean("compression.enabled")
val compressionSizeThreshold: Int = val compressionSizeThreshold: Int = cfg.getBytes("compression.size-threshold").toInt
cfg.getBytes("compression.size-threshold").toInt val customCodes: List[CustomStatusCode] = cfg.getConfigList("custom-codes").toList.map { c =>
val customCodes: List[CustomStatusCode] = CustomStatusCode(
cfg.getConfigList("custom-codes").toList.map { c => c.getInt("code"),
CustomStatusCode(c.getInt("code"),
c.getString("reason"), c.getString("reason"),
c.getBoolean("success")) c.getBoolean("success"))
} }

View File

@ -26,42 +26,28 @@ sealed trait ApiReturnWithHeaders {
// workaround: return date time header in string instead of datetime object // workaround: return date time header in string instead of datetime object
def getDateTimeHeader(name: String): Option[String] = header(name) def getDateTimeHeader(name: String): Option[String] = header(name)
def getIntHeader(name: String): Option[Int] = def getIntHeader(name: String): Option[Int] = castedHeader(name, java.lang.Integer.parseInt)
castedHeader(name, java.lang.Integer.parseInt)
def getLongHeader(name: String): Option[Long] = def getLongHeader(name: String): Option[Long] = castedHeader(name, java.lang.Long.parseLong)
castedHeader(name, java.lang.Long.parseLong)
def getFloatHeader(name: String): Option[Float] = def getFloatHeader(name: String): Option[Float] = castedHeader(name, java.lang.Float.parseFloat)
castedHeader(name, java.lang.Float.parseFloat)
def getDoubleHeader(name: String): Option[Double] = def getDoubleHeader(name: String): Option[Double] = castedHeader(name, java.lang.Double.parseDouble)
castedHeader(name, java.lang.Double.parseDouble)
def getBooleanHeader(name: String): Option[Boolean] = def getBooleanHeader(name: String): Option[Boolean] = castedHeader(name, java.lang.Boolean.parseBoolean)
castedHeader(name, java.lang.Boolean.parseBoolean)
private def castedHeader[U](name: String, private def castedHeader[U](name: String, conversion: String => U): Option[U] = {
conversion: String => U): Option[U] = {
Try { Try {
header(name).map(conversion) header(name).map(conversion)
}.get }.get
} }
} }
sealed case class ApiResponse[T](code: Int, sealed case class ApiResponse[T](code: Int, content: T, headers: Map[String, String] = Map.empty)
content: T,
headers: Map[String, String] = Map.empty)
extends ApiReturnWithHeaders extends ApiReturnWithHeaders
sealed case class ApiError[T](code: Int, sealed case class ApiError[T](code: Int, message: String, responseContent: Option[T], cause: Throwable = null, headers: Map[String, String] = Map.empty)
message: String, extends Throwable(s"($code) $message.${responseContent.map(s => s" Content : $s").getOrElse("")}", cause)
responseContent: Option[T],
cause: Throwable = null,
headers: Map[String, String] = Map.empty)
extends Throwable(
s"($code) $message.${responseContent.map(s => s" Content : $s").getOrElse("")}",
cause)
with ApiReturnWithHeaders with ApiReturnWithHeaders
sealed case class ApiMethod(value: String) sealed case class ApiMethod(value: String)
@ -90,13 +76,9 @@ sealed trait Credentials {
def asQueryParam: Option[(String, String)] = None def asQueryParam: Option[(String, String)] = None
} }
sealed case class BasicCredentials(user: String, password: String) sealed case class BasicCredentials(user: String, password: String) extends Credentials
extends Credentials
sealed case class ApiKeyCredentials(key: ApiKeyValue, sealed case class ApiKeyCredentials(key: ApiKeyValue, keyName: String, location: ApiKeyLocation) extends Credentials {
keyName: String,
location: ApiKeyLocation)
extends Credentials {
override def asQueryParam: Option[(String, String)] = location match { override def asQueryParam: Option[(String, String)] = location match {
case ApiKeyLocations.QUERY => Some((keyName, key.value)) case ApiKeyLocations.QUERY => Some((keyName, key.value))
case _ => None case _ => None
@ -115,6 +97,7 @@ object ApiKeyLocations {
} }
/** /**
* Case class used to unapply numeric values only in pattern matching * Case class used to unapply numeric values only in pattern matching
* *
@ -126,8 +109,7 @@ sealed case class NumericValue(value: String) {
object NumericValue { object NumericValue {
def unapply(n: Any): Option[NumericValue] = n match { def unapply(n: Any): Option[NumericValue] = n match {
case (_: Int | _: Long | _: Float | _: Double | _: Boolean | _: Byte) => case (_: Int | _: Long | _: Float | _: Double | _: Boolean | _: Byte) => Some(NumericValue(String.valueOf(n)))
Some(NumericValue(String.valueOf(n)))
case _ => None case _ => None
} }
} }
@ -135,17 +117,16 @@ object NumericValue {
/** /**
* Used for params being arrays * Used for params being arrays
*/ */
sealed case class ArrayValues(values: Seq[Any], sealed case class ArrayValues(values: Seq[Any], format: CollectionFormat = CollectionFormats.CSV)
format: CollectionFormat = CollectionFormats.CSV)
object ArrayValues { object ArrayValues {
def apply(values: Option[Seq[Any]], format: CollectionFormat): ArrayValues = def apply(values: Option[Seq[Any]], format: CollectionFormat): ArrayValues =
ArrayValues(values.getOrElse(Seq.empty), format) ArrayValues(values.getOrElse(Seq.empty), format)
def apply(values: Option[Seq[Any]]): ArrayValues = def apply(values: Option[Seq[Any]]): ArrayValues = ArrayValues(values, CollectionFormats.CSV)
ArrayValues(values, CollectionFormats.CSV)
} }
/** /**
* Defines how arrays should be rendered in query strings. * Defines how arrays should be rendered in query strings.
*/ */
@ -185,25 +166,19 @@ object ParametersMap {
*/ */
implicit class ParametersMapImprovements(val m: Map[String, Any]) { implicit class ParametersMapImprovements(val m: Map[String, Any]) {
def asFormattedParamsList: List[(String, Any)] = def asFormattedParamsList: List[(String, Any)] = m.toList.flatMap(formattedParams)
m.toList.flatMap(formattedParams)
def asFormattedParams: Map[String, Any] = m.flatMap(formattedParams) def asFormattedParams: Map[String, Any] = m.flatMap(formattedParams)
private def urlEncode(v: Any) = private def urlEncode(v: Any) = URLEncoder.encode(String.valueOf(v), "utf-8").replaceAll("\\+", "%20")
URLEncoder.encode(String.valueOf(v), "utf-8").replaceAll("\\+", "%20")
private def formattedParams(tuple: (String, Any)): Seq[(String, Any)] = private def formattedParams(tuple: (String, Any)): Seq[(String, Any)] = formattedParams(tuple._1, tuple._2)
formattedParams(tuple._1, tuple._2)
private def formattedParams(name: String, value: Any): Seq[(String, Any)] = private def formattedParams(name: String, value: Any): Seq[(String, Any)] = value match {
value match {
case arr: ArrayValues => case arr: ArrayValues =>
arr.format match { arr.format match {
case CollectionFormats.MULTI => case CollectionFormats.MULTI => arr.values.flatMap(formattedParams(name, _))
arr.values.flatMap(formattedParams(name, _)) case format: MergedArrayFormat => Seq((name, arr.values.mkString(format.separator)))
case format: MergedArrayFormat =>
Seq((name, arr.values.mkString(format.separator)))
} }
case None => Seq.empty case None => Seq.empty
case Some(opt) => formattedParams(name, opt) case Some(opt) => formattedParams(name, opt)

View File

@ -20,3 +20,5 @@ case class ApiResponse(
`type`: Option[String] = None, `type`: Option[String] = None,
message: Option[String] = None message: Option[String] = None
) extends ApiModel ) extends ApiModel

View File

@ -19,3 +19,5 @@ case class Category(
id: Option[Long] = None, id: Option[Long] = None,
name: Option[String] = None name: Option[String] = None
) extends ApiModel ) extends ApiModel

View File

@ -19,3 +19,5 @@ case class Tag(
id: Option[Long] = None, id: Option[Long] = None,
name: Option[String] = None name: Option[String] = None
) extends ApiModel ) extends ApiModel

View File

@ -26,3 +26,5 @@ case class User(
/* User Status */ /* User Status */
userStatus: Option[Int] = None userStatus: Option[Int] = None
) extends ApiModel ) extends ApiModel