forked from loafle/openapi-generator-original
[Dart][Jaguar] and proto serialization support (#1793)
* add proto format support for jaguar generator * Add openApiType to CodegenProperties Finish proto generation
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
import 'package:jaguar_retrofit/annotations/annotations.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:jaguar_serializer/src/repo/repo.dart';
|
||||
import 'package:jaguar_mimetype/jaguar_mimetype.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:openapi/model/pet.dart';
|
||||
import 'package:openapi/model/api_response.dart';
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
part 'pet_api.jretro.dart';
|
||||
|
||||
@GenApiClient()
|
||||
class PetApi extends _$PetApiClient implements ApiClient {
|
||||
class PetApi extends ApiClient with _$PetApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Map<String, CodecRepo> converters;
|
||||
final Duration timeout;
|
||||
|
||||
PetApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
PetApi({this.base, this.converters, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
/// Add a new pet to the store
|
||||
///
|
||||
@@ -24,7 +24,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@PostReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||
Future<void> addPet(
|
||||
|
||||
@AsJson() Pet body
|
||||
@AsJson() Pet body
|
||||
) {
|
||||
return super.addPet(
|
||||
|
||||
@@ -99,7 +99,7 @@ class PetApi extends _$PetApiClient implements ApiClient {
|
||||
@PutReq(path: "/pet", metadata: {"auth": [ {"type": "oauth2", "name": "petstore_auth" }]})
|
||||
Future<void> updatePet(
|
||||
|
||||
@AsJson() Pet body
|
||||
@AsJson() Pet body
|
||||
) {
|
||||
return super.updatePet(
|
||||
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
import 'package:jaguar_retrofit/annotations/annotations.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:jaguar_serializer/src/repo/repo.dart';
|
||||
import 'package:jaguar_mimetype/jaguar_mimetype.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:openapi/model/order.dart';
|
||||
|
||||
|
||||
part 'store_api.jretro.dart';
|
||||
|
||||
@GenApiClient()
|
||||
class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
class StoreApi extends ApiClient with _$StoreApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Map<String, CodecRepo> converters;
|
||||
final Duration timeout;
|
||||
|
||||
StoreApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
StoreApi({this.base, this.converters, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
/// Delete purchase order by ID
|
||||
///
|
||||
@@ -60,7 +59,7 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
|
||||
@PostReq(path: "/store/order")
|
||||
Future<Order> placeOrder(
|
||||
|
||||
@AsJson() Order body
|
||||
@AsJson() Order body
|
||||
) {
|
||||
return super.placeOrder(
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
import 'package:jaguar_retrofit/annotations/annotations.dart';
|
||||
import 'package:jaguar_retrofit/jaguar_retrofit.dart';
|
||||
import 'package:jaguar_serializer/jaguar_serializer.dart';
|
||||
import 'package:jaguar_serializer/src/repo/repo.dart';
|
||||
import 'package:jaguar_mimetype/jaguar_mimetype.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:openapi/model/user.dart';
|
||||
|
||||
|
||||
part 'user_api.jretro.dart';
|
||||
|
||||
@GenApiClient()
|
||||
class UserApi extends _$UserApiClient implements ApiClient {
|
||||
class UserApi extends ApiClient with _$UserApiClient {
|
||||
final Route base;
|
||||
final SerializerRepo serializers;
|
||||
final Map<String, CodecRepo> converters;
|
||||
final Duration timeout;
|
||||
|
||||
UserApi({this.base, this.serializers, this.timeout = const Duration(minutes: 2)});
|
||||
UserApi({this.base, this.converters, this.timeout = const Duration(minutes: 2)});
|
||||
|
||||
/// Create user
|
||||
///
|
||||
@@ -23,7 +22,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@PostReq(path: "/user")
|
||||
Future<void> createUser(
|
||||
|
||||
@AsJson() User body
|
||||
@AsJson() User body
|
||||
) {
|
||||
return super.createUser(
|
||||
|
||||
@@ -38,7 +37,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@PostReq(path: "/user/createWithArray")
|
||||
Future<void> createUsersWithArrayInput(
|
||||
|
||||
@AsJson() List<User> body
|
||||
@AsJson() List<User> body
|
||||
) {
|
||||
return super.createUsersWithArrayInput(
|
||||
|
||||
@@ -53,7 +52,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
@PostReq(path: "/user/createWithList")
|
||||
Future<void> createUsersWithListInput(
|
||||
|
||||
@AsJson() List<User> body
|
||||
@AsJson() List<User> body
|
||||
) {
|
||||
return super.createUsersWithListInput(
|
||||
|
||||
@@ -125,7 +124,7 @@ class UserApi extends _$UserApiClient implements ApiClient {
|
||||
Future<void> updateUser(
|
||||
@PathParam("username") String username
|
||||
,
|
||||
@AsJson() User body
|
||||
@AsJson() User body
|
||||
) {
|
||||
return super.updateUser(
|
||||
username
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user