diff --git a/boat-scaffold/pom.xml b/boat-scaffold/pom.xml index b08bb6840..616d3d653 100644 --- a/boat-scaffold/pom.xml +++ b/boat-scaffold/pom.xml @@ -190,6 +190,9 @@ org.jacoco jacoco-maven-plugin + + **/*.jar + report diff --git a/boat-scaffold/src/main/java/org/openapitools/codegen/languages/BoatAndroidClientCodegen.java b/boat-scaffold/src/main/java/org/openapitools/codegen/languages/BoatAndroidClientCodegen.java new file mode 100644 index 000000000..b973efc8a --- /dev/null +++ b/boat-scaffold/src/main/java/org/openapitools/codegen/languages/BoatAndroidClientCodegen.java @@ -0,0 +1,37 @@ +package org.openapitools.codegen.languages; + +import org.openapitools.codegen.SupportingFile; + +public class BoatAndroidClientCodegen extends KotlinClientCodegen { + + public static final String NAME = "boat-android"; + public static final String DBS_DATA_PROVIDER = "DBSDataProvider"; + + public BoatAndroidClientCodegen() { + super(); + supportedLibraries.put(DBS_DATA_PROVIDER, "Backbase: client"); + library = DBS_DATA_PROVIDER; + embeddedTemplateDir = NAME; + templateDir = NAME; + propertyAdditionalKeywords.remove("size"); + specialCharReplacements.put("-", ""); + supportingFiles.add(new SupportingFile("manifest.mustache", "", "src/main/AndroidManifest.xml")); + supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties")); + } + + + @Override + public void setLibrary(String library) { + this.library = library; + } + + @Override + public String getName() { + return NAME; + } + + @Override + public String toString() { + return super.toString(); + } +} diff --git a/boat-scaffold/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/boat-scaffold/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig index d18e7e34e..0960d008a 100644 --- a/boat-scaffold/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig +++ b/boat-scaffold/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -2,4 +2,5 @@ com.backbase.oss.codegen.java.BoatSpringCodeGen com.backbase.oss.codegen.java.BoatJavaCodeGen com.backbase.oss.codegen.doc.BoatDocsGenerator com.backbase.oss.codegen.angular.BoatAngularGenerator -com.backbase.oss.codegen.marina.BoatMarinaGenerator \ No newline at end of file +com.backbase.oss.codegen.marina.BoatMarinaGenerator +org.openapitools.codegen.languages.BoatAndroidClientCodegen \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/README.mustache b/boat-scaffold/src/main/templates/boat-android/README.mustache new file mode 100644 index 000000000..e69de29bb diff --git a/boat-scaffold/src/main/templates/boat-android/additionalModelTypeAnnotations.mustache b/boat-scaffold/src/main/templates/boat-android/additionalModelTypeAnnotations.mustache new file mode 100644 index 000000000..f4871c02c --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/additionalModelTypeAnnotations.mustache @@ -0,0 +1,2 @@ +{{#additionalModelTypeAnnotations}}{{{.}}} +{{/additionalModelTypeAnnotations}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/api.mustache b/boat-scaffold/src/main/templates/boat-android/api.mustache new file mode 100644 index 000000000..ac2b39f8f --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/api.mustache @@ -0,0 +1,138 @@ +{{>licenseInfo}} +package {{apiPackage}} + +{{#imports}}import {{import}} +{{/imports}} +import java.net.URI +import com.backbase.android.dbs.DBSClient +import com.backbase.android.common.utils.dbs.MutableParams +import com.backbase.android.common.utils.dbs.Params +import com.backbase.android.dbs.DBSDataProvider +import com.backbase.android.common.utils.dbs.DBSDataImpl +import com.backbase.android.common.utils.dbs.CustomNetworkDBSProvider +import com.backbase.android.Backbase +import com.backbase.android.utils.net.MultiPartWrapper +import com.backbase.android.utils.net.PartContent +import com.backbase.android.utils.net.request.RequestMethods +import com.backbase.android.utils.net.request.Request +import android.content.Context + +import com.squareup.moshi.Types +import com.squareup.moshi.Moshi + +import dev.drewhamilton.extracare.DataApi + +import com.backbase.android.clients.common.Call +import com.backbase.android.clients.common.MultipartCall +import com.backbase.android.clients.common.ResponseBodyParser +import com.backbase.android.clients.common.MoshiResponseBodyParser +import com.backbase.android.clients.common.buildRequest +import com.backbase.android.clients.common.serializeToHttpRequestPart + +{{#operations}} +/** + * API root for {{classname}}. + * + * @param context the current android context. + * @param moshi the json library instance. + * @param parser the response body parser for DTOs returned by the REST API. + * @param serverUri the server URI where the REST API can be reached. + * @param provider the DBS data provider. + * @param backbase the backbase sdk instance. + */ +class {{classname}}( + val context: Context, + val moshi: Moshi, + val parser: ResponseBodyParser, + var serverUri: URI, + var provider: DBSDataProvider = CustomNetworkDBSProvider(context), + var backbase: Backbase = requireNotNull(Backbase.getInstance()) { "The Backbase instance must not be null!" } +) : DBSClient, DBSDataImpl(backbase) { + + override fun setBaseURI(baseUri: URI) { + this.serverUri = baseUri + } + + override fun getBaseURI() = this.serverUri + + override fun setDataProvider(provider: DBSDataProvider?) { + this.provider = requireNotNull(provider) { "The provider must not be null!" } + } + + override fun getDataProvider(): DBSDataProvider? = provider + + {{#operation}} + + /** + * {{summary}} + * {{notes}} + * @param params the params of this request. + * @return the request that can be executed to perform the {{{operationId}}} operation.{{#isDeprecated}} + * @deprecated{{/isDeprecated}} + */{{#isDeprecated}} + @Deprecated(message = "This operation is deprecated. Do not use"){{/isDeprecated}} + fun {{operationId}}(params: {{classname}}Params.{{{operationIdCamelCase}}}): {{^isMultipart}}{{#isListContainer}}Call<{{{returnType}}}>{{/isListContainer}}{{^isListContainer}}Call<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}>{{/isListContainer}}{{/isMultipart}}{{#isMultipart}}{{#isListContainer}}MultipartCall<{{{returnType}}}>{{/isListContainer}}{{^isListContainer}}MultipartCall<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}>{{/isListContainer}}{{/isMultipart}} { + {{^isMultipart}} + val bodyType = {{#bodyParam}}{{>api_parameter_model_type}}{{/bodyParam}} {{^hasBodyParam}}{{#hasFormParams}}Types.newParameterizedType(Map::class.java, String::class.java, String::class.java){{/hasFormParams}}{{/hasBodyParam}}{{^hasBodyParam}}{{^hasFormParams}}null{{/hasFormParams}}{{/hasBodyParam}} + val serializedBody: kotlin.String? = {{#bodyParam}}moshi.adapter<{{{dataType}}}>(bodyType).toJson(params.{{{paramName}}}){{/bodyParam}}{{^hasBodyParam}}{{^hasFormParams}}null{{/hasFormParams}}{{#hasFormParams}}moshi.adapter>(bodyType).toJson(mapOf({{#formParams}}"{{{baseName}}}" to params.{{{paramName}}}?.toString(){{#hasMore}}, {{/hasMore}}{{/formParams}})){{/hasFormParams}}{{/hasBodyParam}} + val headers: MutableMap = mutableMapOf() + {{#hasConsumes}}{{#consumes.0}}headers["Content-Type"] = "{{mediaType}}"{{/consumes.0}}{{/hasConsumes}} + {{#hasHeaderParams}} + {{#headerParams}} + headers["{{{baseName}}}"] = {{#isContainer}}params.{{{paramName}}}.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}params.{{paramName}}.toString(){{/isContainer}} + {{/headerParams}} + {{/hasHeaderParams}} + + {{/isMultipart}} + val queryParams = mutableMapOf>() + val path = "{{{path}}}"{{#pathParams}}.replace("{" + "{{{paramName}}}" + "}", params.{{{paramName}}}.toString()){{/pathParams}} + + {{>queryParams}} + + val request = buildRequest(RequestMethods.{{{httpMethod}}}, serverUri, path, queryParams, backbase) + {{^isMultipart}} + request.body = serializedBody + request.headers = headers{{#isMapContainer}} + + return Call<{{{returnType}}}>(request, provider, parser, Types.newParameterizedType(Map::class.java, String::class.java, {{{returnBaseType}}}::class.java)){{/isMapContainer}}{{^isMapContainer}}{{#isListContainer}} + return Call<{{{returnType}}}>(request, provider, parser, Types.newParameterizedType(List::class.java, {{{returnBaseType}}}::class.java)){{/isListContainer}}{{^isListContainer}}{{#isArray}} + return Call<{{{returnType}}}>(request, provider, parser, Types.newParameterizedType(List::class.java, {{{returnBaseType}}}::class.java)){{/isArray}}{{^isArray}} + return Call<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}>(request, provider, parser, {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}::class.java){{/isArray}}{{/isListContainer}}{{/isMapContainer}} + {{/isMultipart}} + {{#isMultipart}} + val multiPartWrapper = MultiPartWrapper("multipart/form-data") + {{#formParams}} + {{#isFile}}{{#isContainer}} /* an array of files */ + if (params.{{{paramName}}} != null && params.{{{paramName}}}FileNames != null && params.{{{paramName}}}ContentTypes != null) { + {{{paramName}}}.filterNotNull().forEachIndexed { fileIndex, fileElement -> + multiPartWrapper.addPart(PartContent("{{{paramName}}}", params.{{{paramName}}}FileNames[fileIndex], fileElement, params.{{{paramName}}}ContentTypes[fileIndex])) + } + } + {{/isContainer}}{{/isFile}} + {{#isFile}}{{^isContainer}} /* single file */ + if (params.{{{paramName}}} != null && params.{{{paramName}}}FileName != null && params.{{{paramName}}}ContentType != null) { + multiPartWrapper.addPart(PartContent("{{{paramName}}}", params.{{paramName}}FileName, params.{{{paramName}}}, params.{{{paramName}}}ContentType)) + } + {{/isContainer}}{{/isFile}} + {{^isFile}} /* not a file */ + if (params.{{{paramName}}} != null) { + val nonFileContentType = params.{{{paramName}}}ContentType ?: "{{#isPrimitive}}text/plain{{/isPrimitive}}{{^isPrimitive}}application/json{{/isPrimitive}}" + multiPartWrapper.addPart(PartContent("{{{paramName}}}", "", {{>api_parameter}}.toString().toByteArray(), nonFileContentType)) + } + {{/isFile}} + {{/formParams}} + + {{#isListContainer}} + return MultipartCall<{{{returnType}}}>(request, multiPartWrapper, parser, Types.newParameterizedType(List::class.java, {{{returnBaseType}}}::class.java)) + {{/isListContainer}} + {{^isListContainer}} + return MultipartCall<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}>(request, multiPartWrapper, parser, {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}::class.java) + {{/isListContainer}} + {{/isMultipart}} + } + + {{/operation}} +} +{{/operations}} + +{{>api_parameters}} diff --git a/boat-scaffold/src/main/templates/boat-android/api_doc.mustache b/boat-scaffold/src/main/templates/boat-android/api_doc.mustache new file mode 100644 index 000000000..bcf4b957e --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/api_doc.mustache @@ -0,0 +1,86 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```kotlin +// Import classes: +//import {{{packageName}}}.infrastructure.* +//import {{{modelPackage}}}.* + +val apiInstance = {{{classname}}}() +{{#allParams}} +val {{{paramName}}} : {{{dataType}}} = {{{example}}} // {{{dataType}}} | {{{description}}} +{{/allParams}} +try { + {{#returnType}}val result : {{{returnType}}} = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + println(result){{/returnType}} +} catch (e: ClientException) { + println("4xx response calling {{{classname}}}#{{{operationId}}}") + e.printStackTrace() +} catch (e: ServerException) { + println("5xx response calling {{{classname}}}#{{{operationId}}}") + e.printStackTrace() +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{#generateModelDocs}}[**{{returnType}}**]({{returnBaseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{returnType}}**{{/generateModelDocs}}{{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}} +{{#authMethods}} +{{#isApiKey}} +Configure {{name}}: + ApiClient.apiKey["{{keyParamName}}"] = "" + ApiClient.apiKeyPrefix["{{keyParamName}}"] = "" +{{/isApiKey}} +{{#isBasic}} +{{^isBasicBearer}} +Configure {{name}}: + ApiClient.username = "" + ApiClient.password = "" +{{/isBasicBearer}} +{{#isBasicBearer}} +Configure {{name}}: + ApiClient.accessToken = "" +{{/isBasicBearer}} +{{/isBasic}} +{{#isOAuth}} +Configure {{name}}: + ApiClient.accessToken = "" +{{/isOAuth}} +{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/boat-scaffold/src/main/templates/boat-android/api_operation_parameter_model.mustache b/boat-scaffold/src/main/templates/boat-android/api_operation_parameter_model.mustache new file mode 100644 index 000000000..ae81a0f8a --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/api_operation_parameter_model.mustache @@ -0,0 +1,95 @@ +/** + {{#allParams}}* @param {{paramName}} {{{description}}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isFile}} + * @param {{paramName}}FileName{{#isContainer}}s{{/isContainer}} the name of the file(s) whose content is [{{paramName}}]. Optional only if the related file(s) optional. + * @param {{paramName}}ContentType{{#isContainer}}s{{/isContainer}} the mime type of the file(s) whose content is [{{paramName}}]. Optional only if the related file(s) optional. + {{/isFile}}{{^isFile}}{{#isMultipart}}{{#isFormParam}} + * @param {{paramName}}ContentType the mime type of [{{paramName}}]. Optional. Defaults to text/plain for primitives and application/json for everything else. + {{/isFormParam}}{{/isMultipart}}{{/isFile}}{{/allParams}} + */ +{{#hasParams}}@DataApi {{/hasParams}}class {{{operationIdCamelCase}}} internal constructor( + {{#allParams}} + + val {{{paramName}}}: {{{dataType}}}{{^required}}? = null{{/required}}, + + {{#isMultipart}} + {{#isFormParam}} + {{^isFile}} + val {{{paramName}}}ContentType: String? = null, + {{/isFile}} + {{/isFormParam}} + {{/isMultipart}} + + {{#isFile}} + {{^isContainer}} + val {{{paramName}}}FileName: String{{^required}}? = null{{/required}}, + val {{{paramName}}}ContentType: String{{^required}}? = null{{/required}} + {{/isContainer}} + + {{#isContainer}} + val {{{paramName}}}FileNames: List{{^required}}? = null{{/required}}, + val {{{paramName}}}ContentTypes: List{{^required}}? = null{{/required}}, + {{/isContainer}} + {{/isFile}} + {{/allParams}} +) { + + class Builder { + {{#allParams}} + var {{{paramName}}}: {{{dataType}}}? = null + {{#isMultipart}} + {{#isFormParam}} + {{^isFile}} + var {{{paramName}}}ContentType: String? = null + {{/isFile}} + {{/isFormParam}} + {{/isMultipart}} + {{#isFile}} + {{^isContainer}} + var {{{paramName}}}FileName: String? = null + var {{{paramName}}}ContentType: String? = null + {{/isContainer}} + {{#isContainer}} + var {{{paramName}}}FileNames: List? = null + var {{{paramName}}}ContentTypes: List? = null + {{/isContainer}} + {{/isFile}} + {{/allParams}} + + fun build() = {{{operationIdCamelCase}}}( + {{#allParams}} + {{#required}} + requireNotNull({{{paramName}}}), + {{/required}} + {{^required}} + {{{paramName}}}, + {{/required}} + {{#isMultipart}} + {{#isFormParam}} + {{^isFile}} + requireNotNull({{{paramName}}}ContentType), + {{/isFile}} + {{/isFormParam}} + {{/isMultipart}} + {{#isFile}} + {{^isContainer}} + requireNotNull({{{paramName}}}FileName), + requireNotNull({{{paramName}}}ContentType), + {{/isContainer}} + {{#isContainer}} + requireNotNull({{{paramName}}}FileNames), + requireNotNull({{{paramName}}}ContentTypes), + {{/isContainer}} + {{/isFile}} + {{/allParams}} + ) + } +} + +/** + * Builds an instance of [{{{operationIdCamelCase}}}] with the [initializer] parameters. + */ +@Suppress("FunctionName") // DSL initializer +@JvmSynthetic // Hide from Java callers who should use Builder +fun {{{operationIdCamelCase}}}(initializer: {{{operationIdCamelCase}}}.Builder.() -> Unit): {{{operationIdCamelCase}}} { + return {{{operationIdCamelCase}}}.Builder().apply(initializer).build() +} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/api_parameter.mustache b/boat-scaffold/src/main/templates/boat-android/api_parameter.mustache new file mode 100644 index 000000000..fa40a7b00 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/api_parameter.mustache @@ -0,0 +1 @@ +{{#isPrimitiveType}}params.{{{paramName}}}{{^required}}{{/required}}.{{#isNumber}}toPlainString(){{/isNumber}}{{^isNumber}}toString(){{/isNumber}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{^allowableValues.empty}}{{#enumVars.empty}}{{>api_parameter_model_type}}.let { moshi.adapter<{{{dataType}}}>(it).toJson(params.{{{paramName}}}) }{{/enumVars.empty}}{{^enumVars.empty}}params.{{{paramName}}}{{^required}}{{/required}}.toString(){{/enumVars.empty}}{{/allowableValues.empty}}{{#allowableValues.empty}}params.{{{paramName}}}{{^required}}{{/required}}.toString(){{/allowableValues.empty}}{{/isPrimitiveType}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/api_parameter_model_type.mustache b/boat-scaffold/src/main/templates/boat-android/api_parameter_model_type.mustache new file mode 100644 index 000000000..fd1c54f1b --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/api_parameter_model_type.mustache @@ -0,0 +1 @@ +{{#isContainer}}{{^isMap}}{{^isArray}}Types.newParameterizedType(List::class.java, {{{baseType}}}::class.java){{/isArray}}{{/isMap}}{{/isContainer}}{{#isMap}}Types.newParameterizedType(Map::class.java, String::class.java, {{{baseType}}}::class.java){{/isMap}} {{#isArray}}Types.newParameterizedType(List::class.java, {{{baseType}}}::class.java){{/isArray}} {{^isContainer}}{{{dataType}}}::class.java{{/isContainer}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/api_parameters.mustache b/boat-scaffold/src/main/templates/boat-android/api_parameters.mustache new file mode 100644 index 000000000..2114cc3a7 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/api_parameters.mustache @@ -0,0 +1,8 @@ +object {{classname}}Params { + + {{#operations}} + {{#operation}} + {{>api_operation_parameter_model}} + {{/operation}} + {{/operations}} +} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/build.gradle.mustache b/boat-scaffold/src/main/templates/boat-android/build.gradle.mustache new file mode 100644 index 000000000..089f64cec --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/build.gradle.mustache @@ -0,0 +1,202 @@ +buildscript { + ext.retailGroup = 'com.backbase.android.retail' + ext.appGroup = "${retailGroup}.app" + + ext.rootGroup = 'com.backbase.android.clients' + ext.projectVersions = [ + minSdk: 23, + targetSdk: 33, + buildTools: "33.0.0", + versionName: '2.0.0' + ] + + //region Dependency declarations + ext.versions = [ + annotations: '1.1.0', + apacheCommonsLang: '3.8', + appCompat: '1.1.0', + backbaseSdk: '7.3.0', + coreKtx: '1.1.0', + dokka: '1.7.10', + gson: '2.8.5', + junit: '4.13', + junitAndroid: '1.1.1', + kotlin: '1.7.10', + kotlinCoroutines: '1.3.0', + mockK: '1.9.3', + moshi: '1.15.0', + material: '1.1.0', + multiDex: '2.0.0', + okhttp3: '3.14.9', + robolectric: '4.3.1', + rxJava1: '1.3.8', + testCore: '1.2.0', + testOrchestrator: '1.2.0', + testRules: '1.2.0', + testRunner: '1.2.0', + truth: '1.0', + wc3: '7.0.0', + ] + + ext.deps = [ + accessControlClient: "com.backbase.android.clients:access-control-client:$versions.wc3", + annotations: "androidx.annotation:annotation:$versions.annotations", + apacheCommonsLang: "org.apache.commons:commons-lang3:$versions.apacheCommonsLang", + apacheHttpClient: "org.apache.httpcomponents:httpclient:$versions.apacheHttpClient", + appCompat: "androidx.appcompat:appcompat:$versions.appCompat", + backbaseIdentitySdk: 'com.backbase.android.identity:identitysdk:1.3.0', + backbaseSdk: "com.backbase.android.sdk:backbase:$versions.backbaseSdk", + commonUtils: "com.backbase.android.common:common-utils:$versions.wc3", + coreKtx: "androidx.core:core-ktx:$versions.coreKtx", + desugarJdkLibs: 'com.android.tools:desugar_jdk_libs:1.0.9', + gson: "com.google.code.gson:gson:$versions.gson", + junit: "junit:junit:$versions.junit", + junitAndroid: "androidx.test.ext:junit:$versions.junitAndroid", + kotlinCoroutines: "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.kotlinCoroutines", + kotlinCoroutinesTest: "org.jetbrains.kotlinx:kotlinx-coroutines-test:$versions.kotlinCoroutines", + kotlinStdLib: "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin", + kotlinReflect: "org.jetbrains.kotlin:kotlin-reflect:$versions.kotlin", + material: "com.google.android.material:material:$versions.material", + mockK: "io.mockk:mockk:$versions.mockK", + mockWebServer: "com.squareup.okhttp3:mockwebserver:$versions.okhttp3", + moshi: "com.squareup.moshi:moshi-kotlin:$versions.moshi", + moshiAdapters: "com.squareup.moshi:moshi-adapters:$versions.moshi", + moshiCodegen: "com.squareup.moshi:moshi-kotlin-codegen:$versions.moshi", + multiDex: "androidx.multidex:multidex:$versions.multiDex", + okhttp3: "com.squareup.okhttp3:okhttp:$versions.okhttp3", + robolectric: "org.robolectric:robolectric:$versions.robolectric", + rxJava1: "io.reactivex:rxjava:$versions.rxJava1", + testCore: "androidx.test:core:$versions.testCore", + testOrchestrator: "androidx.test:orchestrator:$versions.testOrchestrator", + testRules: "androidx.test:rules:$versions.testRules", + testRunner: "androidx.test:runner:$versions.testRunner", + truth: "com.google.truth:truth:$versions.truth", + clientsCommon: "$rootGroup:clients-common:$projectVersions.versionName", + ] + //endregion + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.0' + classpath "org.jetbrains.dokka:dokka-gradle-plugin:$versions.dokka" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin" + classpath 'org.jetbrains.kotlinx:binary-compatibility-validator:0.9.0' + classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.24.14' + classpath 'dev.drewhamilton.poko:poko-gradle-plugin:0.11.0' + } + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +allprojects { project -> + repositories { + google() + // These variables must be set up on your machine's global gradle.properties: + maven { + url = 'https://artifacts.backbase.com/android3' + credentials { + username = mvnUser + password = mvnPass + } + } + maven { + url = 'https://artifacts.backbase.com/android-retail3' + credentials { + username = mvnUser + password = mvnPass + } + } + maven { + url = 'https://artifacts.backbase.com/android-wealth3' + credentials { + username = mvnUser + password = mvnPass + } + } + maven { + url = 'https://artifacts.backbase.com/android-flow-development' + credentials { + username = mvnUser + password = mvnPass + } + } + maven { + url = 'https://artifacts.backbase.com/android-identity' + credentials { + username = mvnUser + password = mvnPass + } + } + mavenCentral() + jcenter() + } + + //noinspection UnnecessaryQualifiedReference + project.plugins.withType(com.android.build.gradle.LibraryPlugin) { + group = rootGroup + + //region Disable BuildConfig for libraries + project.android.libraryVariants.all { variant -> + // TODO WORKAROUND: replace with https://issuetracker.google.com/issues/72050365 once released. + variant.generateBuildConfigProvider.get().enabled = false + } + //endregion + } + + project.plugins.withType(JavaLibraryPlugin) { + group = rootGroup + } +} +apply plugin: 'com.android.library' +apply plugin: 'dev.drewhamilton.poko' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-kapt' +apply plugin: 'kotlin-parcelize' +apply plugin: 'org.jetbrains.dokka' + +group rootGroup +ext.artifactName = '{{{artifactId}}}' +version = '{{artifactVersion}}' + +poko { + // Add this if you want to use the old annotation + // Skip this if you want to use the new default Poko annotation + pokoAnnotation = "dev.drewhamilton.extracare.DataApi" +} + +android { + namespace '{{packageName}}' + compileSdk projectVersions.targetSdk + defaultConfig { + minSdk projectVersions.minSdk + versionName '{{artifactVersion}}' + consumerProguardFiles 'bb-clients-proguard-rules.pro' + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + compileOptions { + coreLibraryDesugaringEnabled true + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11 + } +} + +dependencies { + kapt deps.moshiCodegen + implementation deps.kotlinStdLib + implementation deps.kotlinReflect + implementation deps.annotations + implementation deps.moshi + implementation deps.moshiAdapters + implementation deps.backbaseSdk + implementation deps.commonUtils + implementation deps.clientsCommon + coreLibraryDesugaring deps.desugarJdkLibs +} diff --git a/boat-scaffold/src/main/templates/boat-android/class_doc.mustache b/boat-scaffold/src/main/templates/boat-android/class_doc.mustache new file mode 100644 index 000000000..b363fc5a6 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/class_doc.mustache @@ -0,0 +1,15 @@ +# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isEnum}}[**inline**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} +{{/vars}} +{{#vars}}{{#isEnum}} + +{{!NOTE: see java's resources "pojo_doc.mustache" once enums are fully implemented}} +## Enum: {{baseName}} +Name | Value +---- | -----{{#allowableValues}} +{{name}} | {{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}} +{{/isEnum}}{{/vars}} diff --git a/boat-scaffold/src/main/templates/boat-android/data_class.mustache b/boat-scaffold/src/main/templates/boat-android/data_class.mustache new file mode 100644 index 000000000..fa7acddfc --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class.mustache @@ -0,0 +1,58 @@ +{{#gson}} +import com.google.gson.annotations.SerializedName +{{/gson}} +{{#moshi}} +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass +{{/moshi}} +import java.util.Objects +{{#parcelizeModels}}import android.os.Parcelable +import kotlinx.parcelize.Parcelize{{/parcelizeModels}} + +import android.os.Build +import androidx.annotation.RequiresApi +import com.backbase.android.common.utils.dates.DBSDateTimeFormats + +/** + * {{{description}}} +{{>data_class_fields_docs}} + */ +{{#parcelizeModels}} +@Parcelize +{{/parcelizeModels}} +{{#moshi}}@JsonClass(generateAdapter = true){{/moshi}} +class {{{classname}}} internal constructor( +{{>data_class_fields}} +) {{#parcelizeModels}}: Parcelable {{/parcelizeModels}}{ + +{{>data_class_inner_enums}} + + override fun hashCode() = Objects.hash({{>data_class_hashCode}}) + + override fun equals(other: Any?):Boolean = other is {{classname}} + {{>data_class_equals_fields_comparisons}} + + override fun toString() = "{{classname}}({{>data_class_toString_fields}})" + + /** + * A builder for [{{classname}}]. + */ + class Builder { + +{{>data_class_builder_fields}} + + /** + * Builds an instance of [{{classname}}]. + */ + fun build() = {{classname}}({{>data_class_builder_build_parameters}}) + } +} + +/** + * Builds an instance of [{{classname}}] with the [initializer] parameters. + */ +@Suppress("FunctionName") // DSL initializer +@JvmSynthetic // Hide from Java callers who should use Builder +fun {{classname}}(initializer: {{classname}}.Builder.() -> Unit): {{classname}} { + return {{classname}}.Builder().apply(initializer).build() +} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_builder_build_parameters.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_builder_build_parameters.mustache new file mode 100644 index 000000000..a051f8268 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_builder_build_parameters.mustache @@ -0,0 +1 @@ +{{#vars}}{{{name}}} = {{{name}}}{{#required}}!!{{/required}}, {{/vars}}{{#parentModel}}{{>data_class_builder_build_parameters}}{{/parentModel}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_builder_fields.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_builder_fields.mustache new file mode 100644 index 000000000..b13ec4dcb --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_builder_fields.mustache @@ -0,0 +1,8 @@ +{{#vars}} + /** + * See [{{classname}}.{{{name}}}]. + */ + var {{{name}}}: {{#isEnum}} {{#isListContainer}} kotlin.collections.List<{{classname}}.{{{nameInCamelCase}}}> {{/isListContainer}} {{^isListContainer}} {{classname}}.{{{nameInCamelCase}}} {{/isListContainer}} {{/isEnum}} {{^isEnum}} {{{dataType}}} {{/isEnum}} ? = {{#defaultValue}} {{#isEnum}}null{{/isEnum}}{{^isEnum}}{{#isNumber}}java.math.BigDecimal({{{defaultValue}}}) {{/isNumber}} {{^isNumber}} {{{defaultValue}}} {{/isNumber}} {{/isEnum}} {{/defaultValue}} {{^defaultValue}} null {{/defaultValue}} + +{{/vars}} +{{#parentModel}}{{>data_class_builder_fields}}{{/parentModel}} diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_equals_fields_comparisons.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_equals_fields_comparisons.mustache new file mode 100644 index 000000000..1937797db --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_equals_fields_comparisons.mustache @@ -0,0 +1,2 @@ +{{#vars}} && {{{name}}} == other.{{{name}}} {{/vars}} +{{#parentModel}}{{>data_class_equals_fields_comparisons}}{{/parentModel}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_fields.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_fields.mustache new file mode 100644 index 000000000..551a49a52 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_fields.mustache @@ -0,0 +1,3 @@ +{{#vars}}{{#required}}{{>data_class_req_val}}{{/required}}{{^required}}{{>data_class_opt_val}}{{/required}}, +{{/vars}} +{{#parentModel}}{{>data_class_fields}}{{/parentModel}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_fields_docs.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_fields_docs.mustache new file mode 100644 index 000000000..eb7a9c5e6 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_fields_docs.mustache @@ -0,0 +1,3 @@ +{{#vars}} * @param {{name}} {{{description}}} +{{/vars}} +{{#parentModel}}{{>data_class_fields_docs}}{{/parentModel}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_hashCode.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_hashCode.mustache new file mode 100644 index 000000000..63ea2dd86 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_hashCode.mustache @@ -0,0 +1 @@ +{{#vars}}{{{name}}}, {{/vars}}{{#parentModel}}{{>data_class_hashCode}}{{/parentModel}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_inner_enums.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_inner_enums.mustache new file mode 100644 index 000000000..e61492ba6 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_inner_enums.mustache @@ -0,0 +1,32 @@ + {{#hasEnums}} + {{#vars}} + {{#isEnum}} + /** + * {{{description}}} + * Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} + */ + enum class {{{nameInCamelCase}}}(val value: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}kotlin.String{{/isContainer}}){ + {{#allowableValues}} + {{#enumVars}} + {{#moshi}} + @Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}} + {{/moshi}} + {{#gson}} + @SerializedName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}} + {{/gson}} + {{/enumVars}} + {{/allowableValues}} + + /** + * This override toString avoids using the enum var name and uses the actual api value instead. + * In cases the var name and value are different, the client would send incorrect enums to the server. + */ + override fun toString(): String { + return value{{^isString}}.toString(){{/isString}} + } + } + {{/isEnum}} + {{/vars}} + {{/hasEnums}} + + {{#parentModel}}{{>data_class_inner_enums}}{{/parentModel}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_opt_val.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_opt_val.mustache new file mode 100644 index 000000000..5b4b1b427 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_opt_val.mustache @@ -0,0 +1,13 @@ +{{#description}} + /* {{{description}}} */ +{{/description}} + {{#moshi}} + @Json(name = "{{{baseName}}}") + {{/moshi}} + {{#gson}} + @SerializedName("{{name}}") + {{/gson}} +{{#isDeprecated}} + @Deprecated(message = "This field has been deprecated") +{{/isDeprecated}} + val {{{name}}}: {{#isFreeFormObject}}@kotlinx.android.parcel.RawValue {{/isFreeFormObject}}{{#isEnum}}{{#isListContainer}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultValue}}{{#isEnum}}null{{/isEnum}}{{^isEnum}}{{{defaultValue}}}{{/isEnum}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_opt_var.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_opt_var.mustache new file mode 100644 index 000000000..f0198c9e6 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_opt_var.mustache @@ -0,0 +1,21 @@ +{{#description}} + /* {{{.}}} */ +{{/description}} + {{^multiplatform}} + {{#moshi}} + @Json(name = "{{{vendorExtensions.x-base-name-literal}}}") + {{/moshi}} + {{#gson}} + @SerializedName("{{{vendorExtensions.x-base-name-literal}}}") + {{/gson}} + {{#jackson}} + @field:JsonProperty("{{{vendorExtensions.x-base-name-literal}}}") + {{/jackson}} + {{#kotlinx_serialization}} + {{^isEnum}}{{^isArray}}{{^isPrimitiveType}}{{^isModel}}@Contextual {{/isModel}}{{/isPrimitiveType}}{{/isArray}}{{/isEnum}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") + {{/kotlinx_serialization}} + {{/multiplatform}} + {{#deprecated}} + @Deprecated(message = "This property is deprecated.") + {{/deprecated}} + {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}{{#uniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}Set{{/uniqueItems}}{{^uniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/uniqueItems}}{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}? = {{^defaultValue}}null{{/defaultValue}}{{#defaultValue}}{{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{^multiplatform}}{{{dataType}}}("{{{defaultValue}}}"){{/multiplatform}}{{#multiplatform}}({{{defaultValue}}}).toDouble(){{/multiplatform}}{{/isNumber}}{{/defaultValue}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_req_val.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_req_val.mustache new file mode 100644 index 000000000..a095543bf --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_req_val.mustache @@ -0,0 +1,13 @@ +{{#description}} + /* {{{description}}} */ +{{/description}} + {{#moshi}} + @Json(name = "{{{baseName}}}") + {{/moshi}} + {{#gson}} + @SerializedName("{{name}}") + {{/gson}} +{{#isDeprecated}} + @Deprecated(message = "This field has been deprecated") +{{/isDeprecated}} + val {{{name}}}: {{#isFreeFormObject}}@kotlinx.android.parcel.RawValue {{/isFreeFormObject}}{{#isEnum}}{{#isListContainer}}kotlin.collections.List<{{classname}}.{{{nameInCamelCase}}}>{{/isListContainer}}{{^isListContainer}}{{classname}}.{{{nameInCamelCase}}}{{/isListContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_req_var.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_req_var.mustache new file mode 100644 index 000000000..1bfbcc582 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_req_var.mustache @@ -0,0 +1,21 @@ +{{#description}} + /* {{{.}}} */ +{{/description}} + {{^multiplatform}} + {{#moshi}} + @Json(name = "{{{vendorExtensions.x-base-name-literal}}}") + {{/moshi}} + {{#gson}} + @SerializedName("{{{vendorExtensions.x-base-name-literal}}}") + {{/gson}} + {{#jackson}} + @field:JsonProperty("{{{vendorExtensions.x-base-name-literal}}}") + {{/jackson}} + {{#kotlinx_serialization}} + {{^isEnum}}{{^isArray}}{{^isPrimitiveType}}{{^isModel}}@Contextual {{/isModel}}{{/isPrimitiveType}}{{/isArray}}{{/isEnum}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") + {{/kotlinx_serialization}} + {{/multiplatform}} + {{#deprecated}} + @Deprecated(message = "This property is deprecated.") + {{/deprecated}} + {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{#isInherited}}override {{/isInherited}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}{{#uniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}Set{{/uniqueItems}}{{^uniqueItems}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/uniqueItems}}{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}{{#defaultValue}} = {{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{^multiplatform}}{{{dataType}}}("{{{defaultValue}}}"){{/multiplatform}}{{#multiplatform}}({{{defaultValue}}}).toDouble(){{/multiplatform}}{{/isNumber}}{{/defaultValue}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/data_class_toString_fields.mustache b/boat-scaffold/src/main/templates/boat-android/data_class_toString_fields.mustache new file mode 100644 index 000000000..1d5f85689 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/data_class_toString_fields.mustache @@ -0,0 +1 @@ +{{#vars}}{{{name}}}=${{{name}}}{{^-last}},{{/-last}}{{/vars}}{{#parentModel}},{{>data_class_toString_fields}}{{/parentModel}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/enum_class.mustache b/boat-scaffold/src/main/templates/boat-android/enum_class.mustache new file mode 100644 index 000000000..52462ac15 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/enum_class.mustache @@ -0,0 +1,40 @@ +{{#gson}} +import com.google.gson.annotations.SerializedName +{{/gson}} +{{#moshi}} +import com.squareup.moshi.Json +{{/moshi}} + +/** + {{#description}}* {{{description}}}{{/description}} + * Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} + */ +enum class {{classname}}(val value: {{{dataType}}}) { +{{#allowableValues}}{{#enumVars}} + {{#moshi}} + @Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) + {{/moshi}} + {{#gson}} + @SerializedName(value = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) + {{/gson}} + {{#isListContainer}} + {{#isList}} + {{&name}}(listOf({{{value}}})){{^-last}},{{/-last}}{{#-last}};{{/-last}} + {{/isList}} + {{^isList}} + {{&name}}(arrayOf({{{value}}})){{^-last}},{{/-last}}{{#-last}};{{/-last}} + {{/isList}} + {{/isListContainer}} + {{^isListContainer}} + {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}} + {{/isListContainer}} +{{/enumVars}}{{/allowableValues}} + + /** + * This override toString avoids using the enum var name and uses the actual api value instead. + * In cases the var name and value are different, the client would send incorrect enums to the server. + */ + override fun toString(): String { + return value{{^isString}}.toString(){{/isString}} + } +} diff --git a/boat-scaffold/src/main/templates/boat-android/enum_doc.mustache b/boat-scaffold/src/main/templates/boat-android/enum_doc.mustache new file mode 100644 index 000000000..fcb3d7e61 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/enum_doc.mustache @@ -0,0 +1,7 @@ +# {{classname}} + +## Enum + +{{#allowableValues}}{{#enumVars}} + * `{{name}}` (value: `{{{value}}}`) +{{/enumVars}}{{/allowableValues}} diff --git a/boat-scaffold/src/main/templates/boat-android/gradle-wrapper.jar b/boat-scaffold/src/main/templates/boat-android/gradle-wrapper.jar new file mode 100644 index 000000000..7454180f2 Binary files /dev/null and b/boat-scaffold/src/main/templates/boat-android/gradle-wrapper.jar differ diff --git a/boat-scaffold/src/main/templates/boat-android/gradle-wrapper.properties.mustache b/boat-scaffold/src/main/templates/boat-android/gradle-wrapper.properties.mustache new file mode 100644 index 000000000..7c08e4f06 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/gradle-wrapper.properties.mustache @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/gradle.properties.mustache b/boat-scaffold/src/main/templates/boat-android/gradle.properties.mustache new file mode 100644 index 000000000..3fcc6cfd3 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/gradle.properties.mustache @@ -0,0 +1,26 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx4g +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# +# https://youtrack.jetbrains.com/issue/KT-40750 +kapt.use.worker.api=false +kapt.incremental.apt=false +android.suppressUnsupportedCompileSdk=33 diff --git a/boat-scaffold/src/main/templates/boat-android/gradlew.bat.mustache b/boat-scaffold/src/main/templates/boat-android/gradlew.bat.mustache new file mode 100644 index 000000000..93e3f59f1 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/gradlew.bat.mustache @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/boat-scaffold/src/main/templates/boat-android/gradlew.mustache b/boat-scaffold/src/main/templates/boat-android/gradlew.mustache new file mode 100755 index 000000000..aeb74cbb4 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/gradlew.mustache @@ -0,0 +1,245 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/boat-scaffold/src/main/templates/boat-android/interface_opt_var.mustache b/boat-scaffold/src/main/templates/boat-android/interface_opt_var.mustache new file mode 100644 index 000000000..344a6c251 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/interface_opt_var.mustache @@ -0,0 +1,18 @@ +{{#description}} + /* {{{.}}} */ +{{/description}} + {{^multiplatform}} + {{#moshi}} + @Json(name = "{{{vendorExtensions.x-base-name-literal}}}") + {{/moshi}} + {{#gson}} + @get:SerializedName("{{{vendorExtensions.x-base-name-literal}}}") + {{/gson}} + {{#jackson}} + @get:JsonProperty("{{{vendorExtensions.x-base-name-literal}}}") + {{/jackson}} + {{#kotlinx_serialization}} + {{^isEnum}}{{^isArray}}{{^isPrimitiveType}}{{^isModel}}@Contextual {{/isModel}}{{/isPrimitiveType}}{{/isArray}}{{/isEnum}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") + {{/kotlinx_serialization}} + {{/multiplatform}} + {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") {{/multiplatform}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}? \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/interface_req_var.mustache b/boat-scaffold/src/main/templates/boat-android/interface_req_var.mustache new file mode 100644 index 000000000..743069ff5 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/interface_req_var.mustache @@ -0,0 +1,18 @@ +{{#description}} + /* {{{.}}} */ +{{/description}} + {{^multiplatform}} + {{#moshi}} + @Json(name = "{{{vendorExtensions.x-base-name-literal}}}") + {{/moshi}} + {{#gson}} + @get:SerializedName("{{{vendorExtensions.x-base-name-literal}}}") + {{/gson}} + {{#jackson}} + @get:JsonProperty("{{{vendorExtensions.x-base-name-literal}}}") + {{/jackson}} + {{#kotlinx_serialization}} + {{^isEnum}}{{^isArray}}{{^isPrimitiveType}}{{^isModel}}@Contextual {{/isModel}}{{/isPrimitiveType}}{{/isArray}}{{/isEnum}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") + {{/kotlinx_serialization}} + {{/multiplatform}} + {{#multiplatform}}@SerialName(value = "{{{vendorExtensions.x-base-name-literal}}}") @Required {{/multiplatform}}{{>modelMutable}} {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.{{#modelMutable}}Mutable{{/modelMutable}}List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{#kotlinx_serialization}}@Contextual {{/kotlinx_serialization}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{/isArray}}{{^isEnum}}{{^isArray}}{{{dataType}}}{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}.{{{nameInCamelCase}}}{{/isArray}}{{/isEnum}}{{#isNullable}}?{{/isNullable}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/licenseInfo.mustache b/boat-scaffold/src/main/templates/boat-android/licenseInfo.mustache new file mode 100644 index 000000000..3a547de74 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/licenseInfo.mustache @@ -0,0 +1,11 @@ +/** +* {{{appName}}} +* {{{appDescription}}} +* +* {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}} +* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/manifest.mustache b/boat-scaffold/src/main/templates/boat-android/manifest.mustache new file mode 100644 index 000000000..3eacac27a --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/manifest.mustache @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/model.mustache b/boat-scaffold/src/main/templates/boat-android/model.mustache new file mode 100644 index 000000000..abd168abc --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/model.mustache @@ -0,0 +1,11 @@ +{{>licenseInfo}} +package {{modelPackage}} + +{{#imports}}import {{import}} +{{/imports}} + +{{#models}} +{{#model}} +{{#isEnum}}{{>enum_class}}{{/isEnum}}{{^isEnum}}{{#isAlias}}typealias {{classname}} = {{{dataType}}}{{/isAlias}}{{^isAlias}}{{>data_class}}{{/isAlias}}{{/isEnum}} +{{/model}} +{{/models}} diff --git a/boat-scaffold/src/main/templates/boat-android/modelMutable.mustache b/boat-scaffold/src/main/templates/boat-android/modelMutable.mustache new file mode 100644 index 000000000..4c7f39007 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/modelMutable.mustache @@ -0,0 +1 @@ +{{#modelMutable}}var{{/modelMutable}}{{^modelMutable}}val{{/modelMutable}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/model_doc.mustache b/boat-scaffold/src/main/templates/boat-android/model_doc.mustache new file mode 100644 index 000000000..e3b718421 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/model_doc.mustache @@ -0,0 +1,3 @@ +{{#models}}{{#model}} +{{#isEnum}}{{>enum_doc}}{{/isEnum}}{{^isEnum}}{{>class_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/boat-scaffold/src/main/templates/boat-android/model_room.mustache b/boat-scaffold/src/main/templates/boat-android/model_room.mustache new file mode 100644 index 000000000..bb43e6bf8 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/model_room.mustache @@ -0,0 +1,38 @@ +{{>licenseInfo}} +package {{roomModelPackage}} + +import androidx.room.Entity +import androidx.room.Ignore +import androidx.room.PrimaryKey +import {{modelPackage}}.* + +{{#models}} +{{#model}} + +@Entity(tableName = "{{classname}}") +/** +* Room model for {{{description}}} +{{#allVars}} +* @param {{{name}}} {{{description}}} +{{/allVars}} +*/ +data class {{classname}}RoomModel ( + @PrimaryKey(autoGenerate = true) var roomTableId: Int, + {{#allVars}}{{#items.isPrimitiveType}}var {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{>model_room_init_var}}{{/isArray}}, + {{/items.isPrimitiveType}}{{/allVars}} + {{#allVars}}{{^isEnum}}{{^isArray}}var {{{name}}}: {{{dataType}}}{{>model_room_init_var}}, + {{/isArray}}{{/isEnum}}{{/allVars}} + {{#allVars}}{{#isEnum}}{{^isArray}}var {{{name}}}: {{classname}}.{{{nameInCamelCase}}}{{>model_room_init_var}}, + {{/isArray}}{{/isEnum}}{{/allVars}}) { +{{#allVars}}{{#isArray}}{{#isList}}{{^items.isPrimitiveType}} + @Ignore + {{^isNullable}}{{#required}}lateinit {{/required}}{{/isNullable}}var {{{name}}}: {{#isArray}}{{#isList}}kotlin.collections.List{{/isList}}{{^isList}}kotlin.Array{{/isList}}<{{^items.isEnum}}{{^items.isPrimitiveType}}{{^items.isModel}}{{/items.isModel}}{{/items.isPrimitiveType}}{{{items.dataType}}}{{/items.isEnum}}{{#items.isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/items.isEnum}}>{{>model_room_init_var}}{{/isArray}} +{{/items.isPrimitiveType}}{{/isList}}{{/isArray}}{{/allVars}} + {{^discriminator}}companion object { } + + fun toApiModel(): {{classname}} = {{classname}}( + {{#allVars}}{{name}} = this.{{name}}, + {{/allVars}}){{/discriminator}} +} +{{/model}} +{{/models}} diff --git a/boat-scaffold/src/main/templates/boat-android/model_room_init_var.mustache b/boat-scaffold/src/main/templates/boat-android/model_room_init_var.mustache new file mode 100644 index 000000000..3e6f299d3 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/model_room_init_var.mustache @@ -0,0 +1 @@ +{{#isNullable}}?{{/isNullable}}{{^required}}{{^isNullable}}?{{/isNullable}}{{/required}}{{#defaultvalue}} = {{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}{{#isNullable}} = null{{/isNullable}}{{^required}}{{^isNullable}} = null{{/isNullable}}{{/required}}{{/defaultvalue}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/queryParams.mustache b/boat-scaffold/src/main/templates/boat-android/queryParams.mustache new file mode 100644 index 000000000..6380ae769 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/queryParams.mustache @@ -0,0 +1,19 @@ +{{#queryParams}} + + if (params.{{{paramName}}} != null) { + queryParams["{{{paramName}}}"] = + {{#isContainer}} + {{#isExplode}} + //explode=true + (params.{{{paramName}}}{{^required}}?{{/required}}.toList(){{^required}}?{{/required}}.map { it.toString() } {{^required}}?: listOf(""){{/required}}) + {{/isExplode}} + {{^isExplode}} + //explode=false + listOf({{>api_parameter}}) + {{/isExplode}} + {{/isContainer}} + {{^isContainer}} + listOf({{>api_parameter}}) + {{/isContainer}} + } +{{/queryParams}} diff --git a/boat-scaffold/src/main/templates/boat-android/settings.gradle.mustache b/boat-scaffold/src/main/templates/boat-android/settings.gradle.mustache new file mode 100644 index 000000000..2a789fe8d --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/settings.gradle.mustache @@ -0,0 +1,2 @@ +{{#multiplatform}}enableFeaturePreview('GRADLE_METADATA'){{/multiplatform}} +rootProject.name = '{{artifactId}}' \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-android/typeInfoAnnotation.mustache b/boat-scaffold/src/main/templates/boat-android/typeInfoAnnotation.mustache new file mode 100644 index 000000000..6b3cb83b0 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-android/typeInfoAnnotation.mustache @@ -0,0 +1,6 @@ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true) +@JsonSubTypes( +{{#discriminator.mappedModels}} + JsonSubTypes.Type(value = {{modelName}}::class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"){{^-last}},{{/-last}} +{{/discriminator.mappedModels}} +) \ No newline at end of file