[Android][Volley] Build fixes (#18899)

* [android] Fix useAndroidMavenGradlePlugin type in template

* [android][volley] Use version variables in template

* [android][volley] Exclude httpclient

As it is incompatible with Android

* [android][volley] Resolve file conflict between httpcomponents modules

* [android] Update Gradle, the plugins, build tools

This fixes building with current Android Studio.

Android Gradle plugin version 8.0.0 was chosen for wider compatibility
with Android Studio versions (as far back as 2022.2.1).

The Maven plugin has been abandoned since the functionality is now
built in, and manual jar tasks are not necessary with it.

* [android] Regenerate samples
This commit is contained in:
Val Packett 2024-06-16 06:17:59 -03:00 committed by GitHub
parent 6f9ad31df3
commit 989a79811a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 259 additions and 289 deletions

View File

@ -459,8 +459,6 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
if (additionalProperties.containsKey(USE_ANDROID_MAVEN_GRADLE_PLUGIN)) { if (additionalProperties.containsKey(USE_ANDROID_MAVEN_GRADLE_PLUGIN)) {
this.setUseAndroidMavenGradlePlugin(Boolean.valueOf((String) additionalProperties this.setUseAndroidMavenGradlePlugin(Boolean.valueOf((String) additionalProperties
.get(USE_ANDROID_MAVEN_GRADLE_PLUGIN))); .get(USE_ANDROID_MAVEN_GRADLE_PLUGIN)));
} else {
additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin);
} }
if (additionalProperties.containsKey(ANDROID_GRADLE_VERSION)) { if (additionalProperties.containsKey(ANDROID_GRADLE_VERSION)) {
@ -483,8 +481,9 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
this.setSerializableModel(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString())); this.setSerializableModel(Boolean.valueOf(additionalProperties.get(CodegenConstants.SERIALIZABLE_MODEL).toString()));
} }
// need to put back serializableModel (boolean) into additionalProperties as value in additionalProperties is string // need to put back boolean properties into additionalProperties as the values in additionalProperties are strings
additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel); additionalProperties.put(CodegenConstants.SERIALIZABLE_MODEL, serializableModel);
additionalProperties.put(USE_ANDROID_MAVEN_GRADLE_PLUGIN, useAndroidMavenGradlePlugin);
//make api and model doc path available in mustache template //make api and model doc path available in mustache template
additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("apiDocPath", apiDocPath);
@ -524,7 +523,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
// supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle")); supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle"));
supportingFiles.add(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); supportingFiles.add(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml"));
supportingFiles.add(new SupportingFile("apiInvoker.mustache", supportingFiles.add(new SupportingFile("apiInvoker.mustache",

View File

@ -1,50 +1,26 @@
{{#useAndroidMavenGradlePlugin}} plugins {
group = '{{groupId}}' {{#androidGradleVersion}}
project.version = '{{artifactVersion}}' id 'com.android.library' version '{{{.}}}'
{{/useAndroidMavenGradlePlugin}} {{/androidGradleVersion}}
{{^androidGradleVersion}}
buildscript { id 'com.android.library' version '8.0.0'
repositories { {{/androidGradleVersion}}
maven { url "https://repo1.maven.org/maven2" } id 'maven-publish'
jcenter()
}
dependencies {
{{#androidGradleVersion}}
classpath 'com.android.tools.build:gradle:{{{.}}}'
{{/androidGradleVersion}}
{{^androidGradleVersion}}
classpath 'com.android.tools.build:gradle:2.3.+'
{{/androidGradleVersion}}
{{#useAndroidMavenGradlePlugin}}
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
{{/useAndroidMavenGradlePlugin}}
}
} }
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.library'
{{#useAndroidMavenGradlePlugin}}
apply plugin: 'com.github.dcendents.android-maven'
{{/useAndroidMavenGradlePlugin}}
android { android {
namespace "{{invokerPackage}}"
{{#androidSdkVersion}} {{#androidSdkVersion}}
compileSdkVersion {{{.}}} compileSdkVersion {{{.}}}
{{/androidSdkVersion}} {{/androidSdkVersion}}
{{^androidSdkVersion}} {{^androidSdkVersion}}
compileSdkVersion 25 compileSdkVersion 33
{{/androidSdkVersion}} {{/androidSdkVersion}}
{{#androidBuildToolsVersion}} {{#androidBuildToolsVersion}}
buildToolsVersion '{{{.}}}' buildToolsVersion '{{{.}}}'
{{/androidBuildToolsVersion}} {{/androidBuildToolsVersion}}
{{^androidBuildToolsVersion}} {{^androidBuildToolsVersion}}
buildToolsVersion '25.0.2' buildToolsVersion '34.0.0'
{{/androidBuildToolsVersion}} {{/androidBuildToolsVersion}}
useLibrary 'org.apache.http.legacy' useLibrary 'org.apache.http.legacy'
defaultConfig { defaultConfig {
@ -53,27 +29,20 @@ android {
targetSdkVersion {{{.}}} targetSdkVersion {{{.}}}
{{/androidSdkVersion}} {{/androidSdkVersion}}
{{^androidSdkVersion}} {{^androidSdkVersion}}
targetSdkVersion 25 targetSdkVersion 33
{{/androidSdkVersion}} {{/androidSdkVersion}}
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
publishing {
// Rename the aar correctly singleVariant('release') {
libraryVariants.all { variant -> withSourcesJar()
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
} }
} }
} }
ext { ext {
swagger_annotations_version = "1.6.6" swagger_annotations_version = "1.6.6"
gson_version = "2.10.1" gson_version = "2.10.1"
@ -83,38 +52,29 @@ ext {
} }
dependencies { dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version" implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.gson:gson:$gson_version" implementation "com.google.code.gson:gson:$gson_version"
compile "org.apache.httpcomponents:httpcore:$httpcore_version" implementation "org.apache.httpcomponents:httpcore:$httpcore_version"
compile "org.apache.httpcomponents:httpclient:$httpclient_version" implementation "org.apache.httpcomponents:httpclient:$httpclient_version"
compile ("org.apache.httpcomponents:httpcore:$httpcore_version") { implementation ("org.apache.httpcomponents:httpcore:$httpcore_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient') exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
} }
compile ("org.apache.httpcomponents:httpmime:$httpclient_version") { implementation ("org.apache.httpcomponents:httpmime:$httpclient_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient') exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
} }
testCompile "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
} }
afterEvaluate { publishing {
android.libraryVariants.all { variant -> publications {
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar release(MavenPublication) {
task.description = "Create jar artifact for ${variant.name}" groupId = '{{groupId}}'
task.dependsOn variant.javaCompile artifactId = '{{artifactId}}'
task.from variant.javaCompile.destinationDirectory version = '{{artifactVersion}}'
task.destinationDirectory = project.file("${project.buildDir}/outputs/jar")
task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" afterEvaluate {
artifacts.add('archives', task); from components.release
}
}
} }
} }
{{#useAndroidMavenGradlePlugin}}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
{{/useAndroidMavenGradlePlugin}}

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -1,44 +1,35 @@
{{#useAndroidMavenGradlePlugin}} plugins {
group = '{{groupId}}' {{#androidGradleVersion}}
project.version = '{{artifactVersion}}' id 'com.android.library' version '{{{.}}}'
{{/useAndroidMavenGradlePlugin}} {{/androidGradleVersion}}
{{^androidGradleVersion}}
buildscript { id 'com.android.library' version '8.0.0'
repositories { {{/androidGradleVersion}}
mavenLocal() id 'maven-publish'
google()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.+'
{{#useAndroidMavenGradlePlugin}}
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
{{/useAndroidMavenGradlePlugin}}
}
} }
allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: 'com.android.library'
{{#useAndroidMavenGradlePlugin}}
apply plugin: 'com.github.dcendents.android-maven'
{{/useAndroidMavenGradlePlugin}}
android { android {
compileSdkVersion 26 namespace "{{invokerPackage}}"
buildToolsVersion '28.0.3' {{#androidSdkVersion}}
compileSdkVersion {{{.}}}
{{/androidSdkVersion}}
{{^androidSdkVersion}}
compileSdkVersion 33
{{/androidSdkVersion}}
{{#androidBuildToolsVersion}}
buildToolsVersion '{{{.}}}'
{{/androidBuildToolsVersion}}
{{^androidBuildToolsVersion}}
buildToolsVersion '34.0.0'
{{/androidBuildToolsVersion}}
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 26 {{#androidSdkVersion}}
targetSdkVersion {{{.}}}
{{/androidSdkVersion}}
{{^androidSdkVersion}}
targetSdkVersion 33
{{/androidSdkVersion}}
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
@ -47,24 +38,23 @@ android {
lintOptions { lintOptions {
abortOnError false abortOnError false
} }
packagingOptions {
// Rename the aar correctly resources.excludes += "META-INF/DEPENDENCIES"
libraryVariants.all { variant ->
variant.outputs.all { output ->
if (outputFile != null && outputFileName.endsWith('.aar')) {
outputFileName = "${archivesBaseName}-${version}.aar"
}
}
} }
testOptions { testOptions {
unitTests.returnDefaultValues = true unitTests.returnDefaultValues = true
} }
publishing {
singleVariant('release') {
withSourcesJar()
}
}
} }
ext { ext {
swagger_annotations_version = "1.6.6" swagger_annotations_version = "1.6.6"
gson_version = "2.10.1" gson_version = "2.10.1"
httpcore_version = "4.4.16"
httpmime_version = "4.5.14" httpmime_version = "4.5.14"
volley_version = "1.2.1" volley_version = "1.2.1"
junit_version = "4.13.2" junit_version = "4.13.2"
@ -75,32 +65,28 @@ ext {
dependencies { dependencies {
implementation "io.swagger:swagger-annotations:$swagger_annotations_version" implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
implementation "com.google.code.gson:gson:$gson_version" implementation "com.google.code.gson:gson:$gson_version"
implementation "org.apache.httpcomponents:httpmime:$httpmime_version" implementation ("org.apache.httpcomponents:httpcore:$httpcore_version") {
exclude(group: "org.apache.httpcomponents", module: "httpclient")
}
implementation ("org.apache.httpcomponents:httpmime:$httpmime_version") {
exclude(group: "org.apache.httpcomponents", module: "httpclient")
}
implementation "com.android.volley:volley:${volley_version}" implementation "com.android.volley:volley:${volley_version}"
testImplementation "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
testImplementation "org.robolectric:robolectric:${robolectric_version}" testImplementation "org.robolectric:robolectric:${robolectric_version}"
testImplementation "net.jodah:concurrentunit:${concurrent_unit_version}" testImplementation "net.jodah:concurrentunit:${concurrent_unit_version}"
} }
afterEvaluate { publishing {
android.libraryVariants.all { variant -> publications {
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar release(MavenPublication) {
task.description = "Create jar artifact for ${variant.name}" groupId = '{{groupId}}'
task.dependsOn variant.javaCompile artifactId = '{{artifactId}}'
task.from variant.javaCompile.destinationDirectory version = '{{artifactVersion}}'
task.destinationDirectory = project.file("${project.buildDir}/outputs/jar")
task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" afterEvaluate {
artifacts.add('archives', task); from components.release
}
}
} }
} }
{{#useAndroidMavenGradlePlugin}}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
{{/useAndroidMavenGradlePlugin}}

View File

@ -1 +1,17 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "{{artifactId}}" rootProject.name = "{{artifactId}}"

View File

@ -1 +1 @@
6.0.0-SNAPSHOT 7.7.0-SNAPSHOT

View File

@ -117,13 +117,6 @@ Class | Method | HTTP request | Description
## Documentation for Authorization ## Documentation for Authorization
Authentication schemes defined for the API: Authentication schemes defined for the API:
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### petstore_auth ### petstore_auth
@ -134,6 +127,13 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account - write:pets: modify pets in your account
- read:pets: read your pets - read:pets: read your pets
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Recommendation ## Recommendation

View File

@ -1,92 +1,60 @@
group = 'org.openapitools' plugins {
project.version = '1.0.0' id 'com.android.library' version '8.0.0'
id 'maven-publish'
buildscript {
repositories {
maven { url "https://repo1.maven.org/maven2" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
} }
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android { android {
compileSdkVersion 25 namespace "org.openapitools.client"
buildToolsVersion '25.0.2' compileSdkVersion 33
buildToolsVersion '34.0.0'
useLibrary 'org.apache.http.legacy' useLibrary 'org.apache.http.legacy'
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 25 targetSdkVersion 33
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
publishing {
// Rename the aar correctly singleVariant('release') {
libraryVariants.all { variant -> withSourcesJar()
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
} }
} }
} }
ext { ext {
swagger_annotations_version = "1.6.6" swagger_annotations_version = "1.6.6"
gson_version = "2.8.9" gson_version = "2.10.1"
httpclient_version = "4.5.13" httpclient_version = "4.5.13"
httpcore_version = "4.4.4" httpcore_version = "4.4.4"
junit_version = "4.13" junit_version = "4.13"
} }
dependencies { dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version" implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.gson:gson:$gson_version" implementation "com.google.code.gson:gson:$gson_version"
compile "org.apache.httpcomponents:httpcore:$httpcore_version" implementation "org.apache.httpcomponents:httpcore:$httpcore_version"
compile "org.apache.httpcomponents:httpclient:$httpclient_version" implementation "org.apache.httpcomponents:httpclient:$httpclient_version"
compile ("org.apache.httpcomponents:httpcore:$httpcore_version") { implementation ("org.apache.httpcomponents:httpcore:$httpcore_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient') exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
} }
compile ("org.apache.httpcomponents:httpmime:$httpclient_version") { implementation ("org.apache.httpcomponents:httpmime:$httpclient_version") {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient') exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
} }
testCompile "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
} }
afterEvaluate { publishing {
android.libraryVariants.all { variant -> publications {
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar release(MavenPublication) {
task.description = "Create jar artifact for ${variant.name}" groupId = 'org.openapitools'
task.dependsOn variant.javaCompile artifactId = 'openapi-android-client'
task.from variant.javaCompile.destinationDir version = '1.0.0'
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" afterEvaluate {
artifacts.add('archives', task); from components.release
}
}
} }
} }
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -39,12 +39,12 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version> <version>2.12</version>
<configuration> <configuration>
<systemProperties> <systemPropertyVariables>
<property> <property>
<name>loggerPath</name> <name>loggerPath</name>
<value>conf/log4j.properties</value> <value>conf/log4j.properties</value>
</property> </property>
</systemProperties> </systemPropertyVariables>
<argLine>-Xms512m -Xmx1500m</argLine> <argLine>-Xms512m -Xmx1500m</argLine>
<parallel>methods</parallel> <parallel>methods</parallel>
<forkMode>pertest</forkMode> <forkMode>pertest</forkMode>
@ -172,7 +172,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-core-version>1.6.6</swagger-core-version> <swagger-core-version>1.6.6</swagger-core-version>
<gson-version>2.8.9</gson-version> <gson-version>2.10.1</gson-version>
<maven-plugin-version>1.0.0</maven-plugin-version> <maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.13.2</junit-version> <junit-version>4.13.2</junit-version>
<httpclient-version>4.5.13</httpclient-version> <httpclient-version>4.5.13</httpclient-version>

View File

@ -1 +1,17 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "openapi-android-client" rootProject.name = "openapi-android-client"

View File

@ -38,4 +38,12 @@ public class ApiException extends Exception {
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
@Override
public String toString() {
return "ApiException{" +
"code=" + code +
", message=" + message +
'}';
}
} }

View File

@ -22,6 +22,7 @@ import java.util.*;
import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.ApiResponse;
import java.io.File; import java.io.File;
import java.util.*;
import org.openapitools.client.model.Pet; import org.openapitools.client.model.Pet;
import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.MultipartEntityBuilder;

View File

@ -16,6 +16,7 @@ gradle/wrapper/gradle-wrapper.properties
gradlew gradlew
gradlew.bat gradlew.bat
pom.xml pom.xml
settings.gradle
src/main/AndroidManifest.xml src/main/AndroidManifest.xml
src/main/java/org/openapitools/client/ApiException.java src/main/java/org/openapitools/client/ApiException.java
src/main/java/org/openapitools/client/ApiInvoker.java src/main/java/org/openapitools/client/ApiInvoker.java

View File

@ -1 +1 @@
6.0.0-SNAPSHOT 7.7.0-SNAPSHOT

View File

@ -117,13 +117,6 @@ Class | Method | HTTP request | Description
## Documentation for Authorization ## Documentation for Authorization
Authentication schemes defined for the API: Authentication schemes defined for the API:
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### petstore_auth ### petstore_auth
@ -134,6 +127,13 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account - write:pets: modify pets in your account
- read:pets: read your pets - read:pets: read your pets
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Recommendation ## Recommendation

View File

@ -1,38 +1,15 @@
group = 'org.openapitools' plugins {
project.version = '1.0.0' id 'com.android.library' version '8.0.0'
id 'maven-publish'
buildscript {
repositories {
mavenLocal()
google()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
} }
allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android { android {
compileSdkVersion 26 namespace "org.openapitools.client"
buildToolsVersion '28.0.3' compileSdkVersion 33
buildToolsVersion '34.0.0'
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 26 targetSdkVersion 33
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
@ -41,25 +18,24 @@ android {
lintOptions { lintOptions {
abortOnError false abortOnError false
} }
packagingOptions {
// Rename the aar correctly resources.excludes += "META-INF/DEPENDENCIES"
libraryVariants.all { variant ->
variant.outputs.all { output ->
if (outputFile != null && outputFileName.endsWith('.aar')) {
outputFileName = "${archivesBaseName}-${version}.aar"
}
}
} }
testOptions { testOptions {
unitTests.returnDefaultValues = true unitTests.returnDefaultValues = true
} }
publishing {
singleVariant('release') {
withSourcesJar()
}
}
} }
ext { ext {
swagger_annotations_version = "1.6.6" swagger_annotations_version = "1.6.6"
gson_version = "2.8.9" gson_version = "2.10.1"
httpmime_version = "4.5.13" httpcore_version = "4.4.16"
httpmime_version = "4.5.14"
volley_version = "1.2.1" volley_version = "1.2.1"
junit_version = "4.13.2" junit_version = "4.13.2"
robolectric_version = "4.5.1" robolectric_version = "4.5.1"
@ -69,30 +45,28 @@ ext {
dependencies { dependencies {
implementation "io.swagger:swagger-annotations:$swagger_annotations_version" implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
implementation "com.google.code.gson:gson:$gson_version" implementation "com.google.code.gson:gson:$gson_version"
implementation "org.apache.httpcomponents:httpmime:$httpmime_version" implementation ("org.apache.httpcomponents:httpcore:$httpcore_version") {
exclude(group: "org.apache.httpcomponents", module: "httpclient")
}
implementation ("org.apache.httpcomponents:httpmime:$httpmime_version") {
exclude(group: "org.apache.httpcomponents", module: "httpclient")
}
implementation "com.android.volley:volley:${volley_version}" implementation "com.android.volley:volley:${volley_version}"
testImplementation "junit:junit:$junit_version" testImplementation "junit:junit:$junit_version"
testImplementation "org.robolectric:robolectric:${robolectric_version}" testImplementation "org.robolectric:robolectric:${robolectric_version}"
testImplementation "net.jodah:concurrentunit:${concurrent_unit_version}" testImplementation "net.jodah:concurrentunit:${concurrent_unit_version}"
} }
afterEvaluate { publishing {
android.libraryVariants.all { variant -> publications {
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar release(MavenPublication) {
task.description = "Create jar artifact for ${variant.name}" groupId = 'org.openapitools'
task.dependsOn variant.javaCompile artifactId = 'petstore-android-volley'
task.from variant.javaCompile.destinationDir version = '1.0.0'
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar" afterEvaluate {
artifacts.add('archives', task); from components.release
}
}
} }
} }
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}

View File

@ -0,0 +1,15 @@
## 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.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
#Sun Jun 16 04:30:24 ART 2024
#android.enableJetifier=true
#android.useAndroidX=true

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -54,8 +54,8 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-annotations-version>1.6.6</swagger-annotations-version> <swagger-annotations-version>1.6.6</swagger-annotations-version>
<httpcomponents-httpmime-version>4.5.13</httpcomponents-httpmime-version> <httpcomponents-httpmime-version>4.5.14</httpcomponents-httpmime-version>
<google-code-gson-version>2.8.9</google-code-gson-version> <google-code-gson-version>2.10.1</google-code-gson-version>
<volley-library-version>1.2.1</volley-library-version> <volley-library-version>1.2.1</volley-library-version>
<android-platform-version>4.1.1.4</android-platform-version> <android-platform-version>4.1.1.4</android-platform-version>
</properties> </properties>

View File

@ -0,0 +1,17 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "petstore-android-volley"

View File

@ -58,4 +58,12 @@ public class ApiException extends Exception {
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
@Override
public String toString() {
return "ApiException{" +
"code=" + code +
", message=" + message +
'}';
}
} }

View File

@ -203,9 +203,9 @@ public class ApiInvoker {
// Setup authentications (key: authentication name, value: authentication). // Setup authentications (key: authentication name, value: authentication).
INSTANCE.authentications = new HashMap<String, Authentication>(); INSTANCE.authentications = new HashMap<String, Authentication>();
INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// TODO: comment out below as OAuth does not exist // TODO: comment out below as OAuth does not exist
//INSTANCE.authentications.put("petstore_auth", new OAuth()); //INSTANCE.authentications.put("petstore_auth", new OAuth());
INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications); INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications);
} }

View File

@ -25,6 +25,7 @@ import com.android.volley.VolleyError;
import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.ApiResponse;
import java.io.File; import java.io.File;
import java.util.*;
import org.openapitools.client.model.Pet; import org.openapitools.client.model.Pet;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;