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;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
|
import org.openapitools.codegen.CliOption;
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
import org.openapitools.codegen.CodegenModel;
|
import org.openapitools.codegen.CodegenModel;
|
||||||
import org.openapitools.codegen.CodegenOperation;
|
import org.openapitools.codegen.CodegenOperation;
|
||||||
@ -36,6 +37,7 @@ import java.util.Set;
|
|||||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||||
|
|
||||||
public class DartJaguarClientCodegen extends DartClientCodegen {
|
public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||||
|
private static final String NULLABLE_FIELDS = "nullableFields";
|
||||||
private static Set<String> modelToIgnore = new HashSet<>();
|
private static Set<String> modelToIgnore = new HashSet<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -45,11 +47,15 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
modelToIgnore.add("file");
|
modelToIgnore.add("file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean nullableFields = true;
|
||||||
|
|
||||||
public DartJaguarClientCodegen() {
|
public DartJaguarClientCodegen() {
|
||||||
super();
|
super();
|
||||||
browserClient = false;
|
browserClient = false;
|
||||||
outputFolder = "generated-code/dart-jaguar";
|
outputFolder = "generated-code/dart-jaguar";
|
||||||
embeddedTemplateDir = templateDir = "dart-jaguar";
|
embeddedTemplateDir = templateDir = "dart-jaguar";
|
||||||
|
|
||||||
|
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Is the null fields should be in the JSON payload"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,6 +80,13 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
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)) {
|
if (additionalProperties.containsKey(PUB_NAME)) {
|
||||||
this.setPubName((String) additionalProperties.get(PUB_NAME));
|
this.setPubName((String) additionalProperties.get(PUB_NAME));
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,8 +15,9 @@ part '{{classFilename}}.jretro.dart';
|
|||||||
class {{classname}} extends _${{classname}}Client implements ApiClient {
|
class {{classname}} extends _${{classname}}Client implements ApiClient {
|
||||||
final Route base;
|
final Route base;
|
||||||
final SerializerRepo serializers;
|
final SerializerRepo serializers;
|
||||||
|
final Duration timeout;
|
||||||
|
|
||||||
{{classname}}({this.base, this.serializers});
|
{{classname}}({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
/// {{summary}}
|
/// {{summary}}
|
||||||
@ -29,23 +30,46 @@ class {{classname}} extends _${{classname}}Client implements ApiClient {
|
|||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
{{#headerParams}}
|
{{#headerParams}}
|
||||||
{{#-first}}{{#hasPathParams}},{{/hasPathParams}}{{/-first}}
|
{{#-first}}{{#hasPathParams}},{{/hasPathParams}}{{/-first}}
|
||||||
@Header("{{baseName}}") {{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
|
@Header("{{baseName}}") {{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
{{#-first}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/-first}}
|
{{#-first}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/-first}}
|
||||||
@QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
|
@QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
{{#vendorExtensions}}
|
{{#vendorExtensions}}
|
||||||
|
{{#formParams}}
|
||||||
|
{{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}}
|
||||||
|
{{#isJson}}@AsJson() {{/isJson}}{{#isForm}}@AsFormField() {{/isForm}}{{#isMultipart}}@AsMultipartField() {{/isMultipart}}{{{dataType}}} {{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}}
|
||||||
|
{{^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}}
|
{{#formParams}}
|
||||||
{{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}}
|
{{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}}
|
||||||
{{#isJson}}@AsJson() {{/isJson}}{{#isForm}}@AsFormField() {{/isForm}}{{#isMultipart}}@AsMultipartField() {{/isMultipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}
|
{{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
{{#bodyParam}}
|
{{#bodyParam}}
|
||||||
{{#hasFormParams}},{{/hasFormParams}}{{^hasFormParams}}{{#hasQueryParams}},{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}
|
{{#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}}
|
{{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||||
{{/bodyParam}}
|
{{/bodyParam}}
|
||||||
{{/vendorExtensions}}
|
).timeout(timeout);
|
||||||
);
|
}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
library {{pubName}}.api;
|
library {{pubName}}.api;
|
||||||
|
|
||||||
import 'package:http/http.dart';
|
import 'package:http/io_client.dart';
|
||||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||||
import 'package:{{pubName}}/auth/api_key_auth.dart';
|
import 'package:{{pubName}}/auth/api_key_auth.dart';
|
||||||
@ -22,11 +22,12 @@ class JaguarApiGen {
|
|||||||
List<Interceptor> interceptors;
|
List<Interceptor> interceptors;
|
||||||
String basePath = "{{basePath}}";
|
String basePath = "{{basePath}}";
|
||||||
Route _baseRoute;
|
Route _baseRoute;
|
||||||
|
final Duration timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||||
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||||
if(interceptors == null) {
|
if(interceptors == null) {
|
||||||
this.interceptors = _defaultInterceptors;
|
this.interceptors = _defaultInterceptors;
|
||||||
@ -68,8 +69,8 @@ class JaguarApiGen {
|
|||||||
if(serializers == null) {
|
if(serializers == null) {
|
||||||
serializers = jsonJaguarRepo;
|
serializers = jsonJaguarRepo;
|
||||||
}
|
}
|
||||||
return {{classname}}(base: base, serializers: serializers);
|
return {{classname}}(base: base, serializers: serializers, timeout: timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/apis}}{{/apiInfo}}
|
{{/apis}}{{/apiInfo}}
|
||||||
}
|
}
|
@ -2,12 +2,12 @@ part '{{classFilename}}.jser.dart';
|
|||||||
|
|
||||||
class {{classname}} {
|
class {{classname}} {
|
||||||
{{#vars}}{{#description}} /* {{{description}}} */{{/description}}
|
{{#vars}}{{#description}} /* {{{description}}} */{{/description}}
|
||||||
@Alias('{{{baseName}}}')
|
@Alias('{{baseName}}')
|
||||||
final {{{datatype}}} {{name}};
|
final {{{datatype}}} {{name}};
|
||||||
{{#allowableValues}}{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{{/allowableValues}}{{/vars}}
|
{{#allowableValues}}{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{{/allowableValues}}{{/vars}}
|
||||||
|
|
||||||
{{classname}}(
|
{{classname}}(
|
||||||
{{#vars}}{{^defaultValue}}{{#required}} this.{{name}}, {{/required}}{{/defaultValue}}{{/vars}}
|
{{#vars}}{{^defaultValue}}{{#required}} this.{{name}}, {{/required}}{{/defaultValue}}{{/vars}}
|
||||||
|
|
||||||
{{#vendorExtensions}}{{#hasVars}}{
|
{{#vendorExtensions}}{{#hasVars}}{
|
||||||
{{#vars}}{{^required}} this.{{name}}{{#defaultValue}} = {{{defaultValue}}}{{#hasMore}}, {{/hasMore}} {{/defaultValue}}{{/required}}
|
{{#vars}}{{^required}} this.{{name}}{{#defaultValue}} = {{{defaultValue}}}{{#hasMore}}, {{/hasMore}} {{/defaultValue}}{{/required}}
|
||||||
@ -21,7 +21,7 @@ class {{classname}} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: {{nullableFields}})
|
||||||
class {{classname}}Serializer extends Serializer<{{classname}}> with _${{classname}}Serializer {
|
class {{classname}}Serializer extends Serializer<{{classname}}> with _${{classname}}Serializer {
|
||||||
|
|
||||||
}
|
}
|
@ -4,9 +4,9 @@ description: {{pubDescription}}
|
|||||||
environment:
|
environment:
|
||||||
sdk: ">=2.0.0 <3.0.0"
|
sdk: ">=2.0.0 <3.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
jaguar_retrofit: '^2.5.4'
|
jaguar_retrofit: '^2.5.12'
|
||||||
jaguar_serializer: '^2.2.2'
|
jaguar_serializer: '^2.2.4'
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
jaguar_retrofit_gen: '^2.5.2'
|
jaguar_retrofit_gen: '^2.5.10'
|
||||||
jaguar_serializer_cli: '^2.2.1'
|
jaguar_serializer_cli: '^2.2.4'
|
||||||
build_runner: '^0.10.0'
|
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:
|
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-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
|
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
library openapi.api;
|
library openapi.api;
|
||||||
|
|
||||||
import 'package:http/http.dart';
|
import 'package:http/io_client.dart';
|
||||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||||
import 'package:openapi/auth/api_key_auth.dart';
|
import 'package:openapi/auth/api_key_auth.dart';
|
||||||
@ -18,100 +18,101 @@ 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()
|
|
||||||
..add(ApiResponseSerializer())
|
|
||||||
..add(CategorySerializer())
|
|
||||||
..add(OrderSerializer())
|
|
||||||
..add(PetSerializer())
|
|
||||||
..add(TagSerializer())
|
|
||||||
..add(UserSerializer());
|
|
||||||
|
|
||||||
final _defaultInterceptors = [
|
final jsonJaguarRepo = JsonRepo()
|
||||||
OAuthInterceptor(),
|
..add(ApiResponseSerializer())
|
||||||
BasicAuthInterceptor(),
|
..add(CategorySerializer())
|
||||||
ApiKeyAuthInterceptor()
|
..add(OrderSerializer())
|
||||||
];
|
..add(PetSerializer())
|
||||||
|
..add(TagSerializer())
|
||||||
|
..add(UserSerializer())
|
||||||
|
;
|
||||||
|
|
||||||
|
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||||
|
|
||||||
class JaguarApiGen {
|
class JaguarApiGen {
|
||||||
List<Interceptor> interceptors;
|
List<Interceptor> interceptors;
|
||||||
String basePath = "http://petstore.swagger.io/v2";
|
String basePath = "http://petstore.swagger.io/v2";
|
||||||
Route _baseRoute;
|
Route _baseRoute;
|
||||||
|
final Duration timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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(
|
JaguarApiGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||||
{List<Interceptor> interceptors,
|
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||||
bool overrideInterceptors = false,
|
if(interceptors == null) {
|
||||||
String baseUrl}) {
|
this.interceptors = _defaultInterceptors;
|
||||||
_baseRoute =
|
}
|
||||||
Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
else if(overrideInterceptors){
|
||||||
if (interceptors == null) {
|
this.interceptors = interceptors;
|
||||||
this.interceptors = _defaultInterceptors;
|
}
|
||||||
} else if (overrideInterceptors) {
|
else {
|
||||||
this.interceptors = interceptors;
|
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
|
||||||
} else {
|
}
|
||||||
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
|
|
||||||
|
this.interceptors.forEach((interceptor) {
|
||||||
|
_baseRoute.before(interceptor.before);
|
||||||
|
_baseRoute.after(interceptor.after);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.interceptors.forEach((interceptor) {
|
void setOAuthToken(String name, String token) {
|
||||||
_baseRoute.before(interceptor.before);
|
(_defaultInterceptors[0] as OAuthInterceptor).tokens[name] = token;
|
||||||
_baseRoute.after(interceptor.after);
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOAuthToken(String name, String token) {
|
void setBasicAuth(String name, String username, String password) {
|
||||||
(_defaultInterceptors[0] as OAuthInterceptor).tokens[name] = token;
|
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBasicAuth(String name, String username, String password) {
|
void setApiKey(String name, String apiKey) {
|
||||||
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] =
|
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
|
||||||
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,
|
* 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
|
||||||
*/
|
*/
|
||||||
PetApi getPetApi({Route base, SerializerRepo serializers}) {
|
PetApi getPetApi({Route base, SerializerRepo serializers}) {
|
||||||
if (base == null) {
|
if(base == null) {
|
||||||
base = _baseRoute;
|
base = _baseRoute;
|
||||||
|
}
|
||||||
|
if(serializers == null) {
|
||||||
|
serializers = jsonJaguarRepo;
|
||||||
|
}
|
||||||
|
return PetApi(base: base, serializers: serializers, timeout: timeout);
|
||||||
}
|
}
|
||||||
if (serializers == null) {
|
|
||||||
serializers = jsonJaguarRepo;
|
|
||||||
}
|
|
||||||
return PetApi(base: base, serializers: serializers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
|
* 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
|
||||||
*/
|
*/
|
||||||
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
|
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
|
||||||
if (base == null) {
|
if(base == null) {
|
||||||
base = _baseRoute;
|
base = _baseRoute;
|
||||||
|
}
|
||||||
|
if(serializers == null) {
|
||||||
|
serializers = jsonJaguarRepo;
|
||||||
|
}
|
||||||
|
return StoreApi(base: base, serializers: serializers, timeout: timeout);
|
||||||
}
|
}
|
||||||
if (serializers == null) {
|
|
||||||
serializers = jsonJaguarRepo;
|
|
||||||
}
|
|
||||||
return StoreApi(base: base, serializers: serializers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
|
* 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
|
||||||
*/
|
*/
|
||||||
UserApi getUserApi({Route base, SerializerRepo serializers}) {
|
UserApi getUserApi({Route base, SerializerRepo serializers}) {
|
||||||
if (base == null) {
|
if(base == null) {
|
||||||
base = _baseRoute;
|
base = _baseRoute;
|
||||||
|
}
|
||||||
|
if(serializers == null) {
|
||||||
|
serializers = jsonJaguarRepo;
|
||||||
|
}
|
||||||
|
return UserApi(base: base, serializers: serializers, timeout: timeout);
|
||||||
}
|
}
|
||||||
if (serializers == null) {
|
|
||||||
serializers = jsonJaguarRepo;
|
|
||||||
}
|
}
|
||||||
return UserApi(base: base, serializers: serializers);
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,17 +14,24 @@ part 'pet_api.jretro.dart';
|
|||||||
class PetApi extends _$PetApiClient implements ApiClient {
|
class PetApi extends _$PetApiClient implements ApiClient {
|
||||||
final Route base;
|
final Route base;
|
||||||
final SerializerRepo serializers;
|
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
|
/// Add a new pet to the store
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PostReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@PostReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<void> addPet(
|
Future<void> addPet(
|
||||||
|
|
||||||
|
@AsJson() Pet pet
|
||||||
|
) {
|
||||||
|
return super.addPet(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() Pet pet
|
pet
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Deletes a pet
|
/// Deletes a pet
|
||||||
///
|
///
|
||||||
@ -33,8 +40,15 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
Future<void> deletePet(
|
Future<void> deletePet(
|
||||||
@PathParam("petId") int petId
|
@PathParam("petId") int petId
|
||||||
,
|
,
|
||||||
@Header("api_key") String apiKey
|
@Header("api_key") String apiKey
|
||||||
);
|
) {
|
||||||
|
return super.deletePet(
|
||||||
|
petId
|
||||||
|
,
|
||||||
|
apiKey
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Finds Pets by status
|
/// Finds Pets by status
|
||||||
///
|
///
|
||||||
@ -42,8 +56,14 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/pet/findByStatus", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@GetReq(path: "/pet/findByStatus", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<List<Pet>> findPetsByStatus(
|
Future<List<Pet>> findPetsByStatus(
|
||||||
|
|
||||||
@QueryParam("status") List<String> status
|
@QueryParam("status") List<String> status
|
||||||
);
|
) {
|
||||||
|
return super.findPetsByStatus(
|
||||||
|
|
||||||
|
status
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Finds Pets by tags
|
/// Finds Pets by tags
|
||||||
///
|
///
|
||||||
@ -51,8 +71,14 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/pet/findByTags", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@GetReq(path: "/pet/findByTags", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<List<Pet>> findPetsByTags(
|
Future<List<Pet>> findPetsByTags(
|
||||||
|
|
||||||
@QueryParam("tags") List<String> tags
|
@QueryParam("tags") List<String> tags
|
||||||
);
|
) {
|
||||||
|
return super.findPetsByTags(
|
||||||
|
|
||||||
|
tags
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Find pet by ID
|
/// Find pet by ID
|
||||||
///
|
///
|
||||||
@ -60,16 +86,27 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
@GetReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||||
Future<Pet> getPetById(
|
Future<Pet> getPetById(
|
||||||
@PathParam("petId") int petId
|
@PathParam("petId") int petId
|
||||||
);
|
) {
|
||||||
|
return super.getPetById(
|
||||||
|
petId
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Update an existing pet
|
/// Update an existing pet
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PutReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@PutReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<void> updatePet(
|
Future<void> updatePet(
|
||||||
|
|
||||||
|
@AsJson() Pet pet
|
||||||
|
) {
|
||||||
|
return super.updatePet(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() Pet pet
|
pet
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Updates a pet in the store with form data
|
/// Updates a pet in the store with form data
|
||||||
///
|
///
|
||||||
@ -77,11 +114,20 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@PostReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@PostReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<void> updatePetWithForm(
|
Future<void> updatePetWithForm(
|
||||||
@PathParam("petId") int petId
|
@PathParam("petId") int petId
|
||||||
|
,
|
||||||
|
@AsFormField() String name,
|
||||||
|
|
||||||
|
@AsFormField() String status
|
||||||
|
) {
|
||||||
|
return super.updatePetWithForm(
|
||||||
|
petId
|
||||||
|
|
||||||
,
|
,
|
||||||
@AsFormField() String name,
|
name,
|
||||||
|
|
||||||
@AsFormField() String status
|
status
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// uploads an image
|
/// uploads an image
|
||||||
///
|
///
|
||||||
@ -89,11 +135,20 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@PostReq(path: "/pet/:petId/uploadImage", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@PostReq(path: "/pet/:petId/uploadImage", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<ApiResponse> uploadFile(
|
Future<ApiResponse> uploadFile(
|
||||||
@PathParam("petId") int petId
|
@PathParam("petId") int petId
|
||||||
|
,
|
||||||
|
@AsMultipartField() String additionalMetadata,
|
||||||
|
|
||||||
|
@AsMultipartField() MultipartFile file
|
||||||
|
) {
|
||||||
|
return super.uploadFile(
|
||||||
|
petId
|
||||||
|
|
||||||
,
|
,
|
||||||
@AsMultipartField() String additionalMetadata,
|
additionalMetadata,
|
||||||
|
|
||||||
@AsMultipartField() MultipartFile file
|
file
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,9 @@ part 'store_api.jretro.dart';
|
|||||||
class StoreApi extends _$StoreApiClient implements ApiClient {
|
class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||||
final Route base;
|
final Route base;
|
||||||
final SerializerRepo serializers;
|
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
|
/// Delete purchase order by ID
|
||||||
///
|
///
|
||||||
@ -22,14 +23,23 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
|||||||
@DeleteReq(path: "/store/order/:orderId")
|
@DeleteReq(path: "/store/order/:orderId")
|
||||||
Future<void> deleteOrder(
|
Future<void> deleteOrder(
|
||||||
@PathParam("orderId") String orderId
|
@PathParam("orderId") String orderId
|
||||||
);
|
) {
|
||||||
|
return super.deleteOrder(
|
||||||
|
orderId
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns pet inventories by status
|
/// Returns pet inventories by status
|
||||||
///
|
///
|
||||||
/// Returns a map of status codes to quantities
|
/// Returns a map of status codes to quantities
|
||||||
@GetReq(path: "/store/inventory", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
@GetReq(path: "/store/inventory", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||||
Future<Map<String, int>> getInventory(
|
Future<Map<String, int>> getInventory(
|
||||||
);
|
) {
|
||||||
|
return super.getInventory(
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Find purchase order by ID
|
/// Find purchase order by ID
|
||||||
///
|
///
|
||||||
@ -37,16 +47,27 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/store/order/:orderId")
|
@GetReq(path: "/store/order/:orderId")
|
||||||
Future<Order> getOrderById(
|
Future<Order> getOrderById(
|
||||||
@PathParam("orderId") int orderId
|
@PathParam("orderId") int orderId
|
||||||
);
|
) {
|
||||||
|
return super.getOrderById(
|
||||||
|
orderId
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Place an order for a pet
|
/// Place an order for a pet
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PostReq(path: "/store/order")
|
@PostReq(path: "/store/order")
|
||||||
Future<Order> placeOrder(
|
Future<Order> placeOrder(
|
||||||
|
|
||||||
|
@AsJson() Order order
|
||||||
|
) {
|
||||||
|
return super.placeOrder(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() Order order
|
order
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,35 +13,54 @@ part 'user_api.jretro.dart';
|
|||||||
class UserApi extends _$UserApiClient implements ApiClient {
|
class UserApi extends _$UserApiClient implements ApiClient {
|
||||||
final Route base;
|
final Route base;
|
||||||
final SerializerRepo serializers;
|
final SerializerRepo serializers;
|
||||||
|
final Duration timeout;
|
||||||
|
|
||||||
UserApi({this.base, this.serializers});
|
UserApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||||
|
|
||||||
/// Create user
|
/// Create user
|
||||||
///
|
///
|
||||||
/// This can only be done by the logged in user.
|
/// This can only be done by the logged in user.
|
||||||
@PostReq(path: "/user")
|
@PostReq(path: "/user")
|
||||||
Future<void> createUser(
|
Future<void> createUser(
|
||||||
|
|
||||||
|
@AsJson() User user
|
||||||
|
) {
|
||||||
|
return super.createUser(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() User user
|
user
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates list of users with given input array
|
/// Creates list of users with given input array
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PostReq(path: "/user/createWithArray")
|
@PostReq(path: "/user/createWithArray")
|
||||||
Future<void> createUsersWithArrayInput(
|
Future<void> createUsersWithArrayInput(
|
||||||
|
|
||||||
|
@AsJson() List<User> user
|
||||||
|
) {
|
||||||
|
return super.createUsersWithArrayInput(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() List<User> user
|
user
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates list of users with given input array
|
/// Creates list of users with given input array
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PostReq(path: "/user/createWithList")
|
@PostReq(path: "/user/createWithList")
|
||||||
Future<void> createUsersWithListInput(
|
Future<void> createUsersWithListInput(
|
||||||
|
|
||||||
|
@AsJson() List<User> user
|
||||||
|
) {
|
||||||
|
return super.createUsersWithListInput(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() List<User> user
|
user
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Delete user
|
/// Delete user
|
||||||
///
|
///
|
||||||
@ -49,7 +68,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
|||||||
@DeleteReq(path: "/user/:username")
|
@DeleteReq(path: "/user/:username")
|
||||||
Future<void> deleteUser(
|
Future<void> deleteUser(
|
||||||
@PathParam("username") String username
|
@PathParam("username") String username
|
||||||
);
|
) {
|
||||||
|
return super.deleteUser(
|
||||||
|
username
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Get user by user name
|
/// Get user by user name
|
||||||
///
|
///
|
||||||
@ -57,7 +81,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/user/:username")
|
@GetReq(path: "/user/:username")
|
||||||
Future<User> getUserByName(
|
Future<User> getUserByName(
|
||||||
@PathParam("username") String username
|
@PathParam("username") String username
|
||||||
);
|
) {
|
||||||
|
return super.getUserByName(
|
||||||
|
username
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Logs user into the system
|
/// Logs user into the system
|
||||||
///
|
///
|
||||||
@ -65,17 +94,29 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/user/login")
|
@GetReq(path: "/user/login")
|
||||||
Future<String> loginUser(
|
Future<String> loginUser(
|
||||||
|
|
||||||
@QueryParam("username") String username,
|
@QueryParam("username") String username,
|
||||||
|
|
||||||
@QueryParam("password") String password
|
@QueryParam("password") String password
|
||||||
);
|
) {
|
||||||
|
return super.loginUser(
|
||||||
|
|
||||||
|
username,
|
||||||
|
|
||||||
|
password
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Logs out current logged in user session
|
/// Logs out current logged in user session
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@GetReq(path: "/user/logout")
|
@GetReq(path: "/user/logout")
|
||||||
Future<void> logoutUser(
|
Future<void> logoutUser(
|
||||||
);
|
) {
|
||||||
|
return super.logoutUser(
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Updated user
|
/// Updated user
|
||||||
///
|
///
|
||||||
@ -83,9 +124,16 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
|||||||
@PutReq(path: "/user/:username")
|
@PutReq(path: "/user/:username")
|
||||||
Future<void> updateUser(
|
Future<void> updateUser(
|
||||||
@PathParam("username") String username
|
@PathParam("username") String username
|
||||||
|
,
|
||||||
|
@AsJson() User user
|
||||||
|
) {
|
||||||
|
return super.updateUser(
|
||||||
|
username
|
||||||
|
|
||||||
,
|
,
|
||||||
@AsJson() User user
|
user
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,27 @@ 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;
|
||||||
|
|
||||||
@Alias('type')
|
@Alias('type')
|
||||||
final String type;
|
final String type;
|
||||||
|
|
||||||
@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() {
|
||||||
@ -20,6 +31,7 @@ class ApiResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class ApiResponseSerializer extends Serializer<ApiResponse>
|
class ApiResponseSerializer extends Serializer<ApiResponse> with _$ApiResponseSerializer {
|
||||||
with _$ApiResponseSerializer {}
|
|
||||||
|
}
|
||||||
|
@ -3,13 +3,23 @@ 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() {
|
||||||
@ -17,6 +27,7 @@ class Category {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class CategorySerializer extends Serializer<Category>
|
class CategorySerializer extends Serializer<Category> with _$CategorySerializer {
|
||||||
with _$CategorySerializer {}
|
|
||||||
|
}
|
||||||
|
@ -3,31 +3,39 @@ 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;
|
||||||
|
|
||||||
@Alias('petId')
|
@Alias('petId')
|
||||||
final int petId;
|
final int petId;
|
||||||
|
|
||||||
@Alias('quantity')
|
@Alias('quantity')
|
||||||
final int quantity;
|
final int quantity;
|
||||||
|
|
||||||
@Alias('shipDate')
|
@Alias('shipDate')
|
||||||
final DateTime shipDate;
|
final DateTime shipDate;
|
||||||
/* Order Status */
|
/* Order Status */
|
||||||
@Alias('status')
|
@Alias('status')
|
||||||
final String status;
|
final String status;
|
||||||
//enum statusEnum { placed, approved, delivered, };
|
//enum statusEnum { placed, approved, delivered, };
|
||||||
@Alias('complete')
|
@Alias('complete')
|
||||||
final bool complete;
|
final bool complete;
|
||||||
|
|
||||||
|
|
||||||
Order(
|
Order(
|
||||||
{this.id = null,
|
|
||||||
this.petId = null,
|
|
||||||
this.quantity = null,
|
{
|
||||||
this.shipDate = null,
|
this.id = null,
|
||||||
this.status = null,
|
this.petId = null,
|
||||||
this.complete = false});
|
this.quantity = null,
|
||||||
|
this.shipDate = null,
|
||||||
|
this.status = null,
|
||||||
|
this.complete = false
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -35,5 +43,7 @@ class Order {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class OrderSerializer extends Serializer<Order> with _$OrderSerializer {}
|
class OrderSerializer extends Serializer<Order> with _$OrderSerializer {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -5,32 +5,39 @@ 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;
|
||||||
|
|
||||||
@Alias('category')
|
@Alias('category')
|
||||||
final Category category;
|
final Category category;
|
||||||
|
|
||||||
@Alias('name')
|
@Alias('name')
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
@Alias('photoUrls')
|
@Alias('photoUrls')
|
||||||
final List<String> photoUrls;
|
final List<String> photoUrls;
|
||||||
|
|
||||||
@Alias('tags')
|
@Alias('tags')
|
||||||
final List<Tag> tags;
|
final List<Tag> tags;
|
||||||
/* pet status in the store */
|
/* pet status in the store */
|
||||||
@Alias('status')
|
@Alias('status')
|
||||||
final String status;
|
final String status;
|
||||||
//enum statusEnum { available, pending, sold, };
|
//enum statusEnum { available, pending, sold, };
|
||||||
|
|
||||||
Pet(
|
Pet(
|
||||||
{this.id = null,
|
|
||||||
this.category = null,
|
|
||||||
this.name = null,
|
{
|
||||||
this.photoUrls = const [],
|
this.id = null,
|
||||||
this.tags = const [],
|
this.category = null,
|
||||||
this.status = null});
|
|
||||||
|
this.name = null,
|
||||||
|
this.photoUrls = const [], this.tags = const [],
|
||||||
|
this.status = null
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -38,5 +45,7 @@ class Pet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class PetSerializer extends Serializer<Pet> with _$PetSerializer {}
|
class PetSerializer extends Serializer<Pet> with _$PetSerializer {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -3,13 +3,23 @@ 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() {
|
||||||
@ -17,5 +27,7 @@ class Tag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class TagSerializer extends Serializer<Tag> with _$TagSerializer {}
|
class TagSerializer extends Serializer<Tag> with _$TagSerializer {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -3,39 +3,47 @@ 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;
|
||||||
|
|
||||||
@Alias('username')
|
@Alias('username')
|
||||||
final String username;
|
final String username;
|
||||||
|
|
||||||
@Alias('firstName')
|
@Alias('firstName')
|
||||||
final String firstName;
|
final String firstName;
|
||||||
|
|
||||||
@Alias('lastName')
|
@Alias('lastName')
|
||||||
final String lastName;
|
final String lastName;
|
||||||
|
|
||||||
@Alias('email')
|
@Alias('email')
|
||||||
final String email;
|
final String email;
|
||||||
|
|
||||||
@Alias('password')
|
@Alias('password')
|
||||||
final String password;
|
final String password;
|
||||||
|
|
||||||
@Alias('phone')
|
@Alias('phone')
|
||||||
final String phone;
|
final String phone;
|
||||||
/* User Status */
|
/* User Status */
|
||||||
@Alias('userStatus')
|
@Alias('userStatus')
|
||||||
final int userStatus;
|
final int userStatus;
|
||||||
|
|
||||||
|
|
||||||
User(
|
User(
|
||||||
{this.id = null,
|
|
||||||
this.username = null,
|
|
||||||
this.firstName = null,
|
{
|
||||||
this.lastName = null,
|
this.id = null,
|
||||||
this.email = null,
|
this.username = null,
|
||||||
this.password = null,
|
this.firstName = null,
|
||||||
this.phone = null,
|
this.lastName = null,
|
||||||
this.userStatus = null});
|
this.email = null,
|
||||||
|
this.password = null,
|
||||||
|
this.phone = null,
|
||||||
|
this.userStatus = null
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -43,5 +51,7 @@ class User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class UserSerializer extends Serializer<User> with _$UserSerializer {}
|
class UserSerializer extends Serializer<User> with _$UserSerializer {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -4,9 +4,9 @@ description: OpenAPI API client
|
|||||||
environment:
|
environment:
|
||||||
sdk: ">=2.0.0 <3.0.0"
|
sdk: ">=2.0.0 <3.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
jaguar_retrofit: '^2.5.4'
|
jaguar_retrofit: '^2.5.12'
|
||||||
jaguar_serializer: '^2.2.2'
|
jaguar_serializer: '^2.2.4'
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
jaguar_retrofit_gen: '^2.5.2'
|
jaguar_retrofit_gen: '^2.5.10'
|
||||||
jaguar_serializer_cli: '^2.2.1'
|
jaguar_serializer_cli: '^2.2.4'
|
||||||
build_runner: '^0.10.0'
|
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:
|
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-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
|
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
library openapi.api;
|
library openapi.api;
|
||||||
|
|
||||||
import 'package:http/http.dart';
|
import 'package:http/io_client.dart';
|
||||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||||
import 'package:openapi/auth/api_key_auth.dart';
|
import 'package:openapi/auth/api_key_auth.dart';
|
||||||
@ -18,100 +18,101 @@ 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()
|
|
||||||
..add(ApiResponseSerializer())
|
|
||||||
..add(CategorySerializer())
|
|
||||||
..add(OrderSerializer())
|
|
||||||
..add(PetSerializer())
|
|
||||||
..add(TagSerializer())
|
|
||||||
..add(UserSerializer());
|
|
||||||
|
|
||||||
final _defaultInterceptors = [
|
final jsonJaguarRepo = JsonRepo()
|
||||||
OAuthInterceptor(),
|
..add(ApiResponseSerializer())
|
||||||
BasicAuthInterceptor(),
|
..add(CategorySerializer())
|
||||||
ApiKeyAuthInterceptor()
|
..add(OrderSerializer())
|
||||||
];
|
..add(PetSerializer())
|
||||||
|
..add(TagSerializer())
|
||||||
|
..add(UserSerializer())
|
||||||
|
;
|
||||||
|
|
||||||
|
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||||
|
|
||||||
class JaguarApiGen {
|
class JaguarApiGen {
|
||||||
List<Interceptor> interceptors;
|
List<Interceptor> interceptors;
|
||||||
String basePath = "http://petstore.swagger.io/v2";
|
String basePath = "http://petstore.swagger.io/v2";
|
||||||
Route _baseRoute;
|
Route _baseRoute;
|
||||||
|
final Duration timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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(
|
JaguarApiGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||||
{List<Interceptor> interceptors,
|
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||||
bool overrideInterceptors = false,
|
if(interceptors == null) {
|
||||||
String baseUrl}) {
|
this.interceptors = _defaultInterceptors;
|
||||||
_baseRoute =
|
}
|
||||||
Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
else if(overrideInterceptors){
|
||||||
if (interceptors == null) {
|
this.interceptors = interceptors;
|
||||||
this.interceptors = _defaultInterceptors;
|
}
|
||||||
} else if (overrideInterceptors) {
|
else {
|
||||||
this.interceptors = interceptors;
|
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
|
||||||
} else {
|
}
|
||||||
this.interceptors = List.from(_defaultInterceptors)..addAll(interceptors);
|
|
||||||
|
this.interceptors.forEach((interceptor) {
|
||||||
|
_baseRoute.before(interceptor.before);
|
||||||
|
_baseRoute.after(interceptor.after);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.interceptors.forEach((interceptor) {
|
void setOAuthToken(String name, String token) {
|
||||||
_baseRoute.before(interceptor.before);
|
(_defaultInterceptors[0] as OAuthInterceptor).tokens[name] = token;
|
||||||
_baseRoute.after(interceptor.after);
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOAuthToken(String name, String token) {
|
void setBasicAuth(String name, String username, String password) {
|
||||||
(_defaultInterceptors[0] as OAuthInterceptor).tokens[name] = token;
|
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] = BasicAuthInfo(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBasicAuth(String name, String username, String password) {
|
void setApiKey(String name, String apiKey) {
|
||||||
(_defaultInterceptors[1] as BasicAuthInterceptor).authInfo[name] =
|
(_defaultInterceptors[2] as ApiKeyAuthInterceptor).apiKeys[name] = apiKey;
|
||||||
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,
|
* 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
|
||||||
*/
|
*/
|
||||||
PetApi getPetApi({Route base, SerializerRepo serializers}) {
|
PetApi getPetApi({Route base, SerializerRepo serializers}) {
|
||||||
if (base == null) {
|
if(base == null) {
|
||||||
base = _baseRoute;
|
base = _baseRoute;
|
||||||
|
}
|
||||||
|
if(serializers == null) {
|
||||||
|
serializers = jsonJaguarRepo;
|
||||||
|
}
|
||||||
|
return PetApi(base: base, serializers: serializers, timeout: timeout);
|
||||||
}
|
}
|
||||||
if (serializers == null) {
|
|
||||||
serializers = jsonJaguarRepo;
|
|
||||||
}
|
|
||||||
return PetApi(base: base, serializers: serializers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
|
* 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
|
||||||
*/
|
*/
|
||||||
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
|
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
|
||||||
if (base == null) {
|
if(base == null) {
|
||||||
base = _baseRoute;
|
base = _baseRoute;
|
||||||
|
}
|
||||||
|
if(serializers == null) {
|
||||||
|
serializers = jsonJaguarRepo;
|
||||||
|
}
|
||||||
|
return StoreApi(base: base, serializers: serializers, timeout: timeout);
|
||||||
}
|
}
|
||||||
if (serializers == null) {
|
|
||||||
serializers = jsonJaguarRepo;
|
|
||||||
}
|
|
||||||
return StoreApi(base: base, serializers: serializers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
|
* 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
|
||||||
*/
|
*/
|
||||||
UserApi getUserApi({Route base, SerializerRepo serializers}) {
|
UserApi getUserApi({Route base, SerializerRepo serializers}) {
|
||||||
if (base == null) {
|
if(base == null) {
|
||||||
base = _baseRoute;
|
base = _baseRoute;
|
||||||
|
}
|
||||||
|
if(serializers == null) {
|
||||||
|
serializers = jsonJaguarRepo;
|
||||||
|
}
|
||||||
|
return UserApi(base: base, serializers: serializers, timeout: timeout);
|
||||||
}
|
}
|
||||||
if (serializers == null) {
|
|
||||||
serializers = jsonJaguarRepo;
|
|
||||||
}
|
}
|
||||||
return UserApi(base: base, serializers: serializers);
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,17 +14,24 @@ part 'pet_api.jretro.dart';
|
|||||||
class PetApi extends _$PetApiClient implements ApiClient {
|
class PetApi extends _$PetApiClient implements ApiClient {
|
||||||
final Route base;
|
final Route base;
|
||||||
final SerializerRepo serializers;
|
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
|
/// Add a new pet to the store
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PostReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@PostReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<void> addPet(
|
Future<void> addPet(
|
||||||
|
|
||||||
|
@AsJson() Pet pet
|
||||||
|
) {
|
||||||
|
return super.addPet(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() Pet pet
|
pet
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Deletes a pet
|
/// Deletes a pet
|
||||||
///
|
///
|
||||||
@ -33,8 +40,15 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
Future<void> deletePet(
|
Future<void> deletePet(
|
||||||
@PathParam("petId") int petId
|
@PathParam("petId") int petId
|
||||||
,
|
,
|
||||||
@Header("api_key") String apiKey
|
@Header("api_key") String apiKey
|
||||||
);
|
) {
|
||||||
|
return super.deletePet(
|
||||||
|
petId
|
||||||
|
,
|
||||||
|
apiKey
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Finds Pets by status
|
/// Finds Pets by status
|
||||||
///
|
///
|
||||||
@ -42,8 +56,14 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/pet/findByStatus", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@GetReq(path: "/pet/findByStatus", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<List<Pet>> findPetsByStatus(
|
Future<List<Pet>> findPetsByStatus(
|
||||||
|
|
||||||
@QueryParam("status") List<String> status
|
@QueryParam("status") List<String> status
|
||||||
);
|
) {
|
||||||
|
return super.findPetsByStatus(
|
||||||
|
|
||||||
|
status
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Finds Pets by tags
|
/// Finds Pets by tags
|
||||||
///
|
///
|
||||||
@ -51,8 +71,14 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/pet/findByTags", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@GetReq(path: "/pet/findByTags", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<List<Pet>> findPetsByTags(
|
Future<List<Pet>> findPetsByTags(
|
||||||
|
|
||||||
@QueryParam("tags") List<String> tags
|
@QueryParam("tags") List<String> tags
|
||||||
);
|
) {
|
||||||
|
return super.findPetsByTags(
|
||||||
|
|
||||||
|
tags
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Find pet by ID
|
/// Find pet by ID
|
||||||
///
|
///
|
||||||
@ -60,16 +86,27 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
@GetReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||||
Future<Pet> getPetById(
|
Future<Pet> getPetById(
|
||||||
@PathParam("petId") int petId
|
@PathParam("petId") int petId
|
||||||
);
|
) {
|
||||||
|
return super.getPetById(
|
||||||
|
petId
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Update an existing pet
|
/// Update an existing pet
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PutReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@PutReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<void> updatePet(
|
Future<void> updatePet(
|
||||||
|
|
||||||
|
@AsJson() Pet pet
|
||||||
|
) {
|
||||||
|
return super.updatePet(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() Pet pet
|
pet
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Updates a pet in the store with form data
|
/// Updates a pet in the store with form data
|
||||||
///
|
///
|
||||||
@ -77,11 +114,20 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@PostReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@PostReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<void> updatePetWithForm(
|
Future<void> updatePetWithForm(
|
||||||
@PathParam("petId") int petId
|
@PathParam("petId") int petId
|
||||||
|
,
|
||||||
|
@AsFormField() String name,
|
||||||
|
|
||||||
|
@AsFormField() String status
|
||||||
|
) {
|
||||||
|
return super.updatePetWithForm(
|
||||||
|
petId
|
||||||
|
|
||||||
,
|
,
|
||||||
@AsFormField() String name,
|
name,
|
||||||
|
|
||||||
@AsFormField() String status
|
status
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// uploads an image
|
/// uploads an image
|
||||||
///
|
///
|
||||||
@ -89,11 +135,20 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
|||||||
@PostReq(path: "/pet/:petId/uploadImage", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
@PostReq(path: "/pet/:petId/uploadImage", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||||
Future<ApiResponse> uploadFile(
|
Future<ApiResponse> uploadFile(
|
||||||
@PathParam("petId") int petId
|
@PathParam("petId") int petId
|
||||||
|
,
|
||||||
|
@AsMultipartField() String additionalMetadata,
|
||||||
|
|
||||||
|
@AsMultipartField() MultipartFile file
|
||||||
|
) {
|
||||||
|
return super.uploadFile(
|
||||||
|
petId
|
||||||
|
|
||||||
,
|
,
|
||||||
@AsMultipartField() String additionalMetadata,
|
additionalMetadata,
|
||||||
|
|
||||||
@AsMultipartField() MultipartFile file
|
file
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,9 @@ part 'store_api.jretro.dart';
|
|||||||
class StoreApi extends _$StoreApiClient implements ApiClient {
|
class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||||
final Route base;
|
final Route base;
|
||||||
final SerializerRepo serializers;
|
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
|
/// Delete purchase order by ID
|
||||||
///
|
///
|
||||||
@ -22,14 +23,23 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
|||||||
@DeleteReq(path: "/store/order/:orderId")
|
@DeleteReq(path: "/store/order/:orderId")
|
||||||
Future<void> deleteOrder(
|
Future<void> deleteOrder(
|
||||||
@PathParam("orderId") String orderId
|
@PathParam("orderId") String orderId
|
||||||
);
|
) {
|
||||||
|
return super.deleteOrder(
|
||||||
|
orderId
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns pet inventories by status
|
/// Returns pet inventories by status
|
||||||
///
|
///
|
||||||
/// Returns a map of status codes to quantities
|
/// Returns a map of status codes to quantities
|
||||||
@GetReq(path: "/store/inventory", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
@GetReq(path: "/store/inventory", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||||
Future<Map<String, int>> getInventory(
|
Future<Map<String, int>> getInventory(
|
||||||
);
|
) {
|
||||||
|
return super.getInventory(
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Find purchase order by ID
|
/// Find purchase order by ID
|
||||||
///
|
///
|
||||||
@ -37,16 +47,27 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/store/order/:orderId")
|
@GetReq(path: "/store/order/:orderId")
|
||||||
Future<Order> getOrderById(
|
Future<Order> getOrderById(
|
||||||
@PathParam("orderId") int orderId
|
@PathParam("orderId") int orderId
|
||||||
);
|
) {
|
||||||
|
return super.getOrderById(
|
||||||
|
orderId
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Place an order for a pet
|
/// Place an order for a pet
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PostReq(path: "/store/order")
|
@PostReq(path: "/store/order")
|
||||||
Future<Order> placeOrder(
|
Future<Order> placeOrder(
|
||||||
|
|
||||||
|
@AsJson() Order order
|
||||||
|
) {
|
||||||
|
return super.placeOrder(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() Order order
|
order
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,35 +13,54 @@ part 'user_api.jretro.dart';
|
|||||||
class UserApi extends _$UserApiClient implements ApiClient {
|
class UserApi extends _$UserApiClient implements ApiClient {
|
||||||
final Route base;
|
final Route base;
|
||||||
final SerializerRepo serializers;
|
final SerializerRepo serializers;
|
||||||
|
final Duration timeout;
|
||||||
|
|
||||||
UserApi({this.base, this.serializers});
|
UserApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||||
|
|
||||||
/// Create user
|
/// Create user
|
||||||
///
|
///
|
||||||
/// This can only be done by the logged in user.
|
/// This can only be done by the logged in user.
|
||||||
@PostReq(path: "/user")
|
@PostReq(path: "/user")
|
||||||
Future<void> createUser(
|
Future<void> createUser(
|
||||||
|
|
||||||
|
@AsJson() User user
|
||||||
|
) {
|
||||||
|
return super.createUser(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() User user
|
user
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates list of users with given input array
|
/// Creates list of users with given input array
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PostReq(path: "/user/createWithArray")
|
@PostReq(path: "/user/createWithArray")
|
||||||
Future<void> createUsersWithArrayInput(
|
Future<void> createUsersWithArrayInput(
|
||||||
|
|
||||||
|
@AsJson() List<User> user
|
||||||
|
) {
|
||||||
|
return super.createUsersWithArrayInput(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() List<User> user
|
user
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates list of users with given input array
|
/// Creates list of users with given input array
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@PostReq(path: "/user/createWithList")
|
@PostReq(path: "/user/createWithList")
|
||||||
Future<void> createUsersWithListInput(
|
Future<void> createUsersWithListInput(
|
||||||
|
|
||||||
|
@AsJson() List<User> user
|
||||||
|
) {
|
||||||
|
return super.createUsersWithListInput(
|
||||||
|
|
||||||
|
|
||||||
@AsJson() List<User> user
|
user
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Delete user
|
/// Delete user
|
||||||
///
|
///
|
||||||
@ -49,7 +68,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
|||||||
@DeleteReq(path: "/user/:username")
|
@DeleteReq(path: "/user/:username")
|
||||||
Future<void> deleteUser(
|
Future<void> deleteUser(
|
||||||
@PathParam("username") String username
|
@PathParam("username") String username
|
||||||
);
|
) {
|
||||||
|
return super.deleteUser(
|
||||||
|
username
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Get user by user name
|
/// Get user by user name
|
||||||
///
|
///
|
||||||
@ -57,7 +81,12 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/user/:username")
|
@GetReq(path: "/user/:username")
|
||||||
Future<User> getUserByName(
|
Future<User> getUserByName(
|
||||||
@PathParam("username") String username
|
@PathParam("username") String username
|
||||||
);
|
) {
|
||||||
|
return super.getUserByName(
|
||||||
|
username
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Logs user into the system
|
/// Logs user into the system
|
||||||
///
|
///
|
||||||
@ -65,17 +94,29 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
|||||||
@GetReq(path: "/user/login")
|
@GetReq(path: "/user/login")
|
||||||
Future<String> loginUser(
|
Future<String> loginUser(
|
||||||
|
|
||||||
@QueryParam("username") String username,
|
@QueryParam("username") String username,
|
||||||
|
|
||||||
@QueryParam("password") String password
|
@QueryParam("password") String password
|
||||||
);
|
) {
|
||||||
|
return super.loginUser(
|
||||||
|
|
||||||
|
username,
|
||||||
|
|
||||||
|
password
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Logs out current logged in user session
|
/// Logs out current logged in user session
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@GetReq(path: "/user/logout")
|
@GetReq(path: "/user/logout")
|
||||||
Future<void> logoutUser(
|
Future<void> logoutUser(
|
||||||
);
|
) {
|
||||||
|
return super.logoutUser(
|
||||||
|
|
||||||
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
/// Updated user
|
/// Updated user
|
||||||
///
|
///
|
||||||
@ -83,9 +124,16 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
|||||||
@PutReq(path: "/user/:username")
|
@PutReq(path: "/user/:username")
|
||||||
Future<void> updateUser(
|
Future<void> updateUser(
|
||||||
@PathParam("username") String username
|
@PathParam("username") String username
|
||||||
|
,
|
||||||
|
@AsJson() User user
|
||||||
|
) {
|
||||||
|
return super.updateUser(
|
||||||
|
username
|
||||||
|
|
||||||
,
|
,
|
||||||
@AsJson() User user
|
user
|
||||||
);
|
).timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,27 @@ 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;
|
||||||
|
|
||||||
@Alias('type')
|
@Alias('type')
|
||||||
final String type;
|
final String type;
|
||||||
|
|
||||||
@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() {
|
||||||
@ -20,6 +31,7 @@ class ApiResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class ApiResponseSerializer extends Serializer<ApiResponse>
|
class ApiResponseSerializer extends Serializer<ApiResponse> with _$ApiResponseSerializer {
|
||||||
with _$ApiResponseSerializer {}
|
|
||||||
|
}
|
||||||
|
@ -3,13 +3,23 @@ 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() {
|
||||||
@ -17,6 +27,7 @@ class Category {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class CategorySerializer extends Serializer<Category>
|
class CategorySerializer extends Serializer<Category> with _$CategorySerializer {
|
||||||
with _$CategorySerializer {}
|
|
||||||
|
}
|
||||||
|
@ -3,31 +3,39 @@ 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;
|
||||||
|
|
||||||
@Alias('petId')
|
@Alias('petId')
|
||||||
final int petId;
|
final int petId;
|
||||||
|
|
||||||
@Alias('quantity')
|
@Alias('quantity')
|
||||||
final int quantity;
|
final int quantity;
|
||||||
|
|
||||||
@Alias('shipDate')
|
@Alias('shipDate')
|
||||||
final DateTime shipDate;
|
final DateTime shipDate;
|
||||||
/* Order Status */
|
/* Order Status */
|
||||||
@Alias('status')
|
@Alias('status')
|
||||||
final String status;
|
final String status;
|
||||||
//enum statusEnum { placed, approved, delivered, };
|
//enum statusEnum { placed, approved, delivered, };
|
||||||
@Alias('complete')
|
@Alias('complete')
|
||||||
final bool complete;
|
final bool complete;
|
||||||
|
|
||||||
|
|
||||||
Order(
|
Order(
|
||||||
{this.id = null,
|
|
||||||
this.petId = null,
|
|
||||||
this.quantity = null,
|
{
|
||||||
this.shipDate = null,
|
this.id = null,
|
||||||
this.status = null,
|
this.petId = null,
|
||||||
this.complete = false});
|
this.quantity = null,
|
||||||
|
this.shipDate = null,
|
||||||
|
this.status = null,
|
||||||
|
this.complete = false
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -35,5 +43,7 @@ class Order {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class OrderSerializer extends Serializer<Order> with _$OrderSerializer {}
|
class OrderSerializer extends Serializer<Order> with _$OrderSerializer {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -5,32 +5,39 @@ 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;
|
||||||
|
|
||||||
@Alias('category')
|
@Alias('category')
|
||||||
final Category category;
|
final Category category;
|
||||||
|
|
||||||
@Alias('name')
|
@Alias('name')
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
@Alias('photoUrls')
|
@Alias('photoUrls')
|
||||||
final List<String> photoUrls;
|
final List<String> photoUrls;
|
||||||
|
|
||||||
@Alias('tags')
|
@Alias('tags')
|
||||||
final List<Tag> tags;
|
final List<Tag> tags;
|
||||||
/* pet status in the store */
|
/* pet status in the store */
|
||||||
@Alias('status')
|
@Alias('status')
|
||||||
final String status;
|
final String status;
|
||||||
//enum statusEnum { available, pending, sold, };
|
//enum statusEnum { available, pending, sold, };
|
||||||
|
|
||||||
Pet(
|
Pet(
|
||||||
{this.id = null,
|
|
||||||
this.category = null,
|
|
||||||
this.name = null,
|
{
|
||||||
this.photoUrls = const [],
|
this.id = null,
|
||||||
this.tags = const [],
|
this.category = null,
|
||||||
this.status = null});
|
|
||||||
|
this.name = null,
|
||||||
|
this.photoUrls = const [], this.tags = const [],
|
||||||
|
this.status = null
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -38,5 +45,7 @@ class Pet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class PetSerializer extends Serializer<Pet> with _$PetSerializer {}
|
class PetSerializer extends Serializer<Pet> with _$PetSerializer {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -3,13 +3,23 @@ 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() {
|
||||||
@ -17,5 +27,7 @@ class Tag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class TagSerializer extends Serializer<Tag> with _$TagSerializer {}
|
class TagSerializer extends Serializer<Tag> with _$TagSerializer {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -3,39 +3,47 @@ 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;
|
||||||
|
|
||||||
@Alias('username')
|
@Alias('username')
|
||||||
final String username;
|
final String username;
|
||||||
|
|
||||||
@Alias('firstName')
|
@Alias('firstName')
|
||||||
final String firstName;
|
final String firstName;
|
||||||
|
|
||||||
@Alias('lastName')
|
@Alias('lastName')
|
||||||
final String lastName;
|
final String lastName;
|
||||||
|
|
||||||
@Alias('email')
|
@Alias('email')
|
||||||
final String email;
|
final String email;
|
||||||
|
|
||||||
@Alias('password')
|
@Alias('password')
|
||||||
final String password;
|
final String password;
|
||||||
|
|
||||||
@Alias('phone')
|
@Alias('phone')
|
||||||
final String phone;
|
final String phone;
|
||||||
/* User Status */
|
/* User Status */
|
||||||
@Alias('userStatus')
|
@Alias('userStatus')
|
||||||
final int userStatus;
|
final int userStatus;
|
||||||
|
|
||||||
|
|
||||||
User(
|
User(
|
||||||
{this.id = null,
|
|
||||||
this.username = null,
|
|
||||||
this.firstName = null,
|
{
|
||||||
this.lastName = null,
|
this.id = null,
|
||||||
this.email = null,
|
this.username = null,
|
||||||
this.password = null,
|
this.firstName = null,
|
||||||
this.phone = null,
|
this.lastName = null,
|
||||||
this.userStatus = null});
|
this.email = null,
|
||||||
|
this.password = null,
|
||||||
|
this.phone = null,
|
||||||
|
this.userStatus = null
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -43,5 +51,7 @@ class User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenSerializer()
|
@GenSerializer(nullableFields: true)
|
||||||
class UserSerializer extends Serializer<User> with _$UserSerializer {}
|
class UserSerializer extends Serializer<User> with _$UserSerializer {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -4,9 +4,9 @@ description: OpenAPI API client
|
|||||||
environment:
|
environment:
|
||||||
sdk: ">=2.0.0 <3.0.0"
|
sdk: ">=2.0.0 <3.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
jaguar_retrofit: '^2.5.4'
|
jaguar_retrofit: '^2.5.12'
|
||||||
jaguar_serializer: '^2.2.2'
|
jaguar_serializer: '^2.2.4'
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
jaguar_retrofit_gen: '^2.5.2'
|
jaguar_retrofit_gen: '^2.5.10'
|
||||||
jaguar_serializer_cli: '^2.2.1'
|
jaguar_serializer_cli: '^2.2.4'
|
||||||
build_runner: '^0.10.0'
|
build_runner: '^1.1.1'
|
Loading…
x
Reference in New Issue
Block a user