forked from loafle/openapi-generator-original
add default timeout to calls (#1596)
add properties to send or not null values update deps
This commit is contained in:
parent
d57009d14d
commit
d40cbf9dbd
@ -16,6 +16,7 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
@ -36,6 +37,7 @@ import java.util.Set;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
private static final String NULLABLE_FIELDS = "nullableFields";
|
||||
private static Set<String> modelToIgnore = new HashSet<>();
|
||||
|
||||
static {
|
||||
@ -45,11 +47,15 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
modelToIgnore.add("file");
|
||||
}
|
||||
|
||||
private boolean nullableFields = true;
|
||||
|
||||
public DartJaguarClientCodegen() {
|
||||
super();
|
||||
browserClient = false;
|
||||
outputFolder = "generated-code/dart-jaguar";
|
||||
embeddedTemplateDir = templateDir = "dart-jaguar";
|
||||
|
||||
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Is the null fields should be in the JSON payload"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,6 +80,13 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
if (additionalProperties.containsKey(NULLABLE_FIELDS)) {
|
||||
nullableFields = convertPropertyToBooleanAndWriteBack(NULLABLE_FIELDS);
|
||||
} else {
|
||||
//not set, use to be passed to template
|
||||
additionalProperties.put(NULLABLE_FIELDS, nullableFields);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(PUB_NAME)) {
|
||||
this.setPubName((String) additionalProperties.get(PUB_NAME));
|
||||
} else {
|
||||
|
@ -15,8 +15,9 @@ part '{{classFilename}}.jretro.dart';
|
||||
class {{classname}} extends _${{classname}}Client implements ApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Duration timeout;
|
||||
|
||||
{{classname}}({this.base, this.serializers});
|
||||
{{classname}}({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
{{#operation}}
|
||||
/// {{summary}}
|
||||
@ -42,10 +43,33 @@ class {{classname}} extends _${{classname}}Client implements ApiClient {
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
{{#hasFormParams}},{{/hasFormParams}}{{^hasFormParams}}{{#hasQueryParams}},{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}
|
||||
{{#isJson}}@AsJson() {{/isJson}}{{#isForm}}@AsForm() {{/isForm}}{{#isMultipart}}@AsMultipart() {{/isMultipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
{{^isJson}}{{^isForm}}{{^isMultipart}}@AsBody(){{/isMultipart}}{{/isForm}}{{/isJson}} {{#isJson}}@AsJson() {{/isJson}}{{#isForm}}@AsForm() {{/isForm}}{{#isMultipart}}@AsMultipart() {{/isMultipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/bodyParam}}
|
||||
{{/vendorExtensions}}
|
||||
);
|
||||
) {
|
||||
return super.{{nickname}}(
|
||||
{{#pathParams}}
|
||||
{{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/pathParams}}
|
||||
{{#headerParams}}
|
||||
{{#-first}}{{#hasPathParams}},{{/hasPathParams}}{{/-first}}
|
||||
{{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/headerParams}}
|
||||
{{#queryParams}}
|
||||
{{#-first}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/-first}}
|
||||
{{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/queryParams}}
|
||||
|
||||
{{#formParams}}
|
||||
{{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}}
|
||||
{{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
{{#hasFormParams}},{{/hasFormParams}}{{^hasFormParams}}{{#hasQueryParams}},{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}
|
||||
{{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/bodyParam}}
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
library {{pubName}}.api;
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http/io_client.dart';
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
import 'package:{{pubName}}/auth/api_key_auth.dart';
|
||||
@ -22,11 +22,12 @@ class JaguarApiGen {
|
||||
List<Interceptor> interceptors;
|
||||
String basePath = "{{basePath}}";
|
||||
Route _baseRoute;
|
||||
final Duration timeout;
|
||||
|
||||
/**
|
||||
* 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({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||
if(interceptors == null) {
|
||||
this.interceptors = _defaultInterceptors;
|
||||
@ -68,7 +69,7 @@ class JaguarApiGen {
|
||||
if(serializers == null) {
|
||||
serializers = jsonJaguarRepo;
|
||||
}
|
||||
return {{classname}}(base: base, serializers: serializers);
|
||||
return {{classname}}(base: base, serializers: serializers, timeout: timeout);
|
||||
}
|
||||
|
||||
{{/apis}}{{/apiInfo}}
|
||||
|
@ -2,7 +2,7 @@ part '{{classFilename}}.jser.dart';
|
||||
|
||||
class {{classname}} {
|
||||
{{#vars}}{{#description}} /* {{{description}}} */{{/description}}
|
||||
@Alias('{{{baseName}}}')
|
||||
@Alias('{{baseName}}')
|
||||
final {{{datatype}}} {{name}};
|
||||
{{#allowableValues}}{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{{/allowableValues}}{{/vars}}
|
||||
|
||||
@ -21,7 +21,7 @@ class {{classname}} {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
@GenSerializer(nullableFields: {{nullableFields}})
|
||||
class {{classname}}Serializer extends Serializer<{{classname}}> with _${{classname}}Serializer {
|
||||
|
||||
}
|
@ -4,9 +4,9 @@ description: {{pubDescription}}
|
||||
environment:
|
||||
sdk: ">=2.0.0 <3.0.0"
|
||||
dependencies:
|
||||
jaguar_retrofit: '^2.5.4'
|
||||
jaguar_serializer: '^2.2.2'
|
||||
jaguar_retrofit: '^2.5.12'
|
||||
jaguar_serializer: '^2.2.4'
|
||||
dev_dependencies:
|
||||
jaguar_retrofit_gen: '^2.5.2'
|
||||
jaguar_serializer_cli: '^2.2.1'
|
||||
build_runner: '^0.10.0'
|
||||
jaguar_retrofit_gen: '^2.5.10'
|
||||
jaguar_serializer_cli: '^2.2.4'
|
||||
build_runner: '^1.1.1'
|
@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke
|
||||
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
|
||||
|
||||
- API version: 1.0.0
|
||||
- Build date: 2018-10-08T15:27:22.304+08:00[Asia/Hong_Kong]
|
||||
- Build date: 2018-12-02T16:16:44.701611+01:00[Europe/Paris]
|
||||
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
|
||||
|
||||
## Requirements
|
||||
|
@ -1,6 +1,6 @@
|
||||
library openapi.api;
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http/io_client.dart';
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
import 'package:openapi/auth/api_key_auth.dart';
|
||||
@ -18,39 +18,36 @@ import 'package:openapi/model/pet.dart';
|
||||
import 'package:openapi/model/tag.dart';
|
||||
import 'package:openapi/model/user.dart';
|
||||
|
||||
final jsonJaguarRepo = JsonRepo()
|
||||
..add(ApiResponseSerializer())
|
||||
..add(CategorySerializer())
|
||||
..add(OrderSerializer())
|
||||
..add(PetSerializer())
|
||||
..add(TagSerializer())
|
||||
..add(UserSerializer());
|
||||
|
||||
final _defaultInterceptors = [
|
||||
OAuthInterceptor(),
|
||||
BasicAuthInterceptor(),
|
||||
ApiKeyAuthInterceptor()
|
||||
];
|
||||
final jsonJaguarRepo = JsonRepo()
|
||||
..add(ApiResponseSerializer())
|
||||
..add(CategorySerializer())
|
||||
..add(OrderSerializer())
|
||||
..add(PetSerializer())
|
||||
..add(TagSerializer())
|
||||
..add(UserSerializer())
|
||||
;
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class JaguarApiGen {
|
||||
List<Interceptor> interceptors;
|
||||
String basePath = "http://petstore.swagger.io/v2";
|
||||
Route _baseRoute;
|
||||
final Duration timeout;
|
||||
|
||||
/**
|
||||
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
|
||||
*/
|
||||
JaguarApiGen(
|
||||
{List<Interceptor> interceptors,
|
||||
bool overrideInterceptors = false,
|
||||
String baseUrl}) {
|
||||
_baseRoute =
|
||||
Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||
if (interceptors == null) {
|
||||
JaguarApiGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||
if(interceptors == null) {
|
||||
this.interceptors = _defaultInterceptors;
|
||||
} else if (overrideInterceptors) {
|
||||
}
|
||||
else if(overrideInterceptors){
|
||||
this.interceptors = interceptors;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
|
||||
}
|
||||
|
||||
@ -65,53 +62,57 @@ class JaguarApiGen {
|
||||
}
|
||||
|
||||
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) {
|
||||
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get PetApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
PetApi getPetApi({Route base, SerializerRepo serializers}) {
|
||||
if (base == null) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
}
|
||||
if (serializers == null) {
|
||||
if(serializers == null) {
|
||||
serializers = jsonJaguarRepo;
|
||||
}
|
||||
return PetApi(base: base, serializers: serializers);
|
||||
return PetApi(base: base, serializers: serializers, timeout: timeout);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
|
||||
if (base == null) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
}
|
||||
if (serializers == null) {
|
||||
if(serializers == null) {
|
||||
serializers = jsonJaguarRepo;
|
||||
}
|
||||
return StoreApi(base: base, serializers: serializers);
|
||||
return StoreApi(base: base, serializers: serializers, timeout: timeout);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
UserApi getUserApi({Route base, SerializerRepo serializers}) {
|
||||
if (base == null) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
}
|
||||
if (serializers == null) {
|
||||
if(serializers == null) {
|
||||
serializers = jsonJaguarRepo;
|
||||
}
|
||||
return UserApi(base: base, serializers: serializers);
|
||||
return UserApi(base: base, serializers: serializers, timeout: timeout);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -14,8 +14,9 @@ part 'pet_api.jretro.dart';
|
||||
class PetApi extends _$PetApiClient implements ApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Duration timeout;
|
||||
|
||||
PetApi({this.base, this.serializers});
|
||||
PetApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
/// Add a new pet to the store
|
||||
///
|
||||
@ -24,7 +25,13 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
Future<void> addPet(
|
||||
|
||||
@AsJson() Pet pet
|
||||
);
|
||||
) {
|
||||
return super.addPet(
|
||||
|
||||
|
||||
pet
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Deletes a pet
|
||||
///
|
||||
@ -34,7 +41,14 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@PathParam("petId") int petId
|
||||
,
|
||||
@Header("api_key") String apiKey
|
||||
);
|
||||
) {
|
||||
return super.deletePet(
|
||||
petId
|
||||
,
|
||||
apiKey
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Finds Pets by status
|
||||
///
|
||||
@ -43,7 +57,13 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
Future<List<Pet>> findPetsByStatus(
|
||||
|
||||
@QueryParam("status") List<String> status
|
||||
);
|
||||
) {
|
||||
return super.findPetsByStatus(
|
||||
|
||||
status
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
///
|
||||
@ -52,7 +72,13 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
Future<List<Pet>> findPetsByTags(
|
||||
|
||||
@QueryParam("tags") List<String> tags
|
||||
);
|
||||
) {
|
||||
return super.findPetsByTags(
|
||||
|
||||
tags
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
///
|
||||
@ -60,7 +86,12 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@GetReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||
Future<Pet> getPetById(
|
||||
@PathParam("petId") int petId
|
||||
);
|
||||
) {
|
||||
return super.getPetById(
|
||||
petId
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
///
|
||||
@ -69,7 +100,13 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
Future<void> updatePet(
|
||||
|
||||
@AsJson() Pet pet
|
||||
);
|
||||
) {
|
||||
return super.updatePet(
|
||||
|
||||
|
||||
pet
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data
|
||||
///
|
||||
@ -81,7 +118,16 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@AsFormField() String name,
|
||||
|
||||
@AsFormField() String status
|
||||
);
|
||||
) {
|
||||
return super.updatePetWithForm(
|
||||
petId
|
||||
|
||||
,
|
||||
name,
|
||||
|
||||
status
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// uploads an image
|
||||
///
|
||||
@ -93,7 +139,16 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@AsMultipartField() String additionalMetadata,
|
||||
|
||||
@AsMultipartField() MultipartFile file
|
||||
);
|
||||
) {
|
||||
return super.uploadFile(
|
||||
petId
|
||||
|
||||
,
|
||||
additionalMetadata,
|
||||
|
||||
file
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ part 'store_api.jretro.dart';
|
||||
class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Duration timeout;
|
||||
|
||||
StoreApi({this.base, this.serializers});
|
||||
StoreApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
/// Delete purchase order by ID
|
||||
///
|
||||
@ -22,14 +23,23 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
@DeleteReq(path: "/store/order/:orderId")
|
||||
Future<void> deleteOrder(
|
||||
@PathParam("orderId") String orderId
|
||||
);
|
||||
) {
|
||||
return super.deleteOrder(
|
||||
orderId
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Returns pet inventories by status
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
@GetReq(path: "/store/inventory", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||
Future<Map<String, int>> getInventory(
|
||||
);
|
||||
) {
|
||||
return super.getInventory(
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
///
|
||||
@ -37,7 +47,12 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
@GetReq(path: "/store/order/:orderId")
|
||||
Future<Order> getOrderById(
|
||||
@PathParam("orderId") int orderId
|
||||
);
|
||||
) {
|
||||
return super.getOrderById(
|
||||
orderId
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
///
|
||||
@ -46,7 +61,13 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
Future<Order> placeOrder(
|
||||
|
||||
@AsJson() Order order
|
||||
);
|
||||
) {
|
||||
return super.placeOrder(
|
||||
|
||||
|
||||
order
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ part 'user_api.jretro.dart';
|
||||
class UserApi extends _$UserApiClient implements ApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Duration timeout;
|
||||
|
||||
UserApi({this.base, this.serializers});
|
||||
UserApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
/// Create user
|
||||
///
|
||||
@ -23,7 +24,13 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
Future<void> createUser(
|
||||
|
||||
@AsJson() User user
|
||||
);
|
||||
) {
|
||||
return super.createUser(
|
||||
|
||||
|
||||
user
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
@ -32,7 +39,13 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
Future<void> createUsersWithArrayInput(
|
||||
|
||||
@AsJson() List<User> user
|
||||
);
|
||||
) {
|
||||
return super.createUsersWithArrayInput(
|
||||
|
||||
|
||||
user
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
@ -41,7 +54,13 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
Future<void> createUsersWithListInput(
|
||||
|
||||
@AsJson() List<User> user
|
||||
);
|
||||
) {
|
||||
return super.createUsersWithListInput(
|
||||
|
||||
|
||||
user
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Delete user
|
||||
///
|
||||
@ -49,7 +68,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@DeleteReq(path: "/user/:username")
|
||||
Future<void> deleteUser(
|
||||
@PathParam("username") String username
|
||||
);
|
||||
) {
|
||||
return super.deleteUser(
|
||||
username
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Get user by user name
|
||||
///
|
||||
@ -57,7 +81,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@GetReq(path: "/user/:username")
|
||||
Future<User> getUserByName(
|
||||
@PathParam("username") String username
|
||||
);
|
||||
) {
|
||||
return super.getUserByName(
|
||||
username
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
///
|
||||
@ -68,14 +97,26 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@QueryParam("username") String username,
|
||||
|
||||
@QueryParam("password") String password
|
||||
);
|
||||
) {
|
||||
return super.loginUser(
|
||||
|
||||
username,
|
||||
|
||||
password
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
///
|
||||
///
|
||||
@GetReq(path: "/user/logout")
|
||||
Future<void> logoutUser(
|
||||
);
|
||||
) {
|
||||
return super.logoutUser(
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Updated user
|
||||
///
|
||||
@ -85,7 +126,14 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@PathParam("username") String username
|
||||
,
|
||||
@AsJson() User user
|
||||
);
|
||||
) {
|
||||
return super.updateUser(
|
||||
username
|
||||
|
||||
,
|
||||
user
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'api_response.jser.dart';
|
||||
|
||||
class ApiResponse {
|
||||
|
||||
@Alias('code')
|
||||
final int code;
|
||||
|
||||
@ -12,7 +13,17 @@ class ApiResponse {
|
||||
@Alias('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
|
||||
String toString() {
|
||||
@ -20,6 +31,7 @@ class ApiResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class ApiResponseSerializer extends Serializer<ApiResponse>
|
||||
with _$ApiResponseSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class ApiResponseSerializer extends Serializer<ApiResponse> with _$ApiResponseSerializer {
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,23 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'category.jser.dart';
|
||||
|
||||
class Category {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@Alias('name')
|
||||
final String name;
|
||||
|
||||
Category({this.id = null, this.name = null});
|
||||
|
||||
Category(
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.name = null
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -17,6 +27,7 @@ class Category {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class CategorySerializer extends Serializer<Category>
|
||||
with _$CategorySerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class CategorySerializer extends Serializer<Category> with _$CategorySerializer {
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'order.jser.dart';
|
||||
|
||||
class Order {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@ -21,13 +22,20 @@ class Order {
|
||||
@Alias('complete')
|
||||
final bool complete;
|
||||
|
||||
|
||||
Order(
|
||||
{this.id = null,
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.petId = null,
|
||||
this.quantity = null,
|
||||
this.shipDate = null,
|
||||
this.status = null,
|
||||
this.complete = false});
|
||||
this.complete = false
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -35,5 +43,7 @@ class Order {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class OrderSerializer extends Serializer<Order> with _$OrderSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class OrderSerializer extends Serializer<Order> with _$OrderSerializer {
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import 'package:openapi/model/category.dart';
|
||||
part 'pet.jser.dart';
|
||||
|
||||
class Pet {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@ -25,12 +26,18 @@ class Pet {
|
||||
//enum statusEnum { available, pending, sold, };
|
||||
|
||||
Pet(
|
||||
{this.id = null,
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.category = null,
|
||||
|
||||
this.name = null,
|
||||
this.photoUrls = const [],
|
||||
this.tags = const [],
|
||||
this.status = null});
|
||||
this.photoUrls = const [], this.tags = const [],
|
||||
this.status = null
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -38,5 +45,7 @@ class Pet {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class PetSerializer extends Serializer<Pet> with _$PetSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class PetSerializer extends Serializer<Pet> with _$PetSerializer {
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,23 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'tag.jser.dart';
|
||||
|
||||
class Tag {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@Alias('name')
|
||||
final String name;
|
||||
|
||||
Tag({this.id = null, this.name = null});
|
||||
|
||||
Tag(
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.name = null
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -17,5 +27,7 @@ class Tag {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class TagSerializer extends Serializer<Tag> with _$TagSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class TagSerializer extends Serializer<Tag> with _$TagSerializer {
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'user.jser.dart';
|
||||
|
||||
class User {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@ -27,15 +28,22 @@ class User {
|
||||
@Alias('userStatus')
|
||||
final int userStatus;
|
||||
|
||||
|
||||
User(
|
||||
{this.id = null,
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.username = null,
|
||||
this.firstName = null,
|
||||
this.lastName = null,
|
||||
this.email = null,
|
||||
this.password = null,
|
||||
this.phone = null,
|
||||
this.userStatus = null});
|
||||
this.userStatus = null
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -43,5 +51,7 @@ class User {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class UserSerializer extends Serializer<User> with _$UserSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class UserSerializer extends Serializer<User> with _$UserSerializer {
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ description: OpenAPI API client
|
||||
environment:
|
||||
sdk: ">=2.0.0 <3.0.0"
|
||||
dependencies:
|
||||
jaguar_retrofit: '^2.5.4'
|
||||
jaguar_serializer: '^2.2.2'
|
||||
jaguar_retrofit: '^2.5.12'
|
||||
jaguar_serializer: '^2.2.4'
|
||||
dev_dependencies:
|
||||
jaguar_retrofit_gen: '^2.5.2'
|
||||
jaguar_serializer_cli: '^2.2.1'
|
||||
build_runner: '^0.10.0'
|
||||
jaguar_retrofit_gen: '^2.5.10'
|
||||
jaguar_serializer_cli: '^2.2.4'
|
||||
build_runner: '^1.1.1'
|
@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke
|
||||
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
|
||||
|
||||
- API version: 1.0.0
|
||||
- Build date: 2018-10-08T15:27:15.700+08:00[Asia/Hong_Kong]
|
||||
- Build date: 2018-12-02T16:16:43.185605+01:00[Europe/Paris]
|
||||
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
|
||||
|
||||
## Requirements
|
||||
|
@ -1,6 +1,6 @@
|
||||
library openapi.api;
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http/io_client.dart';
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
import 'package:openapi/auth/api_key_auth.dart';
|
||||
@ -18,39 +18,36 @@ import 'package:openapi/model/pet.dart';
|
||||
import 'package:openapi/model/tag.dart';
|
||||
import 'package:openapi/model/user.dart';
|
||||
|
||||
final jsonJaguarRepo = JsonRepo()
|
||||
..add(ApiResponseSerializer())
|
||||
..add(CategorySerializer())
|
||||
..add(OrderSerializer())
|
||||
..add(PetSerializer())
|
||||
..add(TagSerializer())
|
||||
..add(UserSerializer());
|
||||
|
||||
final _defaultInterceptors = [
|
||||
OAuthInterceptor(),
|
||||
BasicAuthInterceptor(),
|
||||
ApiKeyAuthInterceptor()
|
||||
];
|
||||
final jsonJaguarRepo = JsonRepo()
|
||||
..add(ApiResponseSerializer())
|
||||
..add(CategorySerializer())
|
||||
..add(OrderSerializer())
|
||||
..add(PetSerializer())
|
||||
..add(TagSerializer())
|
||||
..add(UserSerializer())
|
||||
;
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class JaguarApiGen {
|
||||
List<Interceptor> interceptors;
|
||||
String basePath = "http://petstore.swagger.io/v2";
|
||||
Route _baseRoute;
|
||||
final Duration timeout;
|
||||
|
||||
/**
|
||||
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
|
||||
*/
|
||||
JaguarApiGen(
|
||||
{List<Interceptor> interceptors,
|
||||
bool overrideInterceptors = false,
|
||||
String baseUrl}) {
|
||||
_baseRoute =
|
||||
Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||
if (interceptors == null) {
|
||||
JaguarApiGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||
if(interceptors == null) {
|
||||
this.interceptors = _defaultInterceptors;
|
||||
} else if (overrideInterceptors) {
|
||||
}
|
||||
else if(overrideInterceptors){
|
||||
this.interceptors = interceptors;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
|
||||
}
|
||||
|
||||
@ -65,53 +62,57 @@ class JaguarApiGen {
|
||||
}
|
||||
|
||||
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) {
|
||||
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get PetApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
PetApi getPetApi({Route base, SerializerRepo serializers}) {
|
||||
if (base == null) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
}
|
||||
if (serializers == null) {
|
||||
if(serializers == null) {
|
||||
serializers = jsonJaguarRepo;
|
||||
}
|
||||
return PetApi(base: base, serializers: serializers);
|
||||
return PetApi(base: base, serializers: serializers, timeout: timeout);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
|
||||
if (base == null) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
}
|
||||
if (serializers == null) {
|
||||
if(serializers == null) {
|
||||
serializers = jsonJaguarRepo;
|
||||
}
|
||||
return StoreApi(base: base, serializers: serializers);
|
||||
return StoreApi(base: base, serializers: serializers, timeout: timeout);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
UserApi getUserApi({Route base, SerializerRepo serializers}) {
|
||||
if (base == null) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
}
|
||||
if (serializers == null) {
|
||||
if(serializers == null) {
|
||||
serializers = jsonJaguarRepo;
|
||||
}
|
||||
return UserApi(base: base, serializers: serializers);
|
||||
return UserApi(base: base, serializers: serializers, timeout: timeout);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -14,8 +14,9 @@ part 'pet_api.jretro.dart';
|
||||
class PetApi extends _$PetApiClient implements ApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Duration timeout;
|
||||
|
||||
PetApi({this.base, this.serializers});
|
||||
PetApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
/// Add a new pet to the store
|
||||
///
|
||||
@ -24,7 +25,13 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
Future<void> addPet(
|
||||
|
||||
@AsJson() Pet pet
|
||||
);
|
||||
) {
|
||||
return super.addPet(
|
||||
|
||||
|
||||
pet
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Deletes a pet
|
||||
///
|
||||
@ -34,7 +41,14 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@PathParam("petId") int petId
|
||||
,
|
||||
@Header("api_key") String apiKey
|
||||
);
|
||||
) {
|
||||
return super.deletePet(
|
||||
petId
|
||||
,
|
||||
apiKey
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Finds Pets by status
|
||||
///
|
||||
@ -43,7 +57,13 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
Future<List<Pet>> findPetsByStatus(
|
||||
|
||||
@QueryParam("status") List<String> status
|
||||
);
|
||||
) {
|
||||
return super.findPetsByStatus(
|
||||
|
||||
status
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
///
|
||||
@ -52,7 +72,13 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
Future<List<Pet>> findPetsByTags(
|
||||
|
||||
@QueryParam("tags") List<String> tags
|
||||
);
|
||||
) {
|
||||
return super.findPetsByTags(
|
||||
|
||||
tags
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
///
|
||||
@ -60,7 +86,12 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@GetReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||
Future<Pet> getPetById(
|
||||
@PathParam("petId") int petId
|
||||
);
|
||||
) {
|
||||
return super.getPetById(
|
||||
petId
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
///
|
||||
@ -69,7 +100,13 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
Future<void> updatePet(
|
||||
|
||||
@AsJson() Pet pet
|
||||
);
|
||||
) {
|
||||
return super.updatePet(
|
||||
|
||||
|
||||
pet
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data
|
||||
///
|
||||
@ -81,7 +118,16 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@AsFormField() String name,
|
||||
|
||||
@AsFormField() String status
|
||||
);
|
||||
) {
|
||||
return super.updatePetWithForm(
|
||||
petId
|
||||
|
||||
,
|
||||
name,
|
||||
|
||||
status
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// uploads an image
|
||||
///
|
||||
@ -93,7 +139,16 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@AsMultipartField() String additionalMetadata,
|
||||
|
||||
@AsMultipartField() MultipartFile file
|
||||
);
|
||||
) {
|
||||
return super.uploadFile(
|
||||
petId
|
||||
|
||||
,
|
||||
additionalMetadata,
|
||||
|
||||
file
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ part 'store_api.jretro.dart';
|
||||
class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Duration timeout;
|
||||
|
||||
StoreApi({this.base, this.serializers});
|
||||
StoreApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
/// Delete purchase order by ID
|
||||
///
|
||||
@ -22,14 +23,23 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
@DeleteReq(path: "/store/order/:orderId")
|
||||
Future<void> deleteOrder(
|
||||
@PathParam("orderId") String orderId
|
||||
);
|
||||
) {
|
||||
return super.deleteOrder(
|
||||
orderId
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Returns pet inventories by status
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
@GetReq(path: "/store/inventory", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||
Future<Map<String, int>> getInventory(
|
||||
);
|
||||
) {
|
||||
return super.getInventory(
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
///
|
||||
@ -37,7 +47,12 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
@GetReq(path: "/store/order/:orderId")
|
||||
Future<Order> getOrderById(
|
||||
@PathParam("orderId") int orderId
|
||||
);
|
||||
) {
|
||||
return super.getOrderById(
|
||||
orderId
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
///
|
||||
@ -46,7 +61,13 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
Future<Order> placeOrder(
|
||||
|
||||
@AsJson() Order order
|
||||
);
|
||||
) {
|
||||
return super.placeOrder(
|
||||
|
||||
|
||||
order
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ part 'user_api.jretro.dart';
|
||||
class UserApi extends _$UserApiClient implements ApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Duration timeout;
|
||||
|
||||
UserApi({this.base, this.serializers});
|
||||
UserApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
/// Create user
|
||||
///
|
||||
@ -23,7 +24,13 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
Future<void> createUser(
|
||||
|
||||
@AsJson() User user
|
||||
);
|
||||
) {
|
||||
return super.createUser(
|
||||
|
||||
|
||||
user
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
@ -32,7 +39,13 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
Future<void> createUsersWithArrayInput(
|
||||
|
||||
@AsJson() List<User> user
|
||||
);
|
||||
) {
|
||||
return super.createUsersWithArrayInput(
|
||||
|
||||
|
||||
user
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
@ -41,7 +54,13 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
Future<void> createUsersWithListInput(
|
||||
|
||||
@AsJson() List<User> user
|
||||
);
|
||||
) {
|
||||
return super.createUsersWithListInput(
|
||||
|
||||
|
||||
user
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Delete user
|
||||
///
|
||||
@ -49,7 +68,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@DeleteReq(path: "/user/:username")
|
||||
Future<void> deleteUser(
|
||||
@PathParam("username") String username
|
||||
);
|
||||
) {
|
||||
return super.deleteUser(
|
||||
username
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Get user by user name
|
||||
///
|
||||
@ -57,7 +81,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@GetReq(path: "/user/:username")
|
||||
Future<User> getUserByName(
|
||||
@PathParam("username") String username
|
||||
);
|
||||
) {
|
||||
return super.getUserByName(
|
||||
username
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
///
|
||||
@ -68,14 +97,26 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@QueryParam("username") String username,
|
||||
|
||||
@QueryParam("password") String password
|
||||
);
|
||||
) {
|
||||
return super.loginUser(
|
||||
|
||||
username,
|
||||
|
||||
password
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
///
|
||||
///
|
||||
@GetReq(path: "/user/logout")
|
||||
Future<void> logoutUser(
|
||||
);
|
||||
) {
|
||||
return super.logoutUser(
|
||||
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
/// Updated user
|
||||
///
|
||||
@ -85,7 +126,14 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@PathParam("username") String username
|
||||
,
|
||||
@AsJson() User user
|
||||
);
|
||||
) {
|
||||
return super.updateUser(
|
||||
username
|
||||
|
||||
,
|
||||
user
|
||||
).timeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'api_response.jser.dart';
|
||||
|
||||
class ApiResponse {
|
||||
|
||||
@Alias('code')
|
||||
final int code;
|
||||
|
||||
@ -12,7 +13,17 @@ class ApiResponse {
|
||||
@Alias('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
|
||||
String toString() {
|
||||
@ -20,6 +31,7 @@ class ApiResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class ApiResponseSerializer extends Serializer<ApiResponse>
|
||||
with _$ApiResponseSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class ApiResponseSerializer extends Serializer<ApiResponse> with _$ApiResponseSerializer {
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,23 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'category.jser.dart';
|
||||
|
||||
class Category {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@Alias('name')
|
||||
final String name;
|
||||
|
||||
Category({this.id = null, this.name = null});
|
||||
|
||||
Category(
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.name = null
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -17,6 +27,7 @@ class Category {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class CategorySerializer extends Serializer<Category>
|
||||
with _$CategorySerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class CategorySerializer extends Serializer<Category> with _$CategorySerializer {
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'order.jser.dart';
|
||||
|
||||
class Order {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@ -21,13 +22,20 @@ class Order {
|
||||
@Alias('complete')
|
||||
final bool complete;
|
||||
|
||||
|
||||
Order(
|
||||
{this.id = null,
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.petId = null,
|
||||
this.quantity = null,
|
||||
this.shipDate = null,
|
||||
this.status = null,
|
||||
this.complete = false});
|
||||
this.complete = false
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -35,5 +43,7 @@ class Order {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class OrderSerializer extends Serializer<Order> with _$OrderSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class OrderSerializer extends Serializer<Order> with _$OrderSerializer {
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import 'package:openapi/model/category.dart';
|
||||
part 'pet.jser.dart';
|
||||
|
||||
class Pet {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@ -25,12 +26,18 @@ class Pet {
|
||||
//enum statusEnum { available, pending, sold, };
|
||||
|
||||
Pet(
|
||||
{this.id = null,
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.category = null,
|
||||
|
||||
this.name = null,
|
||||
this.photoUrls = const [],
|
||||
this.tags = const [],
|
||||
this.status = null});
|
||||
this.photoUrls = const [], this.tags = const [],
|
||||
this.status = null
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -38,5 +45,7 @@ class Pet {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class PetSerializer extends Serializer<Pet> with _$PetSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class PetSerializer extends Serializer<Pet> with _$PetSerializer {
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,23 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'tag.jser.dart';
|
||||
|
||||
class Tag {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@Alias('name')
|
||||
final String name;
|
||||
|
||||
Tag({this.id = null, this.name = null});
|
||||
|
||||
Tag(
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.name = null
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -17,5 +27,7 @@ class Tag {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class TagSerializer extends Serializer<Tag> with _$TagSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class TagSerializer extends Serializer<Tag> with _$TagSerializer {
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
part 'user.jser.dart';
|
||||
|
||||
class User {
|
||||
|
||||
@Alias('id')
|
||||
final int id;
|
||||
|
||||
@ -27,15 +28,22 @@ class User {
|
||||
@Alias('userStatus')
|
||||
final int userStatus;
|
||||
|
||||
|
||||
User(
|
||||
{this.id = null,
|
||||
|
||||
|
||||
{
|
||||
this.id = null,
|
||||
this.username = null,
|
||||
this.firstName = null,
|
||||
this.lastName = null,
|
||||
this.email = null,
|
||||
this.password = null,
|
||||
this.phone = null,
|
||||
this.userStatus = null});
|
||||
this.userStatus = null
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -43,5 +51,7 @@ class User {
|
||||
}
|
||||
}
|
||||
|
||||
@GenSerializer()
|
||||
class UserSerializer extends Serializer<User> with _$UserSerializer {}
|
||||
@GenSerializer(nullableFields: true)
|
||||
class UserSerializer extends Serializer<User> with _$UserSerializer {
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ description: OpenAPI API client
|
||||
environment:
|
||||
sdk: ">=2.0.0 <3.0.0"
|
||||
dependencies:
|
||||
jaguar_retrofit: '^2.5.4'
|
||||
jaguar_serializer: '^2.2.2'
|
||||
jaguar_retrofit: '^2.5.12'
|
||||
jaguar_serializer: '^2.2.4'
|
||||
dev_dependencies:
|
||||
jaguar_retrofit_gen: '^2.5.2'
|
||||
jaguar_serializer_cli: '^2.2.1'
|
||||
build_runner: '^0.10.0'
|
||||
jaguar_retrofit_gen: '^2.5.10'
|
||||
jaguar_serializer_cli: '^2.2.4'
|
||||
build_runner: '^1.1.1'
|
Loading…
x
Reference in New Issue
Block a user