Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove default implementation while generating code using swagger-codegen maven plugin

I have to generate code from yaml file, in my swagger maven plugin I put :

<configOptions>
  <java8>true</java8>
  <sourceFolder>src/main/java</sourceFolder>
  <interfaceOnly>true</interfaceOnly>
  <dateLibrary>java8</dateLibrary>
  <singleContentTypes>true</singleContentTypes>
</configOptions>

even if it says iinterfaceOnly>true however the codegen generate an interface with default implementation as follow:

@ApiOperation(value = "", nickname = "billetsFichiersHealthGet", notes = "Obtient l'état de santé de l'API. ", tags={  })
    @ApiResponses(value = { 
        @ApiResponse(code = 200, message = "OK"),
        @ApiResponse(code = 200, message = "Erreur", response = Error.class) })
    @RequestMapping(value = "/bills/health",
        produces = "application/json", 
        consumes = "",
        method = RequestMethod.GET)
    default ResponseEntity<Void> billetsFichiersHealthGet() {
        if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
        } else {
            log.warn("ObjectMapper or HttpServletRequest not configured in default BilletsApi interface so no example is generated");
        }
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
    }

How can I disable generation of default interface method and just have definition in interface and not default implementation.

When I remove the following two tags it works

<java8>true</java8> 
<dateLibrary>java8</dateLibrary>

However my models are using localdatetime and so I should be on java8 and cant remove these two tags really

Any Idea ?

like image 619
Mohamed Taboubi Avatar asked Nov 06 '22 17:11

Mohamed Taboubi


1 Answers

Please try:

<configOptions>
    <dateLibrary>java8</dateLibrary>
    <java8>true</java8>
    <defaultInterfaces>false</defaultInterfaces>
</configOptions>

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

like image 95
Ioan-Emanuel Grama Avatar answered Nov 15 '22 05:11

Ioan-Emanuel Grama