[Java][jaxrs-jersey] unnecessary multipart imports in generated code
Created by: kingofdisasterr
Description
if the java jaxrs-jersey server code is generated from a model which doesn't need the jersey multipart feature, the multipart packages are imported anyway.
openapi-generator version
openapi-generator 3.3.2
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: foo
description: >-
bar
version: 1.1.0
paths:
/foo/v1/bar:
get:
summary: read foo bar
operationId: getFooBar
responses:
200:
content:
application/json:
schema:
default:
description: all went ok
Command line used for generation
Java -jar openapi-generator-cli-3.3.2.jar generate -i /foobar.yaml -g jaxrs-jersey -o /foobar
java output
package fooBar.impl;
import fooBar.*;
import fooBar.model.*;
import java.util.List;
import fooBar.NotFoundException;
import java.io.InputStream;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.validation.constraints.*;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = "2018-11-12T10:51:46.203+01:00[Europe/Berlin]")
public class FooApiServiceImpl extends FooApiService {
@Override
public Response getFooBar(SecurityContext securityContext) throws NotFoundException {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
}
Suggest a fix/enhancement
in the templates should be a check around the multipart imports:
{{#useMultipartFeature}}
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
{{/useMultipartFeature}}