forked from loafle/openapi-generator-original
fix generation of jaguar api with auth (#1009)
This commit is contained in:
@@ -28,11 +28,11 @@ fi
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
||||
# Generate client
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l dart-jaguar -o samples/client/petstore/dart-jaguar/openapi -DhideGenerationTimestamp=true"
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l dart-jaguar -o samples/client/petstore/dart-jaguar/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# Generate non-browserClient and put it to the flutter sample app
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_petstore/openapi -DhideGenerationTimestamp=true"
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_petstore/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# There is a proposal to allow importing different libraries depending on the environment:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{{{appDescription}}}
|
||||
{{/appDescription}}
|
||||
|
||||
This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
||||
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
{{#artifactVersion}}
|
||||
@@ -82,8 +82,8 @@ import 'package:{{pubName}}/api.dart';
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
|
||||
final swaggerGen = SwaggerGen();
|
||||
var api_instance = swaggerGen.get{{classname}}();
|
||||
final jaguarApiGen = JaguarApiGen();
|
||||
var api_instance = jaguarApiGen.get{{classname}}();
|
||||
{{#allParams}}
|
||||
var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}}
|
||||
{{/allParams}}
|
||||
|
||||
@@ -25,7 +25,7 @@ class {{classname}} extends _${{classname}}Client implements ApiClient {
|
||||
@{{httpMethod}}Req(path: "{{path}}"{{#hasAuthMethods}}, metadata: {"auth": [{{#authMethods}} {"type": "{{type}}", "name": "{{name}}"{{#isApiKey}}, "keyName": "{{keyParamName}}", "where": "{{#isKeyInQuery}}query{{/isKeyInQuery}}{{#isKeyInHeader}}header{{/isKeyInHeader}}"{{/isApiKey}} }{{#hasMore}}, {{/hasMore}}{{/authMethods}}]}{{/hasAuthMethods}})
|
||||
Future<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{nickname}}(
|
||||
{{#pathParams}}
|
||||
{{dataType}} {{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
@PathParam("{{baseName}}") {{dataType}} {{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/pathParams}}
|
||||
{{#headerParams}}
|
||||
{{#-first}}{{#hasPathParams}},{{/hasPathParams}}{{/-first}}
|
||||
|
||||
@@ -18,16 +18,16 @@ final jsonJaguarRepo = JsonRepo()
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class SwaggerGen {
|
||||
class JaguarApiGen {
|
||||
List<Interceptor> interceptors;
|
||||
String baseSwaggerPath = "{{basePath}}";
|
||||
String basePath = "{{basePath}}";
|
||||
Route _baseRoute;
|
||||
|
||||
/**
|
||||
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
|
||||
*/
|
||||
SwaggerGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl}) {
|
||||
_baseRoute = Route(baseUrl ?? baseSwaggerPath).withClient(globalClient ?? IOClient());
|
||||
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
|
||||
*/
|
||||
JaguarApiGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl}) {
|
||||
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||
if(interceptors == null) {
|
||||
this.interceptors = _defaultInterceptors;
|
||||
}
|
||||
@@ -58,9 +58,9 @@ class SwaggerGen {
|
||||
|
||||
{{#apiInfo}}{{#apis}}
|
||||
/**
|
||||
* Get {{classname}} instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
* Get {{classname}} instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
{{classname}} get{{classname}}({Route base, SerializerRepo serializers}) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
@@ -72,4 +72,4 @@ class SwaggerGen {
|
||||
}
|
||||
|
||||
{{/apis}}{{/apiInfo}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ description: {{pubDescription}}
|
||||
environment:
|
||||
sdk: ">=2.0.0 <3.0.0"
|
||||
dependencies:
|
||||
jaguar_retrofit: '^2.4.1'
|
||||
jaguar_serializer: '^2.2.0'
|
||||
jaguar_retrofit: '^2.5.4'
|
||||
jaguar_serializer: '^2.2.2'
|
||||
dev_dependencies:
|
||||
jaguar_retrofit_gen: '^2.4.2'
|
||||
jaguar_retrofit_gen: '^2.5.1'
|
||||
jaguar_serializer_cli: '^2.2.1'
|
||||
build_runner: '^0.10.0'
|
||||
@@ -1,6 +1,6 @@
|
||||
# flutter_petstore
|
||||
|
||||
Swagger petstore sample flutter
|
||||
OpenApi petstore sample flutter
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,11 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:swagger/api.dart';
|
||||
import 'package:swagger/model/order.dart';
|
||||
import 'package:swagger/model/pet.dart';
|
||||
import 'package:swagger/model/user.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:openapi/model/order.dart';
|
||||
import 'package:openapi/model/pet.dart';
|
||||
import 'package:openapi/model/user.dart';
|
||||
import 'package:jaguar_resty/jaguar_resty.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
void main() {
|
||||
globalClient = IOClient();
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
// This widget is the root of your application.
|
||||
@@ -49,7 +54,7 @@ class MyHomePage extends StatefulWidget {
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
SwaggerGen swaggerGen = SwaggerGen();
|
||||
JaguarApiGen jaguarApiGen = JaguarApiGen();
|
||||
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
@@ -74,12 +79,12 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
print('fetching pets by status...');
|
||||
var statuses = List<String>();
|
||||
statuses.add('available');
|
||||
swaggerGen.getPetApi().findPetsByStatus(statuses)
|
||||
jaguarApiGen.getPetApi().findPetsByStatus(statuses)
|
||||
.then((List<Pet> pets) {
|
||||
print('pets received: ');
|
||||
print(pets);
|
||||
var order = Order(petId: pets[0].id, quantity: 1);
|
||||
swaggerGen.getStoreApi().placeOrder(order)
|
||||
jaguarApiGen.getStoreApi().placeOrder(order)
|
||||
.then((Order order) => print(order));
|
||||
}).catchError((error) {
|
||||
print('error fetching pets');
|
||||
@@ -89,7 +94,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
void fetchStoreInventory() {
|
||||
print('fetching inventory...');
|
||||
swaggerGen.getStoreApi().getInventory()
|
||||
jaguarApiGen.getStoreApi().getInventory()
|
||||
.then((Map inventory) {
|
||||
print('inventory received: ');
|
||||
print(inventory);
|
||||
@@ -101,7 +106,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
void fetchUser() {
|
||||
print('fetching user1...');
|
||||
swaggerGen.getUserApi().getUserByName('user1')
|
||||
jaguarApiGen.getUserApi().getUserByName('user1')
|
||||
.then((User user) {
|
||||
print('user received: ');
|
||||
print(user);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# openapi
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
||||
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
|
||||
|
||||
- API version: 1.0.0
|
||||
- Build date: 2018-09-10T21:45:17.334+08:00[Asia/Hong_Kong]
|
||||
- Build date: 2018-09-10T20:17:32.515369+02:00[Europe/Paris]
|
||||
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
|
||||
|
||||
## Requirements
|
||||
@@ -55,8 +55,8 @@ import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final swaggerGen = SwaggerGen();
|
||||
var api_instance = swaggerGen.getPetApi();
|
||||
final jaguarApiGen = JaguarApiGen();
|
||||
var api_instance = jaguarApiGen.getPetApi();
|
||||
var pet = new Pet(); // Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
|
||||
@@ -30,15 +30,15 @@ final jsonJaguarRepo = JsonRepo()
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class SwaggerGen {
|
||||
class JaguarApiGen {
|
||||
List<Interceptor> interceptors;
|
||||
String baseSwaggerPath = "http://petstore.swagger.io/v2";
|
||||
Route _baseRoute;
|
||||
|
||||
/**
|
||||
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
|
||||
*/
|
||||
SwaggerGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl}) {
|
||||
* 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 ?? baseSwaggerPath).withClient(globalClient ?? IOClient());
|
||||
if(interceptors == null) {
|
||||
this.interceptors = _defaultInterceptors;
|
||||
@@ -70,9 +70,9 @@ class SwaggerGen {
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
* Get PetApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
PetApi getPetApi({Route base, SerializerRepo serializers}) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
@@ -85,9 +85,9 @@ class SwaggerGen {
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
@@ -100,9 +100,9 @@ class SwaggerGen {
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
UserApi getUserApi({Route base, SerializerRepo serializers}) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
@@ -114,4 +114,4 @@ class SwaggerGen {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
///
|
||||
@DeleteReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||
Future<void> deletePet(
|
||||
int petId
|
||||
@PathParam("petId") int petId
|
||||
,
|
||||
@Header("api_key") String apiKey
|
||||
);
|
||||
@@ -59,7 +59,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
/// Returns a single pet
|
||||
@GetReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||
Future<Pet> getPetById(
|
||||
int petId
|
||||
@PathParam("petId") int petId
|
||||
);
|
||||
|
||||
/// Update an existing pet
|
||||
@@ -76,7 +76,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
///
|
||||
@PostReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||
Future<void> updatePetWithForm(
|
||||
int petId
|
||||
@PathParam("petId") int petId
|
||||
,
|
||||
@AsFormField() String name,
|
||||
|
||||
@@ -88,7 +88,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
///
|
||||
@PostReq(path: "/pet/:petId/uploadImage", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||
Future<ApiResponse> uploadFile(
|
||||
int petId
|
||||
@PathParam("petId") int petId
|
||||
,
|
||||
@AsMultipartField() String additionalMetadata,
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pet_api.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarHttpGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$PetApiClient implements ApiClient {
|
||||
final String basePath = "";
|
||||
Future<void> addPet(Pet pet) async {
|
||||
var req = base.post
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet")
|
||||
.json(serializers.to(pet));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> deletePet(int petId, String apiKey) async {
|
||||
var req = base.delete
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/:petId")
|
||||
.pathParams("petId", petId)
|
||||
.header("api_key", apiKey);
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||
var req = base.get
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/findByStatus")
|
||||
.query("status", status);
|
||||
return req.list(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
||||
var req = base.get
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/findByTags")
|
||||
.query("tags", tags);
|
||||
return req.list(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<Pet> getPetById(int petId) async {
|
||||
var req = base.get
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "apiKey",
|
||||
"name": "api_key",
|
||||
"keyName": "api_key",
|
||||
"where": "header",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/:petId")
|
||||
.pathParams("petId", petId);
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<void> updatePet(Pet pet) async {
|
||||
var req = base.put
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet")
|
||||
.json(serializers.to(pet));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> updatePetWithForm(int petId, String name, String status) async {
|
||||
var req = base.post
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/:petId")
|
||||
.pathParams("petId", petId)
|
||||
.urlEncodedFormField(name, name)
|
||||
.urlEncodedFormField(status, status);
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<ApiResponse> uploadFile(
|
||||
int petId, String additionalMetadata, MultipartFile file) async {
|
||||
var req = base.post
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/:petId/uploadImage")
|
||||
.pathParams("petId", petId)
|
||||
.multipart({"additionalMetadata": additionalMetadata})
|
||||
.multipart({"file": file});
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
@DeleteReq(path: "/store/order/:orderId")
|
||||
Future<void> deleteOrder(
|
||||
String orderId
|
||||
@PathParam("orderId") String orderId
|
||||
);
|
||||
|
||||
/// Returns pet inventories by status
|
||||
@@ -36,7 +36,7 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
@GetReq(path: "/store/order/:orderId")
|
||||
Future<Order> getOrderById(
|
||||
int orderId
|
||||
@PathParam("orderId") int orderId
|
||||
);
|
||||
|
||||
/// Place an order for a pet
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'store_api.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarHttpGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$StoreApiClient implements ApiClient {
|
||||
final String basePath = "";
|
||||
Future<void> deleteOrder(String orderId) async {
|
||||
var req = base.delete
|
||||
.path(basePath)
|
||||
.path("/store/order/:orderId")
|
||||
.pathParams("orderId", orderId);
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<Map<String, int>> getInventory() async {
|
||||
var req = base.get
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "apiKey",
|
||||
"name": "api_key",
|
||||
"keyName": "api_key",
|
||||
"where": "header",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/store/inventory");
|
||||
return req.one().then((v) => serializers.mapFrom<int>(v));
|
||||
}
|
||||
|
||||
Future<Order> getOrderById(int orderId) async {
|
||||
var req = base.get
|
||||
.path(basePath)
|
||||
.path("/store/order/:orderId")
|
||||
.pathParams("orderId", orderId);
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<Order> placeOrder(Order order) async {
|
||||
var req = base.post
|
||||
.path(basePath)
|
||||
.path("/store/order")
|
||||
.json(serializers.to(order));
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
/// This can only be done by the logged in user.
|
||||
@DeleteReq(path: "/user/:username")
|
||||
Future<void> deleteUser(
|
||||
String username
|
||||
@PathParam("username") String username
|
||||
);
|
||||
|
||||
/// Get user by user name
|
||||
@@ -56,7 +56,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
///
|
||||
@GetReq(path: "/user/:username")
|
||||
Future<User> getUserByName(
|
||||
String username
|
||||
@PathParam("username") String username
|
||||
);
|
||||
|
||||
/// Logs user into the system
|
||||
@@ -82,7 +82,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
/// This can only be done by the logged in user.
|
||||
@PutReq(path: "/user/:username")
|
||||
Future<void> updateUser(
|
||||
String username
|
||||
@PathParam("username") String username
|
||||
,
|
||||
@AsJson() User user
|
||||
);
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_api.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarHttpGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$UserApiClient implements ApiClient {
|
||||
final String basePath = "";
|
||||
Future<void> createUser(User user) async {
|
||||
var req = base.post.path(basePath).path("/user").json(serializers.to(user));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> createUsersWithArrayInput(List<User> user) async {
|
||||
var req = base.post
|
||||
.path(basePath)
|
||||
.path("/user/createWithArray")
|
||||
.json(serializers.to(user));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> createUsersWithListInput(List<User> user) async {
|
||||
var req = base.post
|
||||
.path(basePath)
|
||||
.path("/user/createWithList")
|
||||
.json(serializers.to(user));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> deleteUser(String username) async {
|
||||
var req = base.delete
|
||||
.path(basePath)
|
||||
.path("/user/:username")
|
||||
.pathParams("username", username);
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<User> getUserByName(String username) async {
|
||||
var req = base.get
|
||||
.path(basePath)
|
||||
.path("/user/:username")
|
||||
.pathParams("username", username);
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<String> loginUser(String username, String password) async {
|
||||
var req = base.get
|
||||
.path(basePath)
|
||||
.path("/user/login")
|
||||
.query("username", username)
|
||||
.query("password", password);
|
||||
return req.one();
|
||||
}
|
||||
|
||||
Future<void> logoutUser() async {
|
||||
var req = base.get.path(basePath).path("/user/logout");
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> updateUser(String username, User user) async {
|
||||
var req = base.put
|
||||
.path(basePath)
|
||||
.path("/user/:username")
|
||||
.pathParams("username", username)
|
||||
.json(serializers.to(user));
|
||||
await req.go();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'api_response.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$ApiResponseSerializer implements Serializer<ApiResponse> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(ApiResponse model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'code', model.code);
|
||||
setMapValue(ret, 'type', model.type);
|
||||
setMapValue(ret, 'message', model.message);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
ApiResponse fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new ApiResponse(
|
||||
code: map['code'] as int ?? getJserDefault('code'),
|
||||
type: map['type'] as String ?? getJserDefault('type'),
|
||||
message: map['message'] as String ?? getJserDefault('message'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'category.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$CategorySerializer implements Serializer<Category> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(Category model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'name', model.name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
Category fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new Category(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
name: map['name'] as String ?? getJserDefault('name'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'order.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$OrderSerializer implements Serializer<Order> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(Order model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'petId', model.petId);
|
||||
setMapValue(ret, 'quantity', model.quantity);
|
||||
setMapValue(
|
||||
ret, 'shipDate', dateTimeUtcProcessor.serialize(model.shipDate));
|
||||
setMapValue(ret, 'status', model.status);
|
||||
setMapValue(ret, 'complete', model.complete);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
Order fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new Order(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
petId: map['petId'] as int ?? getJserDefault('petId'),
|
||||
quantity: map['quantity'] as int ?? getJserDefault('quantity'),
|
||||
shipDate: dateTimeUtcProcessor.deserialize(map['shipDate'] as String) ??
|
||||
getJserDefault('shipDate'),
|
||||
status: map['status'] as String ?? getJserDefault('status'),
|
||||
complete: map['complete'] as bool ?? getJserDefault('complete'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pet.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$PetSerializer implements Serializer<Pet> {
|
||||
Serializer<Category> __categorySerializer;
|
||||
Serializer<Category> get _categorySerializer =>
|
||||
__categorySerializer ??= new CategorySerializer();
|
||||
Serializer<Tag> __tagSerializer;
|
||||
Serializer<Tag> get _tagSerializer => __tagSerializer ??= new TagSerializer();
|
||||
@override
|
||||
Map<String, dynamic> toMap(Pet model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'category', _categorySerializer.toMap(model.category));
|
||||
setMapValue(ret, 'name', model.name);
|
||||
setMapValue(ret, 'photoUrls',
|
||||
codeIterable(model.photoUrls, (val) => val as String));
|
||||
setMapValue(ret, 'tags',
|
||||
codeIterable(model.tags, (val) => _tagSerializer.toMap(val as Tag)));
|
||||
setMapValue(ret, 'status', model.status);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
Pet fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new Pet(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
category: _categorySerializer.fromMap(map['category'] as Map) ??
|
||||
getJserDefault('category'),
|
||||
name: map['name'] as String ?? getJserDefault('name'),
|
||||
photoUrls: codeIterable<String>(
|
||||
map['photoUrls'] as Iterable, (val) => val as String) ??
|
||||
getJserDefault('photoUrls'),
|
||||
tags: codeIterable<Tag>(map['tags'] as Iterable,
|
||||
(val) => _tagSerializer.fromMap(val as Map)) ??
|
||||
getJserDefault('tags'),
|
||||
status: map['status'] as String ?? getJserDefault('status'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'tag.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$TagSerializer implements Serializer<Tag> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(Tag model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'name', model.name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
Tag fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new Tag(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
name: map['name'] as String ?? getJserDefault('name'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$UserSerializer implements Serializer<User> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(User model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'username', model.username);
|
||||
setMapValue(ret, 'firstName', model.firstName);
|
||||
setMapValue(ret, 'lastName', model.lastName);
|
||||
setMapValue(ret, 'email', model.email);
|
||||
setMapValue(ret, 'password', model.password);
|
||||
setMapValue(ret, 'phone', model.phone);
|
||||
setMapValue(ret, 'userStatus', model.userStatus);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
User fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new User(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
username: map['username'] as String ?? getJserDefault('username'),
|
||||
firstName: map['firstName'] as String ?? getJserDefault('firstName'),
|
||||
lastName: map['lastName'] as String ?? getJserDefault('lastName'),
|
||||
email: map['email'] as String ?? getJserDefault('email'),
|
||||
password: map['password'] as String ?? getJserDefault('password'),
|
||||
phone: map['phone'] as String ?? getJserDefault('phone'),
|
||||
userStatus: map['userStatus'] as int ?? getJserDefault('userStatus'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ description: OpenAPI API client
|
||||
environment:
|
||||
sdk: ">=2.0.0 <3.0.0"
|
||||
dependencies:
|
||||
jaguar_retrofit: '^2.4.1'
|
||||
jaguar_serializer: '^2.2.0'
|
||||
jaguar_retrofit: '^2.5.4'
|
||||
jaguar_serializer: '^2.2.2'
|
||||
dev_dependencies:
|
||||
jaguar_retrofit_gen: '^2.4.2'
|
||||
jaguar_retrofit_gen: '^2.5.1'
|
||||
jaguar_serializer_cli: '^2.2.1'
|
||||
build_runner: '^0.10.0'
|
||||
@@ -1,11 +1,11 @@
|
||||
name: flutter_petstore
|
||||
description: Swagger petstore sample flutter
|
||||
description: OpenApi petstore sample flutter
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
swagger:
|
||||
path: ./swagger
|
||||
openapi:
|
||||
path: ./openapi
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# openapi
|
||||
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
|
||||
This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
||||
This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project:
|
||||
|
||||
- API version: 1.0.0
|
||||
- Build date: 2018-09-10T21:45:14.233+08:00[Asia/Hong_Kong]
|
||||
- Build date: 2018-09-10T20:17:28.677286+02:00[Europe/Paris]
|
||||
- Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen
|
||||
|
||||
## Requirements
|
||||
@@ -55,8 +55,8 @@ import 'package:openapi/api.dart';
|
||||
// TODO Configure OAuth2 access token for authorization: petstore_auth
|
||||
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
|
||||
|
||||
final swaggerGen = SwaggerGen();
|
||||
var api_instance = swaggerGen.getPetApi();
|
||||
final jaguarApiGen = JaguarApiGen();
|
||||
var api_instance = jaguarApiGen.getPetApi();
|
||||
var pet = new Pet(); // Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
|
||||
@@ -30,16 +30,16 @@ final jsonJaguarRepo = JsonRepo()
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class SwaggerGen {
|
||||
class JaguarApiGen {
|
||||
List<Interceptor> interceptors;
|
||||
String baseSwaggerPath = "http://petstore.swagger.io/v2";
|
||||
String basePath = "http://petstore.swagger.io/v2";
|
||||
Route _baseRoute;
|
||||
|
||||
/**
|
||||
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
|
||||
*/
|
||||
SwaggerGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl}) {
|
||||
_baseRoute = Route(baseUrl ?? baseSwaggerPath).withClient(globalClient ?? IOClient());
|
||||
* Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added)
|
||||
*/
|
||||
JaguarApiGen({List<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl}) {
|
||||
_baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient());
|
||||
if(interceptors == null) {
|
||||
this.interceptors = _defaultInterceptors;
|
||||
}
|
||||
@@ -70,9 +70,9 @@ class SwaggerGen {
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
* Get PetApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
PetApi getPetApi({Route base, SerializerRepo serializers}) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
@@ -85,9 +85,9 @@ class SwaggerGen {
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
StoreApi getStoreApi({Route base, SerializerRepo serializers}) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
@@ -100,9 +100,9 @@ class SwaggerGen {
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
|
||||
* by doing that all interceptors will not be executed
|
||||
*/
|
||||
UserApi getUserApi({Route base, SerializerRepo serializers}) {
|
||||
if(base == null) {
|
||||
base = _baseRoute;
|
||||
@@ -114,4 +114,4 @@ class SwaggerGen {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
///
|
||||
@DeleteReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||
Future<void> deletePet(
|
||||
int petId
|
||||
@PathParam("petId") int petId
|
||||
,
|
||||
@Header("api_key") String apiKey
|
||||
);
|
||||
@@ -59,7 +59,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
/// Returns a single pet
|
||||
@GetReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "apiKey", "name": "api_key", "keyName": "api_key", "where": "header" }]})
|
||||
Future<Pet> getPetById(
|
||||
int petId
|
||||
@PathParam("petId") int petId
|
||||
);
|
||||
|
||||
/// Update an existing pet
|
||||
@@ -76,7 +76,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
///
|
||||
@PostReq(path: "/pet/:petId", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||
Future<void> updatePetWithForm(
|
||||
int petId
|
||||
@PathParam("petId") int petId
|
||||
,
|
||||
@AsFormField() String name,
|
||||
|
||||
@@ -88,7 +88,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
///
|
||||
@PostReq(path: "/pet/:petId/uploadImage", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||
Future<ApiResponse> uploadFile(
|
||||
int petId
|
||||
@PathParam("petId") int petId
|
||||
,
|
||||
@AsMultipartField() String additionalMetadata,
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pet_api.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarHttpGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$PetApiClient implements ApiClient {
|
||||
final String basePath = "";
|
||||
Future<void> addPet(Pet pet) async {
|
||||
var req = base.post
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet")
|
||||
.json(serializers.to(pet));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> deletePet(int petId, String apiKey) async {
|
||||
var req = base.delete
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/:petId")
|
||||
.pathParams("petId", petId)
|
||||
.header("api_key", apiKey);
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||
var req = base.get
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/findByStatus")
|
||||
.query("status", status);
|
||||
return req.list(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
||||
var req = base.get
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/findByTags")
|
||||
.query("tags", tags);
|
||||
return req.list(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<Pet> getPetById(int petId) async {
|
||||
var req = base.get
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "apiKey",
|
||||
"name": "api_key",
|
||||
"keyName": "api_key",
|
||||
"where": "header",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/:petId")
|
||||
.pathParams("petId", petId);
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<void> updatePet(Pet pet) async {
|
||||
var req = base.put
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet")
|
||||
.json(serializers.to(pet));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> updatePetWithForm(int petId, String name, String status) async {
|
||||
var req = base.post
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/:petId")
|
||||
.pathParams("petId", petId)
|
||||
.urlEncodedFormField(name, name)
|
||||
.urlEncodedFormField(status, status);
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<ApiResponse> uploadFile(
|
||||
int petId, String additionalMetadata, MultipartFile file) async {
|
||||
var req = base.post
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "oauth2",
|
||||
"name": "petstore_auth",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/pet/:petId/uploadImage")
|
||||
.pathParams("petId", petId)
|
||||
.multipart({"additionalMetadata": additionalMetadata})
|
||||
.multipart({"file": file});
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
@DeleteReq(path: "/store/order/:orderId")
|
||||
Future<void> deleteOrder(
|
||||
String orderId
|
||||
@PathParam("orderId") String orderId
|
||||
);
|
||||
|
||||
/// Returns pet inventories by status
|
||||
@@ -36,7 +36,7 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
@GetReq(path: "/store/order/:orderId")
|
||||
Future<Order> getOrderById(
|
||||
int orderId
|
||||
@PathParam("orderId") int orderId
|
||||
);
|
||||
|
||||
/// Place an order for a pet
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'store_api.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarHttpGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$StoreApiClient implements ApiClient {
|
||||
final String basePath = "";
|
||||
Future<void> deleteOrder(String orderId) async {
|
||||
var req = base.delete
|
||||
.path(basePath)
|
||||
.path("/store/order/:orderId")
|
||||
.pathParams("orderId", orderId);
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<Map<String, int>> getInventory() async {
|
||||
var req = base.get
|
||||
.metadata({
|
||||
"auth": [
|
||||
{
|
||||
"type": "apiKey",
|
||||
"name": "api_key",
|
||||
"keyName": "api_key",
|
||||
"where": "header",
|
||||
}
|
||||
],
|
||||
})
|
||||
.path(basePath)
|
||||
.path("/store/inventory");
|
||||
return req.one().then((v) => serializers.mapFrom<int>(v));
|
||||
}
|
||||
|
||||
Future<Order> getOrderById(int orderId) async {
|
||||
var req = base.get
|
||||
.path(basePath)
|
||||
.path("/store/order/:orderId")
|
||||
.pathParams("orderId", orderId);
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<Order> placeOrder(Order order) async {
|
||||
var req = base.post
|
||||
.path(basePath)
|
||||
.path("/store/order")
|
||||
.json(serializers.to(order));
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
/// This can only be done by the logged in user.
|
||||
@DeleteReq(path: "/user/:username")
|
||||
Future<void> deleteUser(
|
||||
String username
|
||||
@PathParam("username") String username
|
||||
);
|
||||
|
||||
/// Get user by user name
|
||||
@@ -56,7 +56,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
///
|
||||
@GetReq(path: "/user/:username")
|
||||
Future<User> getUserByName(
|
||||
String username
|
||||
@PathParam("username") String username
|
||||
);
|
||||
|
||||
/// Logs user into the system
|
||||
@@ -82,7 +82,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
/// This can only be done by the logged in user.
|
||||
@PutReq(path: "/user/:username")
|
||||
Future<void> updateUser(
|
||||
String username
|
||||
@PathParam("username") String username
|
||||
,
|
||||
@AsJson() User user
|
||||
);
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_api.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarHttpGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$UserApiClient implements ApiClient {
|
||||
final String basePath = "";
|
||||
Future<void> createUser(User user) async {
|
||||
var req = base.post.path(basePath).path("/user").json(serializers.to(user));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> createUsersWithArrayInput(List<User> user) async {
|
||||
var req = base.post
|
||||
.path(basePath)
|
||||
.path("/user/createWithArray")
|
||||
.json(serializers.to(user));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> createUsersWithListInput(List<User> user) async {
|
||||
var req = base.post
|
||||
.path(basePath)
|
||||
.path("/user/createWithList")
|
||||
.json(serializers.to(user));
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> deleteUser(String username) async {
|
||||
var req = base.delete
|
||||
.path(basePath)
|
||||
.path("/user/:username")
|
||||
.pathParams("username", username);
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<User> getUserByName(String username) async {
|
||||
var req = base.get
|
||||
.path(basePath)
|
||||
.path("/user/:username")
|
||||
.pathParams("username", username);
|
||||
return req.one(convert: serializers.oneFrom);
|
||||
}
|
||||
|
||||
Future<String> loginUser(String username, String password) async {
|
||||
var req = base.get
|
||||
.path(basePath)
|
||||
.path("/user/login")
|
||||
.query("username", username)
|
||||
.query("password", password);
|
||||
return req.one();
|
||||
}
|
||||
|
||||
Future<void> logoutUser() async {
|
||||
var req = base.get.path(basePath).path("/user/logout");
|
||||
await req.go();
|
||||
}
|
||||
|
||||
Future<void> updateUser(String username, User user) async {
|
||||
var req = base.put
|
||||
.path(basePath)
|
||||
.path("/user/:username")
|
||||
.pathParams("username", username)
|
||||
.json(serializers.to(user));
|
||||
await req.go();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'api_response.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$ApiResponseSerializer implements Serializer<ApiResponse> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(ApiResponse model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'code', model.code);
|
||||
setMapValue(ret, 'type', model.type);
|
||||
setMapValue(ret, 'message', model.message);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
ApiResponse fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new ApiResponse(
|
||||
code: map['code'] as int ?? getJserDefault('code'),
|
||||
type: map['type'] as String ?? getJserDefault('type'),
|
||||
message: map['message'] as String ?? getJserDefault('message'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'category.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$CategorySerializer implements Serializer<Category> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(Category model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'name', model.name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
Category fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new Category(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
name: map['name'] as String ?? getJserDefault('name'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'order.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$OrderSerializer implements Serializer<Order> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(Order model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'petId', model.petId);
|
||||
setMapValue(ret, 'quantity', model.quantity);
|
||||
setMapValue(
|
||||
ret, 'shipDate', dateTimeUtcProcessor.serialize(model.shipDate));
|
||||
setMapValue(ret, 'status', model.status);
|
||||
setMapValue(ret, 'complete', model.complete);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
Order fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new Order(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
petId: map['petId'] as int ?? getJserDefault('petId'),
|
||||
quantity: map['quantity'] as int ?? getJserDefault('quantity'),
|
||||
shipDate: dateTimeUtcProcessor.deserialize(map['shipDate'] as String) ??
|
||||
getJserDefault('shipDate'),
|
||||
status: map['status'] as String ?? getJserDefault('status'),
|
||||
complete: map['complete'] as bool ?? getJserDefault('complete'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pet.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$PetSerializer implements Serializer<Pet> {
|
||||
Serializer<Category> __categorySerializer;
|
||||
Serializer<Category> get _categorySerializer =>
|
||||
__categorySerializer ??= new CategorySerializer();
|
||||
Serializer<Tag> __tagSerializer;
|
||||
Serializer<Tag> get _tagSerializer => __tagSerializer ??= new TagSerializer();
|
||||
@override
|
||||
Map<String, dynamic> toMap(Pet model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'category', _categorySerializer.toMap(model.category));
|
||||
setMapValue(ret, 'name', model.name);
|
||||
setMapValue(ret, 'photoUrls',
|
||||
codeIterable(model.photoUrls, (val) => val as String));
|
||||
setMapValue(ret, 'tags',
|
||||
codeIterable(model.tags, (val) => _tagSerializer.toMap(val as Tag)));
|
||||
setMapValue(ret, 'status', model.status);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
Pet fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new Pet(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
category: _categorySerializer.fromMap(map['category'] as Map) ??
|
||||
getJserDefault('category'),
|
||||
name: map['name'] as String ?? getJserDefault('name'),
|
||||
photoUrls: codeIterable<String>(
|
||||
map['photoUrls'] as Iterable, (val) => val as String) ??
|
||||
getJserDefault('photoUrls'),
|
||||
tags: codeIterable<Tag>(map['tags'] as Iterable,
|
||||
(val) => _tagSerializer.fromMap(val as Map)) ??
|
||||
getJserDefault('tags'),
|
||||
status: map['status'] as String ?? getJserDefault('status'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'tag.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$TagSerializer implements Serializer<Tag> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(Tag model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'name', model.name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
Tag fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new Tag(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
name: map['name'] as String ?? getJserDefault('name'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JaguarSerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$UserSerializer implements Serializer<User> {
|
||||
@override
|
||||
Map<String, dynamic> toMap(User model) {
|
||||
if (model == null) return null;
|
||||
Map<String, dynamic> ret = <String, dynamic>{};
|
||||
setMapValue(ret, 'id', model.id);
|
||||
setMapValue(ret, 'username', model.username);
|
||||
setMapValue(ret, 'firstName', model.firstName);
|
||||
setMapValue(ret, 'lastName', model.lastName);
|
||||
setMapValue(ret, 'email', model.email);
|
||||
setMapValue(ret, 'password', model.password);
|
||||
setMapValue(ret, 'phone', model.phone);
|
||||
setMapValue(ret, 'userStatus', model.userStatus);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
User fromMap(Map map) {
|
||||
if (map == null) return null;
|
||||
final obj = new User(
|
||||
id: map['id'] as int ?? getJserDefault('id'),
|
||||
username: map['username'] as String ?? getJserDefault('username'),
|
||||
firstName: map['firstName'] as String ?? getJserDefault('firstName'),
|
||||
lastName: map['lastName'] as String ?? getJserDefault('lastName'),
|
||||
email: map['email'] as String ?? getJserDefault('email'),
|
||||
password: map['password'] as String ?? getJserDefault('password'),
|
||||
phone: map['phone'] as String ?? getJserDefault('phone'),
|
||||
userStatus: map['userStatus'] as int ?? getJserDefault('userStatus'));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ description: OpenAPI API client
|
||||
environment:
|
||||
sdk: ">=2.0.0 <3.0.0"
|
||||
dependencies:
|
||||
jaguar_retrofit: '^2.4.1'
|
||||
jaguar_serializer: '^2.2.0'
|
||||
jaguar_retrofit: '^2.5.4'
|
||||
jaguar_serializer: '^2.2.2'
|
||||
dev_dependencies:
|
||||
jaguar_retrofit_gen: '^2.4.2'
|
||||
jaguar_retrofit_gen: '^2.5.1'
|
||||
jaguar_serializer_cli: '^2.2.1'
|
||||
build_runner: '^0.10.0'
|
||||
Reference in New Issue
Block a user