diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java index 5e60619cd9a..cc2516fee73 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java @@ -16,15 +16,12 @@ package org.openapitools.codegen.languages; -import org.apache.commons.io.FilenameUtils; import org.openapitools.codegen.*; import org.openapitools.codegen.utils.ModelUtils; import io.swagger.v3.oas.models.media.*; import org.apache.commons.lang3.StringUtils; -import org.openapitools.codegen.*; -import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ProcessUtils; import java.io.File; @@ -37,6 +34,8 @@ public class DartJaguarClientCodegen extends DartClientCodegen { private static final String SERIALIZATION_FORMAT = "serialization"; private static final String IS_FORMAT_JSON = "jsonFormat"; private static final String IS_FORMAT_PROTO = "protoFormat"; + private static final String CLIENT_NAME = "clientName"; + private static Set modelToIgnore = new HashSet<>(); private HashMap protoTypeMapping = new HashMap<>(); @@ -141,6 +140,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen { //not set, use to be passed to template additionalProperties.put(PUB_NAME, pubName); } + additionalProperties.put(CLIENT_NAME, org.openapitools.codegen.utils.StringUtils.camelize(pubName)); if (additionalProperties.containsKey(PUB_VERSION)) { this.setPubVersion((String) additionalProperties.get(PUB_VERSION)); diff --git a/modules/openapi-generator/src/main/resources/dart-jaguar/README.mustache b/modules/openapi-generator/src/main/resources/dart-jaguar/README.mustache index f3e63b485e1..93cdde77b2a 100644 --- a/modules/openapi-generator/src/main/resources/dart-jaguar/README.mustache +++ b/modules/openapi-generator/src/main/resources/dart-jaguar/README.mustache @@ -82,7 +82,7 @@ import 'package:{{pubName}}/api.dart'; {{/authMethods}} {{/hasAuthMethods}} -final jaguarApiGen = JaguarApiGen(); +final jaguarApiGen = {{clientName}}(); var api_instance = jaguarApiGen.get{{classname}}(); {{#allParams}} var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}} diff --git a/modules/openapi-generator/src/main/resources/dart-jaguar/apilib.mustache b/modules/openapi-generator/src/main/resources/dart-jaguar/apilib.mustache index cb41c5243ad..8571ea0a198 100644 --- a/modules/openapi-generator/src/main/resources/dart-jaguar/apilib.mustache +++ b/modules/openapi-generator/src/main/resources/dart-jaguar/apilib.mustache @@ -42,7 +42,7 @@ final Map converters = { final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()]; -class JaguarApiGen { +class {{clientName}} { List interceptors; String basePath = "{{basePath}}"; Route _baseRoute; @@ -51,7 +51,7 @@ class JaguarApiGen { /** * Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added) */ - JaguarApiGen({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { + {{clientName}}({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { _baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient()); if(interceptors == null) { this.interceptors = _defaultInterceptors; diff --git a/samples/client/petstore/dart-jaguar/flutter_petstore/openapi/README.md b/samples/client/petstore/dart-jaguar/flutter_petstore/openapi/README.md index 0d0008ed4f4..291b60d7e6b 100644 --- a/samples/client/petstore/dart-jaguar/flutter_petstore/openapi/README.md +++ b/samples/client/petstore/dart-jaguar/flutter_petstore/openapi/README.md @@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project: - API version: 1.0.0 -- Build date: 2019-06-29T11:26:01.157+12:00[Pacific/Auckland] +- Build date: 2019-06-29T09:47:15.495+12:00[Pacific/Auckland] - Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen ## Requirements @@ -55,7 +55,7 @@ import 'package:openapi/api.dart'; // TODO Configure OAuth2 access token for authorization: petstore_auth //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -final jaguarApiGen = JaguarApiGen(); +final jaguarApiGen = Openapi(); var api_instance = jaguarApiGen.getPetApi(); var body = new Pet(); // Pet | Pet object that needs to be added to the store diff --git a/samples/client/petstore/dart-jaguar/flutter_petstore/openapi/lib/api.dart b/samples/client/petstore/dart-jaguar/flutter_petstore/openapi/lib/api.dart index 23e42175157..b787b0405de 100644 --- a/samples/client/petstore/dart-jaguar/flutter_petstore/openapi/lib/api.dart +++ b/samples/client/petstore/dart-jaguar/flutter_petstore/openapi/lib/api.dart @@ -37,7 +37,7 @@ final Map converters = { final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()]; -class JaguarApiGen { +class Openapi { List interceptors; String basePath = "http://petstore.swagger.io/v2"; Route _baseRoute; @@ -46,7 +46,7 @@ class JaguarApiGen { /** * Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added) */ - JaguarApiGen({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { + Openapi({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { _baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient()); if(interceptors == null) { this.interceptors = _defaultInterceptors; diff --git a/samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/README.md b/samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/README.md index e50b342433b..82778678423 100644 --- a/samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/README.md +++ b/samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/README.md @@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project: - API version: 1.0.0 -- Build date: 2019-06-29T11:26:04.013+12:00[Pacific/Auckland] +- Build date: 2019-06-29T09:47:16.421+12:00[Pacific/Auckland] - Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen ## Requirements @@ -55,7 +55,7 @@ import 'package:openapi/api.dart'; // TODO Configure OAuth2 access token for authorization: petstore_auth //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -final jaguarApiGen = JaguarApiGen(); +final jaguarApiGen = Openapi(); var api_instance = jaguarApiGen.getPetApi(); var body = new Pet(); // Pet | Pet object that needs to be added to the store diff --git a/samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/lib/api.dart b/samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/lib/api.dart index bed06dd13dc..12dcdff72fe 100644 --- a/samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/lib/api.dart +++ b/samples/client/petstore/dart-jaguar/flutter_proto_petstore/openapi/lib/api.dart @@ -47,7 +47,7 @@ final Map converters = { final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()]; -class JaguarApiGen { +class Openapi { List interceptors; String basePath = "http://petstore.swagger.io/v2"; Route _baseRoute; @@ -56,7 +56,7 @@ class JaguarApiGen { /** * Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added) */ - JaguarApiGen({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { + Openapi({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { _baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient()); if(interceptors == null) { this.interceptors = _defaultInterceptors; diff --git a/samples/client/petstore/dart-jaguar/openapi/README.md b/samples/client/petstore/dart-jaguar/openapi/README.md index 2b99d076a70..7f450643330 100644 --- a/samples/client/petstore/dart-jaguar/openapi/README.md +++ b/samples/client/petstore/dart-jaguar/openapi/README.md @@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project: - API version: 1.0.0 -- Build date: 2019-06-29T11:25:59.502+12:00[Pacific/Auckland] +- Build date: 2019-06-29T09:47:14.533+12:00[Pacific/Auckland] - Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen ## Requirements @@ -55,7 +55,7 @@ import 'package:openapi/api.dart'; // TODO Configure OAuth2 access token for authorization: petstore_auth //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -final jaguarApiGen = JaguarApiGen(); +final jaguarApiGen = Openapi(); var api_instance = jaguarApiGen.getPetApi(); var body = new Pet(); // Pet | Pet object that needs to be added to the store diff --git a/samples/client/petstore/dart-jaguar/openapi/lib/api.dart b/samples/client/petstore/dart-jaguar/openapi/lib/api.dart index 23e42175157..b787b0405de 100644 --- a/samples/client/petstore/dart-jaguar/openapi/lib/api.dart +++ b/samples/client/petstore/dart-jaguar/openapi/lib/api.dart @@ -37,7 +37,7 @@ final Map converters = { final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()]; -class JaguarApiGen { +class Openapi { List interceptors; String basePath = "http://petstore.swagger.io/v2"; Route _baseRoute; @@ -46,7 +46,7 @@ class JaguarApiGen { /** * Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added) */ - JaguarApiGen({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { + Openapi({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { _baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient()); if(interceptors == null) { this.interceptors = _defaultInterceptors; diff --git a/samples/client/petstore/dart-jaguar/openapi_proto/README.md b/samples/client/petstore/dart-jaguar/openapi_proto/README.md index 761fc689ef7..84be8a47c9f 100644 --- a/samples/client/petstore/dart-jaguar/openapi_proto/README.md +++ b/samples/client/petstore/dart-jaguar/openapi_proto/README.md @@ -4,7 +4,7 @@ This is a sample server Petstore server. For this sample, you can use the api ke This Dart package is automatically generated by the [Open API Codegen](https://github.com/OpenAPITools/openapi-generator) project: - API version: 1.0.0 -- Build date: 2019-06-29T11:26:07.058+12:00[Pacific/Auckland] +- Build date: 2019-06-29T09:47:17.358+12:00[Pacific/Auckland] - Build package: org.openapitools.codegen.languages.DartJaguarClientCodegen ## Requirements @@ -55,7 +55,7 @@ import 'package:openapi/api.dart'; // TODO Configure OAuth2 access token for authorization: petstore_auth //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; -final jaguarApiGen = JaguarApiGen(); +final jaguarApiGen = Openapi(); var api_instance = jaguarApiGen.getPetApi(); var body = new Pet(); // Pet | Pet object that needs to be added to the store diff --git a/samples/client/petstore/dart-jaguar/openapi_proto/lib/api.dart b/samples/client/petstore/dart-jaguar/openapi_proto/lib/api.dart index bed06dd13dc..12dcdff72fe 100644 --- a/samples/client/petstore/dart-jaguar/openapi_proto/lib/api.dart +++ b/samples/client/petstore/dart-jaguar/openapi_proto/lib/api.dart @@ -47,7 +47,7 @@ final Map converters = { final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()]; -class JaguarApiGen { +class Openapi { List interceptors; String basePath = "http://petstore.swagger.io/v2"; Route _baseRoute; @@ -56,7 +56,7 @@ class JaguarApiGen { /** * Add custom global interceptors, put overrideInterceptors to true to set your interceptors only (auth interceptors will not be added) */ - JaguarApiGen({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { + Openapi({List interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) { _baseRoute = Route(baseUrl ?? basePath).withClient(globalClient ?? IOClient()); if(interceptors == null) { this.interceptors = _defaultInterceptors;