forked from loafle/openapi-generator-original
add @Generated annotation to all Java class templates
This commit is contained in:
parent
84ff5cfc87
commit
6fbb8ab1e0
@ -16,6 +16,7 @@ import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||
import io.swagger.util.Json;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -62,6 +63,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
List<File> files = new ArrayList<File>();
|
||||
try {
|
||||
config.processOpts();
|
||||
|
||||
config.additionalProperties().put("generatedTime", DateTime.now().toString());
|
||||
config.additionalProperties().put("generatorClass", config.getClass().toString());
|
||||
|
||||
if (swagger.getInfo() != null) {
|
||||
Info info = swagger.getInfo();
|
||||
if (info.getTitle() != null) {
|
||||
|
@ -40,6 +40,7 @@ import {{invokerPackage}}.auth.HttpBasicAuth;
|
||||
import {{invokerPackage}}.auth.ApiKeyAuth;
|
||||
import {{invokerPackage}}.auth.OAuth;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiClient {
|
||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class Configuration {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
|
@ -7,6 +7,7 @@ import com.fasterxml.jackson.core.JsonGenerator.Feature;
|
||||
|
||||
import com.fasterxml.jackson.datatype.joda.*;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class JsonUtil {
|
||||
public static ObjectMapper mapper;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class Pair {
|
||||
private String name = "";
|
||||
private String value = "";
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -21,6 +21,7 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
private ApiClient {{localVariablePrefix}}apiClient;
|
||||
|
@ -3,6 +3,7 @@ package {{invokerPackage}};
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private String message = null;
|
||||
|
@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
|
@ -5,6 +5,7 @@ import {{invokerPackage}}.Pair;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class OAuth implements Authentication {
|
||||
@Override
|
||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||
|
@ -0,0 +1 @@
|
||||
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* {{description}}
|
||||
**/{{/description}}
|
||||
@ApiModel(description = "{{{description}}}")
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
public enum {{datatypeWithEnum}} {
|
||||
|
@ -13,6 +13,7 @@ import {{modelPackage}}.*;
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* {{description}}
|
||||
**/{{/description}}
|
||||
@ApiModel(description = "{{{description}}}")
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
public enum {{datatypeWithEnum}} {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiException extends Exception{
|
||||
private int code;
|
||||
public ApiException (int code, String msg) {
|
||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiOriginFilter implements javax.servlet.Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response,
|
||||
|
@ -3,6 +3,7 @@ package {{apiPackage}};
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
@javax.xml.bind.annotation.XmlRootElement
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiResponseMessage {
|
||||
public static final int ERROR = 1;
|
||||
public static final int WARNING = 2;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class NotFoundException extends ApiException {
|
||||
private int code;
|
||||
public NotFoundException (int code, String msg) {
|
||||
|
@ -26,6 +26,7 @@ import javax.ws.rs.*;
|
||||
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
|
||||
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
||||
@io.swagger.annotations.Api(value = "/{{baseName}}", description = "the {{baseName}} API")
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}} {
|
||||
|
||||
|
@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public abstract class {{classname}}Service {
|
||||
{{#operation}}
|
||||
|
@ -3,6 +3,7 @@ package {{package}}.factories;
|
||||
import {{package}}.{{classname}}Service;
|
||||
import {{package}}.impl.{{classname}}ServiceImpl;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}}ServiceFactory {
|
||||
|
||||
private final static {{classname}}Service service = new {{classname}}ServiceImpl();
|
||||
|
@ -18,6 +18,7 @@ import com.sun.jersey.multipart.FormDataParam;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
{{>generatedAnnotation}}
|
||||
{{#operations}}
|
||||
public class {{classname}}ServiceImpl extends {{classname}}Service {
|
||||
{{#operation}}
|
||||
|
@ -0,0 +1 @@
|
||||
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* {{description}}
|
||||
**/{{/description}}
|
||||
@ApiModel(description = "{{{description}}}")
|
||||
{{>generatedAnnotation}}
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
public enum {{datatypeWithEnum}} {
|
||||
|
@ -0,0 +1 @@
|
||||
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
Loading…
x
Reference in New Issue
Block a user