diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaMSF4JServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaMSF4JServerCodegen.java new file mode 100644 index 00000000000..09f5276afc3 --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaMSF4JServerCodegen.java @@ -0,0 +1,152 @@ +package io.swagger.codegen.languages; + +import io.swagger.codegen.*; +import io.swagger.models.Operation; + +import java.util.*; + +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; + +public class JavaMSF4JServerCodegen extends AbstractJavaJAXRSServerCodegen { + + protected static final String LIBRARY_JERSEY1 = "jersey1"; + protected static final String LIBRARY_JERSEY2 = "jersey2"; + + + public static final String DEFAULT_LIBRARY = LIBRARY_JERSEY2; + + public JavaMSF4JServerCodegen() { + super(); + outputFolder = "generated-code/JavaJaxRS-Jersey"; + apiTemplateFiles.put("apiService.mustache", ".java"); + apiTemplateFiles.put("apiServiceImpl.mustache", ".java"); + apiTemplateFiles.put("apiServiceFactory.mustache", ".java"); + apiTestTemplateFiles.clear(); + modelDocTemplateFiles.remove("model_doc.mustache"); + apiDocTemplateFiles.remove("api_doc.mustache"); + embeddedTemplateDir = templateDir = "MSF4J"; + CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); + supportedLibraries.put(LIBRARY_JERSEY1, "Jersey core 1.x"); + supportedLibraries.put(LIBRARY_JERSEY2, "Jersey core 2.x"); + library.setEnum(supportedLibraries); + library.setDefault(DEFAULT_LIBRARY); + cliOptions.add(library); + + } + + @Override + public String getName() + { + return "msf4j"; + } + + @Override + public String getHelp() + { + return "Generates a Java Micro Service based on WSO2 Microservices Framework for Java (MSF4J)"; + } + + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + super.postProcessModelProperty(model, property); + if("null".equals(property.example)) { + property.example = null; + } + + //Add imports for Jackson + if(!BooleanUtils.toBoolean(model.isEnum)) { + model.imports.add("JsonProperty"); + + if(BooleanUtils.toBoolean(model.hasEnums)) { + model.imports.add("JsonValue"); + } + } + } + + @Override + public void processOpts() { + super.processOpts(); + + // use default library if unset + if (StringUtils.isEmpty(library)) { + setLibrary(DEFAULT_LIBRARY); + } + + if ( additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) { + implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER); + } + + if ("joda".equals(dateLibrary)) { + supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java")); + supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java")); + } else if ( dateLibrary.startsWith("java8") ) { + supportingFiles.add(new SupportingFile("OffsetDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "OffsetDateTimeProvider.java")); + supportingFiles.add(new SupportingFile("LocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java")); + } + + writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml")); + writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("ApiException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java")); + supportingFiles.add(new SupportingFile("ApiOriginFilter.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiOriginFilter.java")); + supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java")); + supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java")); + supportingFiles.add(new SupportingFile("jacksonJsonProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JacksonJsonProvider.java")); + supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "RFC3339DateFormat.java")); + //writeOptional(outputFolder, new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java")); + //writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml")); + supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java")); + supportingFiles.add(new SupportingFile("Application.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "Application.java")); + } + + @Override + public Map postProcessModelsEnum(Map objs) { + objs = super.postProcessModelsEnum(objs); + + //Add imports for Jackson + List> imports = (List>)objs.get("imports"); + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _mo; + CodegenModel cm = (CodegenModel) mo.get("model"); + // for enum model + if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) { + cm.imports.add(importMapping.get("JsonValue")); + Map item = new HashMap(); + item.put("import", importMapping.get("JsonValue")); + imports.add(item); + } + } + + return objs; + } + + @Override + public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { + String basePath = resourcePath; + if (basePath.startsWith("/")) { + basePath = basePath.substring(1); + } + int pos = basePath.indexOf("/"); + if (pos > 0) { + basePath = basePath.substring(0, pos); + } + + if (basePath == "") { + basePath = "default"; + } else { + if (co.path.startsWith("/" + basePath)) { + co.path = co.path.substring(("/" + basePath).length()); + } + co.subresourceOperation = !co.path.isEmpty(); + } + List opList = operations.get(basePath); + if (opList == null) { + opList = new ArrayList(); + operations.put(basePath, opList); + } + opList.add(co); + co.baseName = basePath; + } + +} diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 5e67d0dd67f..02f5ce9c05d 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -57,3 +57,4 @@ io.swagger.codegen.languages.LumenServerCodegen io.swagger.codegen.languages.GoServerCodegen io.swagger.codegen.languages.ErlangServerCodegen io.swagger.codegen.languages.UndertowCodegen +io.swagger.codegen.languages.JavaMSF4JServerCodegen diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/ApiException.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/ApiException.mustache new file mode 100644 index 00000000000..f6161147700 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/ApiException.mustache @@ -0,0 +1,10 @@ +package {{apiPackage}}; + +{{>generatedAnnotation}} +public class ApiException extends Exception{ + private int code; + public ApiException (int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/ApiOriginFilter.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/ApiOriginFilter.mustache new file mode 100644 index 00000000000..b8af270a05a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/ApiOriginFilter.mustache @@ -0,0 +1,22 @@ +package {{apiPackage}}; + +import java.io.IOException; + +import javax.servlet.*; +import javax.servlet.http.HttpServletResponse; + +{{>generatedAnnotation}} +public class ApiOriginFilter implements javax.servlet.Filter { + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + public void destroy() {} + + public void init(FilterConfig filterConfig) throws ServletException {} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/ApiResponseMessage.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/ApiResponseMessage.mustache new file mode 100644 index 00000000000..c883e16b5e6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/ApiResponseMessage.mustache @@ -0,0 +1,69 @@ +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; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/Application.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/Application.mustache new file mode 100644 index 00000000000..6e6140b79e7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/Application.mustache @@ -0,0 +1,21 @@ +package {{invokerPackage}}; + +import org.wso2.msf4j.MicroservicesRunner; + +/** + * Application entry point. + * + * @since 1.0.0-SNAPSHOT + */ +public class Application { + public static void main(String[] args) { + +System.out.println("starting Micro Services"); +//Before you run service replace .deploy(new ()) with your actual service class like .deploy(new ApisAPI()) then it will start that service. +//If you have multiple service classes add them in , seperated manner. +//Ex: .deploy(new PetApi()) + new MicroservicesRunner() + .deploy(new PetApi()) + .start(); + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/JodaDateTimeProvider.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/JodaDateTimeProvider.mustache new file mode 100644 index 00000000000..f9421790983 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/JodaDateTimeProvider.mustache @@ -0,0 +1,44 @@ +package {{apiPackage}}; + +import com.sun.jersey.core.spi.component.ComponentContext; +import com.sun.jersey.spi.inject.Injectable; +import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider; + +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.Provider; +import org.joda.time.DateTime; +import java.util.List; + +@Provider +public class JodaDateTimeProvider extends PerRequestTypeInjectableProvider { + private final UriInfo uriInfo; + + public JodaDateTimeProvider(@Context UriInfo uriInfo) { + super(DateTime.class); + this.uriInfo = uriInfo; + } + + @Override + public Injectable getInjectable(final ComponentContext cc, final QueryParam a) { + return new Injectable() { + @Override + public DateTime getValue() { + final List values = uriInfo.getQueryParameters().get(a.value()); + + if (values == null || values.isEmpty()) + return null; + if (values.size() > 1) { + throw new WebApplicationException(Response.status(Status.BAD_REQUEST). + entity(a.value() + " cannot contain multiple values").build()); + } + + return DateTime.parse(values.get(0)); + } + }; + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/JodaLocalDateProvider.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/JodaLocalDateProvider.mustache new file mode 100644 index 00000000000..7bd4027e63d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/JodaLocalDateProvider.mustache @@ -0,0 +1,44 @@ +package {{apiPackage}}; + +import com.sun.jersey.core.spi.component.ComponentContext; +import com.sun.jersey.spi.inject.Injectable; +import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider; + +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.Provider; +import org.joda.time.LocalDate; +import java.util.List; + +@Provider +public class JodaLocalDateProvider extends PerRequestTypeInjectableProvider { + private final UriInfo uriInfo; + + public JodaLocalDateProvider(@Context UriInfo uriInfo) { + super(LocalDate.class); + this.uriInfo = uriInfo; + } + + @Override + public Injectable getInjectable(final ComponentContext cc, final QueryParam a) { + return new Injectable() { + @Override + public LocalDate getValue() { + final List values = uriInfo.getQueryParameters().get(a.value()); + + if (values == null || values.isEmpty()) + return null; + if (values.size() > 1) { + throw new WebApplicationException(Response.status(Status.BAD_REQUEST). + entity(a.value() + " cannot contain multiple values").build()); + } + + return LocalDate.parse(values.get(0)); + } + }; + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/LocalDateProvider.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/LocalDateProvider.mustache new file mode 100644 index 00000000000..8c4cd4cbd15 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/LocalDateProvider.mustache @@ -0,0 +1,44 @@ +package {{apiPackage}}; + +import com.sun.jersey.core.spi.component.ComponentContext; +import com.sun.jersey.spi.inject.Injectable; +import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider; + +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.Provider; +import java.time.LocalDate; +import java.util.List; + +@Provider +public class LocalDateProvider extends PerRequestTypeInjectableProvider { + private final UriInfo uriInfo; + + public LocalDateProvider(@Context UriInfo uriInfo) { + super(LocalDate.class); + this.uriInfo = uriInfo; + } + + @Override + public Injectable getInjectable(final ComponentContext cc, final QueryParam a) { + return new Injectable() { + @Override + public LocalDate getValue() { + final List values = uriInfo.getQueryParameters().get(a.value()); + + if (values == null || values.isEmpty()) + return null; + if (values.size() > 1) { + throw new WebApplicationException(Response.status(Status.BAD_REQUEST). + entity(a.value() + " cannot contain multiple values").build()); + } + + return LocalDate.parse(values.get(0)); + } + }; + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/NotFoundException.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/NotFoundException.mustache new file mode 100644 index 00000000000..40c25c5ea5c --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/NotFoundException.mustache @@ -0,0 +1,10 @@ +package {{apiPackage}}; + +{{>generatedAnnotation}} +public class NotFoundException extends ApiException { + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/OffsetDateTimeProvider.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/OffsetDateTimeProvider.mustache new file mode 100644 index 00000000000..876aeb327be --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/OffsetDateTimeProvider.mustache @@ -0,0 +1,44 @@ +package {{apiPackage}}; + +import com.sun.jersey.core.spi.component.ComponentContext; +import com.sun.jersey.spi.inject.Injectable; +import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider; + +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.Provider; +import java.time.OffsetDateTime; +import java.util.List; + +@Provider +public class OffsetDateTimeProvider extends PerRequestTypeInjectableProvider { + private final UriInfo uriInfo; + + public OffsetDateTimeProvider(@Context UriInfo uriInfo) { + super(OffsetDateTime.class); + this.uriInfo = uriInfo; + } + + @Override + public Injectable getInjectable(final ComponentContext cc, final QueryParam a) { + return new Injectable() { + @Override + public OffsetDateTime getValue() { + final List values = uriInfo.getQueryParameters().get(a.value()); + + if (values == null || values.isEmpty()) + return null; + if (values.size() > 1) { + throw new WebApplicationException(Response.status(Status.BAD_REQUEST). + entity(a.value() + " cannot contain multiple values").build()); + } + + return OffsetDateTime.parse(values.get(0)); + } + }; + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/README.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/README.mustache new file mode 100644 index 00000000000..b8a8abc32ad --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/README.mustache @@ -0,0 +1,23 @@ +# Swagger Jersey generated server + +## Overview +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the +[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This +is an example of building a swagger-enabled JAX-RS server. + +This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework. + +To run the server, please execute the following: + +``` +mvn clean package jetty:run +``` + +You can then view the swagger listing here: + +``` +http://localhost:{{serverPort}}{{contextPath}}/swagger.json +``` + +Note that if you have configured the `host` to be something other than localhost, the calls through +swagger-ui will be directed to that host and not localhost! \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/RFC3339DateFormat.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/RFC3339DateFormat.mustache new file mode 100644 index 00000000000..061e000f5a2 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/RFC3339DateFormat.mustache @@ -0,0 +1,19 @@ +package {{apiPackage}}; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + +import java.text.FieldPosition; +import java.util.Date; + +public class RFC3339DateFormat extends ISO8601DateFormat { + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/StringUtil.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/StringUtil.mustache new file mode 100644 index 00000000000..073966b0c21 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/StringUtil.mustache @@ -0,0 +1,42 @@ +package {{invokerPackage}}; + +{{>generatedAnnotation}} +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) return true; + if (value != null && value.equalsIgnoreCase(str)) return true; + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) return ""; + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/allowableValues.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/allowableValues.mustache new file mode 100644 index 00000000000..a48256d027a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/allowableValues.mustache @@ -0,0 +1 @@ +{{#allowableValues}}allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}{{^values}}range=[{{#min}}{{.}}{{/min}}{{^min}}-infinity{{/min}}, {{#max}}{{.}}{{/max}}{{^max}}infinity{{/max}}]{{/values}}"{{/allowableValues}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/api.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/api.mustache new file mode 100644 index 00000000000..f90d2564187 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/api.mustache @@ -0,0 +1,56 @@ +package {{package}}; + +import {{modelPackage}}.*; +import {{package}}.{{classname}}Service; +import {{package}}.factories.{{classname}}ServiceFactory; + +import io.swagger.annotations.ApiParam; +import io.swagger.jaxrs.*; + +{{#imports}}import {{import}}; +{{/imports}} + +import java.util.List; +import {{package}}.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +import org.glassfish.jersey.media.multipart.FormDataParam; + +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.*; + +@Path("/{{baseName}}") +{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} +{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} +@io.swagger.annotations.Api(description = "the {{baseName}} API") +{{>generatedAnnotation}} +{{#operations}} +public class {{classname}} { + private final {{classname}}Service delegate = {{classname}}ServiceFactory.get{{classname}}(); + +{{#operation}} + @{{httpMethod}} + {{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}} + {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} + {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} + @io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { + {{#authMethods}}@io.swagger.annotations.Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { + {{#scopes}}@io.swagger.annotations.AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, + {{/hasMore}}{{/scopes}} + }{{/isOAuth}}){{#hasMore}}, + {{/hasMore}}{{/authMethods}} + }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }) + @io.swagger.annotations.ApiResponses(value = { {{#responses}} + @io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}}, + {{/hasMore}}{{/responses}} }) + public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) + throws NotFoundException { + return delegate.{{nickname}}({{#allParams}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}{{#hasMore}},{{/hasMore}}{{/allParams}}); + } +{{/operation}} +} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/apiService.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/apiService.mustache new file mode 100644 index 00000000000..edaa0f9becb --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/apiService.mustache @@ -0,0 +1,26 @@ +package {{package}}; + +import {{package}}.*; +import {{modelPackage}}.*; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; + +{{#imports}}import {{import}}; +{{/imports}} + +import java.util.List; +import {{package}}.NotFoundException; + +import java.io.InputStream; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; + +{{>generatedAnnotation}} +{{#operations}} +public abstract class {{classname}}Service { + {{#operation}} + public abstract Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}} {{#hasMore}},{{/hasMore}}{{/allParams}}) throws NotFoundException; + {{/operation}} +} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/apiServiceFactory.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/apiServiceFactory.mustache new file mode 100644 index 00000000000..a638548227f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/apiServiceFactory.mustache @@ -0,0 +1,12 @@ +package {{package}}.factories; + +import {{package}}.{{classname}}Service; +import {{package}}.impl.{{classname}}ServiceImpl; + +public class {{classname}}ServiceFactory { + private final static {{classname}}Service service = new {{classname}}ServiceImpl(); + + public static {{classname}}Service get{{classname}}() { + return service; + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/apiServiceImpl.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/apiServiceImpl.mustache new file mode 100644 index 00000000000..af1b56fc69c --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/apiServiceImpl.mustache @@ -0,0 +1,30 @@ +package {{package}}.impl; + +import {{package}}.*; +import {{modelPackage}}.*; + +{{#imports}}import {{import}}; +{{/imports}} + +import java.util.List; +import {{package}}.NotFoundException; + +import java.io.InputStream; + +import org.glassfish.jersey.media.multipart.FormDataContentDisposition; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.SecurityContext; + +{{>generatedAnnotation}} +{{#operations}} +public class {{classname}}ServiceImpl extends {{classname}}Service { + {{#operation}} + @Override + public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}},{{/hasMore}} {{/allParams}}) throws NotFoundException { + // do some magic! + return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); + } + {{/operation}} +} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/api_test.mastache~ b/modules/swagger-codegen/src/main/resources/MSF4J/api_test.mastache~ new file mode 100644 index 00000000000..e69de29bb2d diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/application.mastache~ b/modules/swagger-codegen/src/main/resources/MSF4J/application.mastache~ new file mode 100644 index 00000000000..e97da6f8895 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/application.mastache~ @@ -0,0 +1,18 @@ +package {{invokerPackage}}; + +import org.wso2.msf4j.MicroservicesRunner; + +/** + * Application entry point. + * + * @since 1.0.0-SNAPSHOT + */ +public class Application { + public static void main(String[] args) { + +System.out.println("starting========================================================="); + new MicroservicesRunner() + .deploy(new ApisApi()) + .start(); + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/bodyParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/bodyParams.mustache new file mode 100644 index 00000000000..2b28441d3d0 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/bodyParams.mustache @@ -0,0 +1 @@ +{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/bootstrap.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/bootstrap.mustache new file mode 100644 index 00000000000..f7e8efff419 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/bootstrap.mustache @@ -0,0 +1,31 @@ +package {{apiPackage}}; + +import io.swagger.jaxrs.config.SwaggerContextService; +import io.swagger.models.*; + +import io.swagger.models.auth.*; + +import javax.servlet.http.HttpServlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; + +public class Bootstrap extends HttpServlet { + @Override + public void init(ServletConfig config) throws ServletException { + Info info = new Info() + .title("{{title}}") + .description("{{{appDescription}}}") + .termsOfService("{{termsOfService}}") + .contact(new Contact() + .email("{{infoEmail}}")) + .license(new License() + .name("{{licenseInfo}}") + .url("{{licenseUrl}}")); + + ServletContext context = config.getServletContext(); + Swagger swagger = new Swagger().info(info); + + new SwaggerContextService().withServletConfig(config).updateSwagger(swagger); + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/enumClass.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/enumClass.mustache new file mode 100644 index 00000000000..c5c3143cb94 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/enumClass.mustache @@ -0,0 +1,44 @@ + /** + * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} + */ + public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { + {{#gson}} + {{#allowableValues}} + {{#enumVars}} + @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}} + {{/enumVars}} + {{/allowableValues}} + {{/gson}} + {{^gson}} + {{#allowableValues}} + {{#enumVars}} + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}} + {{/enumVars}} + {{/allowableValues}} + {{/gson}} + + private {{{datatype}}} value; + + {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{datatype}}} value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { + for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/enumOuterClass.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/enumOuterClass.mustache new file mode 100644 index 00000000000..76c2cbf5a76 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/enumOuterClass.mustache @@ -0,0 +1,42 @@ +{{#jackson}} +import com.fasterxml.jackson.annotation.JsonCreator; +{{/jackson}} + +/** + * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} + */ +public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { + {{#gson}} + {{#allowableValues}}{{#enumVars}} + @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} + {{/gson}} + {{^gson}} + {{#allowableValues}}{{#enumVars}} + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} + {{/gson}} + + private {{{dataType}}} value; + + {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { + for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/formParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/formParams.mustache new file mode 100644 index 00000000000..9a7ff6ea6cf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/formParams.mustache @@ -0,0 +1,3 @@ +{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{#vendorExtensions.x-multipart}}@FormDataParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}} {{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{/notFile}}{{#isFile}} + @FormDataParam("{{paramName}}") InputStream {{paramName}}InputStream, + @FormDataParam("{{paramName}}") FormDataContentDisposition {{paramName}}Detail{{/isFile}}{{/isFormParam}} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/generatedAnnotation.mustache new file mode 100644 index 00000000000..a47b6faa85b --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/generatedAnnotation.mustache @@ -0,0 +1 @@ +{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/headerParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/headerParams.mustache new file mode 100644 index 00000000000..1360d796826 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/headerParams.mustache @@ -0,0 +1 @@ +{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/jacksonJsonProvider.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/jacksonJsonProvider.mustache new file mode 100644 index 00000000000..e82da4051f7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/jacksonJsonProvider.mustache @@ -0,0 +1,27 @@ +package {{apiPackage}}; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.joda.JodaModule; +import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; + +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.ext.Provider; + +@Provider +@Produces({MediaType.APPLICATION_JSON}) +public class JacksonJsonProvider extends JacksonJaxbJsonProvider { + + public JacksonJsonProvider() { + + ObjectMapper objectMapper = new ObjectMapper() + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .registerModule(new JodaModule()) + .setDateFormat(new RFC3339DateFormat()); + + setMapper(objectMapper); + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/model.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/model.mustache new file mode 100644 index 00000000000..d52b90c8bec --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/model.mustache @@ -0,0 +1,19 @@ +package {{package}}; + +import java.util.Objects; +{{#imports}}import {{import}}; +{{/imports}} +{{#serializableModel}} +import java.io.Serializable; +{{/serializableModel}} + +{{#models}} +{{#model}} +{{#isEnum}} +{{>enumOuterClass}} +{{/isEnum}} +{{^isEnum}} +{{>pojo}} +{{/isEnum}} +{{/model}} +{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/pathParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/pathParams.mustache new file mode 100644 index 00000000000..8d80210b4b4 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/pathParams.mustache @@ -0,0 +1 @@ +{{#isPathParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/pojo.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/pojo.mustache new file mode 100644 index 00000000000..6e5c1b74115 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/pojo.mustache @@ -0,0 +1,122 @@ +/** + * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} + */{{#description}} +@ApiModel(description = "{{{description}}}"){{/description}} +{{>generatedAnnotation}} +public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { + {{#vars}} + {{#isEnum}} + {{^isContainer}} +{{>enumClass}} + {{/isContainer}} + {{/isEnum}} + {{#items.isEnum}} + {{#items}} + {{^isContainer}} +{{>enumClass}} + {{/isContainer}} + {{/items}} + {{/items.isEnum}} + {{#jackson}} + @JsonProperty("{{baseName}}") + {{/jackson}} + {{#gson}} + @SerializedName("{{baseName}}") + {{/gson}} + private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; + + {{/vars}} + {{#vars}} + {{^isReadOnly}} + public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { + this.{{name}} = {{name}}; + return this; + } + {{#isListContainer}} + + public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { + this.{{name}}.add({{name}}Item); + return this; + } + {{/isListContainer}} + {{#isMapContainer}} + + public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { + this.{{name}}.put(key, {{name}}Item); + return this; + } + {{/isMapContainer}} + + {{/isReadOnly}} + /** + {{#description}} + * {{{description}}} + {{/description}} + {{^description}} + * Get {{name}} + {{/description}} + {{#minimum}} + * minimum: {{minimum}} + {{/minimum}} + {{#maximum}} + * maximum: {{maximum}} + {{/maximum}} + * @return {{name}} + **/ + {{#vendorExtensions.extraAnnotation}} + {{vendorExtensions.extraAnnotation}} + {{/vendorExtensions.extraAnnotation}} + @ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") + public {{{datatypeWithEnum}}} {{getter}}() { + return {{name}}; + } + {{^isReadOnly}} + + public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { + this.{{name}} = {{name}}; + } + {{/isReadOnly}} + + {{/vars}} + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + }{{#hasVars}} + {{classname}} {{classVarName}} = ({{classname}}) o; + return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && + {{/hasMore}}{{/vars}}{{#parent}} && + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} + return true;{{/hasVars}} + } + + @Override + public int hashCode() { + return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class {{classname}} {\n"); + {{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}} + {{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n"); + {{/vars}}sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/pom.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/pom.mustache new file mode 100644 index 00000000000..ff9764e8e95 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/pom.mustache @@ -0,0 +1,103 @@ + + + + + org.wso2.msf4j + msf4j-service +2.0.0 + + + 4.0.0 + {{groupId}} + {{artifactId}} + jar + {{artifactId}} + {{artifactVersion}} + + src/main/java + + + + org.apache.maven.plugins + maven-jar-plugin + + + + io.swagger.api.Application + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + + + javax.servlet + servlet-api + ${servlet-api-version} + + + org.wso2.msf4j + msf4j-all + 2.0.0 + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + 2.4.1 + + + org.glassfish.jersey.containers + jersey-container-servlet-core + ${jersey2-version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey2-version} + + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + true + + + + + {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + ${java.version} + ${java.version} + 1.5.9 + 9.2.9.v20150224 + 2.22.2 + 4.12 + 1.1.7 + 2.5 + 2.22.2 + UTF-8 + + diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/queryParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/queryParams.mustache new file mode 100644 index 00000000000..9055e6f16dc --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/queryParams.mustache @@ -0,0 +1 @@ +{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/returnTypes.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/returnTypes.mustache new file mode 100644 index 00000000000..c8f7a56938a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/returnTypes.mustache @@ -0,0 +1 @@ +{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/serviceBodyParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/serviceBodyParams.mustache new file mode 100644 index 00000000000..c7d1abfe527 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/serviceBodyParams.mustache @@ -0,0 +1 @@ +{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/serviceFormParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/serviceFormParams.mustache new file mode 100644 index 00000000000..dc2d2eb1ecf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/serviceFormParams.mustache @@ -0,0 +1 @@ +{{#isFormParam}}{{#notFile}}{{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}InputStream {{paramName}}InputStream, FormDataContentDisposition {{paramName}}Detail{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/serviceHeaderParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/serviceHeaderParams.mustache new file mode 100644 index 00000000000..bd03573d196 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/serviceHeaderParams.mustache @@ -0,0 +1 @@ +{{#isHeaderParam}}{{{dataType}}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/servicePathParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/servicePathParams.mustache new file mode 100644 index 00000000000..6829cf8c7a6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/servicePathParams.mustache @@ -0,0 +1 @@ +{{#isPathParam}}{{{dataType}}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/serviceQueryParams.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/serviceQueryParams.mustache new file mode 100644 index 00000000000..ff79730471d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/serviceQueryParams.mustache @@ -0,0 +1 @@ +{{#isQueryParam}}{{{dataType}}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/MSF4J/web.mustache b/modules/swagger-codegen/src/main/resources/MSF4J/web.mustache new file mode 100644 index 00000000000..520456fb128 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/MSF4J/web.mustache @@ -0,0 +1,63 @@ + + + + + jersey + org.glassfish.jersey.servlet.ServletContainer + + jersey.config.server.provider.packages + + io.swagger.jaxrs.listing, + io.swagger.sample.resource, + {{apiPackage}} + + + + jersey.config.server.provider.classnames + org.glassfish.jersey.media.multipart.MultiPartFeature + + + jersey.config.server.wadl.disableWadl + true + + 1 + + + + Jersey2Config + io.swagger.jersey.config.JerseyJaxrsConfig + + api.version + 1.0.0 + + + swagger.api.title + {{{title}}} + + + swagger.api.basepath + {{basePath}} + + + 2 + + + Bootstrap + {{apiPackage}}.Bootstrap + 2 + + + jersey + {{contextPath}}/* + + + ApiOriginFilter + {{apiPackage}}.ApiOriginFilter + + + ApiOriginFilter + /* + +