forked from loafle/openapi-generator-original
[dart-jaguar] Adds option to customise the generated API client name (#3234)
* [dart=-jaguar] Adds option to customise the generated API client name * [dart-jaguar] Removes explicit clientName CLI property and derives client name from pub name * [dart-jaguar] Updates samples * Reverts import changes
This commit is contained in:
parent
40a6e639d4
commit
f04ef76d07
@ -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<String> modelToIgnore = new HashSet<>();
|
||||
private HashMap<String, String> 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));
|
||||
|
@ -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}}}
|
||||
|
@ -42,7 +42,7 @@ final Map<String, CodecRepo> converters = {
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class JaguarApiGen {
|
||||
class {{clientName}} {
|
||||
List<Interceptor> 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<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
{{clientName}}({List<Interceptor> 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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -37,7 +37,7 @@ final Map<String, CodecRepo> converters = {
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class JaguarApiGen {
|
||||
class Openapi {
|
||||
List<Interceptor> 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<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
Openapi({List<Interceptor> 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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -47,7 +47,7 @@ final Map<String, CodecRepo> converters = {
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class JaguarApiGen {
|
||||
class Openapi {
|
||||
List<Interceptor> 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<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
Openapi({List<Interceptor> 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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -37,7 +37,7 @@ final Map<String, CodecRepo> converters = {
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class JaguarApiGen {
|
||||
class Openapi {
|
||||
List<Interceptor> 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<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
Openapi({List<Interceptor> 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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -47,7 +47,7 @@ final Map<String, CodecRepo> converters = {
|
||||
|
||||
final _defaultInterceptors = [OAuthInterceptor(), BasicAuthInterceptor(), ApiKeyAuthInterceptor()];
|
||||
|
||||
class JaguarApiGen {
|
||||
class Openapi {
|
||||
List<Interceptor> 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<Interceptor> interceptors, bool overrideInterceptors = false, String baseUrl, this.timeout = const Duration(minutes: 2)}) {
|
||||
Openapi({List<Interceptor> 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user