Swagger-codegen: [JAVA/Spring] Using java8 <dateLibrary> causes default interface implementations regarding <java8>false</java8>

Created on 20 Oct 2018  路  2Comments  路  Source: swagger-api/swagger-codegen

Description


When enabling <dateLibrary>java8</dateLibrary> in <configOptions>, default methods are created in API contract interface. Even if I set the value <java8>false</java8>.

According to the help, <java8> option produces the aforementioned default interface methods:

java8
use java8 default interface (Default: false)

I want the advantage of Java 8 types (date,...) but not default interface which is not very convenient as does not enforce to implement the API contract in controllers. I am using the <interfaceOnly>true option as I am only interested in generating the API contract and model classes.

Swagger-codegen version

3.0.2

<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.2</version>
Command line used for generation

mvn compile

Related issues/PRs

https://github.com/swagger-api/swagger-codegen/issues/8045

Suggest a fix/enhancement

Enable a dedicated option for default interface independent of other Java 8 feature such as Optional class, Date library or others, or at least fix it so we can use a mix of options such as:

<useOptional>true</useOptional>
<dateLibrary>java8</dateLibrary>
<java8>false</java8>  <!-- disable default interface -->

Most helpful comment

fixed by swagger-api/swagger-codegen-generators/pull/490.

use additional properties java8=true and defaultInterfaces=false not to generate default interfaces

All 2 comments

swagger-codegen 3.0.4 also outputs two java8 options:

swagger-codegen config-help -l spring
...
    java8
        Option. Use Java8 classes instead of third party equivalents
            true - Use Java 8 classes such as Base64
            false - Various third party libraries as needed
...
    java8
        use java8 default interface (Default: false)
...

fixed by swagger-api/swagger-codegen-generators/pull/490.

use additional properties java8=true and defaultInterfaces=false not to generate default interfaces

Was this page helpful?
0 / 5 - 0 ratings