Skip to content

Commit

Permalink
fix generation of jaguar api with auth (OpenAPITools#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaumard committed Sep 21, 2018
1 parent 4dde500 commit 5c6dade
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -72,4 +72,4 @@ class SwaggerGen {
}

{{/apis}}{{/apiInfo}}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -114,4 +114,4 @@ class SwaggerGen {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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
Expand All @@ -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,

Expand All @@ -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,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
/// For valid response try integer IDs with value &lt; 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
Expand All @@ -36,7 +36,7 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ 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
///
///
@GetReq(path: "/user/:username")
Future<User> getUserByName(
String username
@PathParam("username") String username
);

/// Logs user into the system
Expand All @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
32 changes: 16 additions & 16 deletions samples/client/petstore/dart-jaguar/openapi/lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -114,4 +114,4 @@ class SwaggerGen {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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
Expand All @@ -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,

Expand All @@ -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,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
/// For valid response try integer IDs with value &lt; 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
Expand All @@ -36,7 +36,7 @@ class StoreApi extends _$StoreApiClient implements ApiClient {
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ 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
///
///
@GetReq(path: "/user/:username")
Future<User> getUserByName(
String username
@PathParam("username") String username
);

/// Logs user into the system
Expand All @@ -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
);
Expand Down
Loading

0 comments on commit 5c6dade

Please sign in to comment.