Swagger codegen Maven plugin - generate ResponseEntity?

Viewed 454

Is there a way to tell the Swagger codegen Maven plugin that, when it generates clientside API definitions (i.e. consumers of ApiClient), it should generate method signatures using org.springframework.http.ResponseEntity<T> as the return type, where T is the actual type being returned?

I would like to be able to check for instance the HTTP status codes when invoking methods on the server.

To make it explicit what I want, rather than

public void deleteById(String id);

I want

public ResponseEntity<Void> deleteById(String id);

I'm using 2.3.1 of the plugin. Current configuration:

<execution>
    <id>generate-client</id>
    <phase>generate-sources</phase>
    <goals>
        <goal>generate</goal>
    </goals>
    <configuration>
        <inputSpec>${project.basedir}/src/main/resources/swagger.json</inputSpec>
        <language>java</language>
        <library>resttemplate</library>
        <addCompileSourceRoot>true</addCompileSourceRoot>
        <modelPackage>com.my.group.model</modelPackage>
        <apiPackage>com.my.group.api</apiPackage>
        <invokerPackage>com.my.group.invoker</invokerPackage>
        <configOptions>
            <sourceFolder>src/gen/java/main</sourceFolder>
            <dateLibrary>java8</dateLibrary>
            <java8>true</java8>
            <groupId>com.my.group</groupId>
            <artifactId>client</artifactId>
        </configOptions>
    </configuration>
</execution>
0 Answers
Related