Open tgraupmann opened 7 years ago
@tgraupmann can you try using the Java API client instead to see if it works better for you?
https://github.com/swagger-api/swagger-codegen/wiki/FAQ#how-can-i-generate-an-android-sdk
I can confirm that the JAVA exported code when imported into Android Studio and run on Windows works as expected.
I will attempt on Android to do further testing...
Found that the JAVA export uses okhttp1 and needed to upgrade to okhttp3. But after that I'm seeing responses on Android.
The Client methods need to be called from a Thread to avoid a networking on main thread exception.
I automated the JAVA source fixes to upgrade to okhttp3 in another Windows.Forms app. https://github.com/tgraupmann/SwaggerJavaClientFixer
Progress...
These are the changes that I made to make the Swagger JAVA client work on Android. https://github.com/tgraupmann/SwaggerJavaExportFixes/commit/908d7dbf4ebd30087ecb7dc5387b0893de70843b
The https://github.com/tgraupmann/SwaggerJavaClientFixer automates fixing the JAVA source.
Editing the Gradle build and adding the SwaggerApp module was done manually.
I ran into some JSON date parsing issues related to: http://stackoverflow.com/questions/21839143/jodatime-string-yyyy-mm-ddthhmmss-z-to-datetime
I altered io.swagger.client.JSON.java
to use the suggested DateTime parser.
@Override
public DateTime read(JsonReader in) throws IOException {
switch (in.peek()) {
case NULL:
in.nextNull();
return null;
default:
String date = in.nextString();
//return formatter.parseDateTime(date); //old
return DateTime.parse(date, ISODateTimeFormat.dateTimeParser());
}
}
Description
I'm using the Swagger Android export to autogenerate the structures and client code for a REST API. I made a tool to apply some JAVA syntax fixes to get the Android Studio project to compile. I have some Gradle compile issues (upgrade, and dependency) that I apply so that the APK can be created. And then when using the EndPoint, I'm getting timeouts and the client doesn't appear to connect at all. This could either be a client, or dependency issue.
Swagger-codegen version
I'm using the online editor so maybe 2.0? http://editor.swagger.io/#/
Swagger declaration file content or url
In the Swagger editor, load the URL: https://polling.arena.razerzone.com/swagger/docs/v1
Command line used for generation
Generate Client for Android.
Steps to reproduce
Load the url in the editor.
Generate the Android Client.
Unzip and open the project in Android Studio.
Upgrade gradle when prompted.
I've made a temporary Windows.Form tool that you run on the root Android project directory to fix the enum and Object syntax errors.
https://github.com/tgraupmann/SwaggerAndroidClientFixer
Rebuild the project.
At this point Gradle warnings will appear. Are these warnings important?
Related issues
https://github.com/swagger-api/swagger-codegen/issues/4279 https://github.com/swagger-api/swagger-codegen/issues/4278
Suggest a Fix
I need insight to what might be happening.
I'm using a tool to make syntax fixes when I should fix the raw export templates.
From debugging, it looks like the Swagger client puts a request in the queue and waits for the request to complete. The request might not actually happen...