-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Java 1.6 #3568
Comments
What about running swagger generator via docker instead? |
Just to make sure: Do you need Java 6 for running Codegen, or for running the generated code? |
I don't think going to java 6 makes sense. It's been EOL'd for a while now, and I don't want to constrain updates in the core code to not use java 7 features. As @ePaul said, you can certainly use generated clients with java6 (for now). |
Thanks for the clarifying questions and responses. I'm trying to get a generated client to work in Java 6. The generated client code includes java.util.Objects, java.util.Objects.equals, and java.util.Objects.hash which are not in Java 6. I have tried playing around with targetCompatibility to no avail. Is there something I'm missing that will create a Java 6 set of compatible client Java classes? The fork: https://github.com/zambien/swagger-codegen Replaces all of the java.util.Objects java code and mustache files with google guava as well as including guava where it is required. |
I guess for the generated Java files (i.e. the Mustache files) we can/should do that, I wouldn't do it for the generator code (i.e. CodegenModel and friends). Maybe we can introduce an option for the equals/hashCode implementations, whether to use Java 8 or Guava, like we are doing for JodaTime vs. Java8 time? |
I think that is an excellent idea. I was making changes as I was starting to understand the project which is why I didn't create a PR just yet. |
I'm running into this issue as well with The reason we use Java instead of Android for the codegen language, is we want to use retrofit2, which is not an option for the android generator (I'm not sure why). However, I just tried generating for Android and it did not use the Java 7 |
@ashughes if we provide an option to remove |
@wing328 I think so. We just started using Swagger, so we haven't used it extensively yet, but that's the only Android compatibility issue we've run into so far. |
We should probably have a "javaVersion" option that would provide some defaults:
|
I agree with @cbornet. However, on Android the default date lib should be ThreeTenABP. Maybe there could be an "androidVersion" or "androidMinSdk" option with defaults:
|
Or "sdk" which can be java6, java7,java8 and android. |
Right, but it would also be good to have different Android versions, since on API 19+ it's okay to use java.util.Objects. |
I've added an option Please pull the latest to give it a try. |
We have a similar issue with wishing to run generated client code on Java6 (in our case jersey2 but it doesn't seem to make a difference). So, this would be perfect for us. I tried the latest and found that equals and hashcode methods have been removed from the model classes. Excellent. However, there are a few remaining issues:
|
Thanks for doing a test. I'm working on 1 and 3
How should that be changed to conform to Java6? |
It's relying on a copy method. I guess options would be to provide an On Tue, 18 Oct 2016 7:02 pm wing328 notifications@github.com wrote:
|
I've fixed 1 & 3 via #4021. Do you have cycle to contribute the suggested fix? |
#4021 merged into master. |
I think given we already have commons.io as a dependency hopefully we should be able to trivially substitute Files.copy with FileUtils.copyFile for Java6. I'll take a look tomorrow. |
@k1w1m8 thanks for offering help to contribute the enhancement. |
Just added new PR #4039 with idk6 compatible hashCode and equals implementation. |
PR merged. Thanks @scannerscan for the contribution. |
* upstream/master: (43 commits) [Java] BeanValidation + JAXRS CXF server generator (swagger-api#4068) update JS petstore samples nancyfx basePath => modulePath toggle (swagger-api#4053) Throw an Error object instead of a string [Qt5/C++] Arrays of primitive types fix (swagger-api#4046) fix NancyFX string parser (swagger-api#4048) Fix sanitizeTag to retain numbers and underscore in tag names add test for java6 jersey2 client hashCode and equals support for jdk6 for jersey2 (swagger-api#4039) update gitignore to include PetStore.pro.user increase timeout value for qt5 petstore test update undertow readme Java6 support for jersey2 (swagger-api#4033) [java] Allow setting test folder fix reserved word handling in model name (sinatra) better handling of reserved words for sintatra, dart improvements based on swagger-api#3568 (swagger-api#4021) [csharp] add missing anchor tags in readme (swagger-api#4019) Issue 3651 (swagger-api#4014) Added company (swagger-api#4015) ...
Description
Would it be acceptable to add Java 1.6 support to this project? I have created a fork at zambien/swagger-codegen which has most of the changes needed to do this (replace java.util.Objects and associated code/mustaches with google guava). I work in an environment which runs Java 6 servers and there is not an opportunity to upgrade them unfortunately.
Swagger-codegen version
master
Suggest a Fix
Please take a look at my fork and let me know if a pull request to include Java 1.6 support is acceptable.
The text was updated successfully, but these errors were encountered: