-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkmst- Prokarma microservice toolkit for java #7023
Merged
Merged
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0203e5d
Added pkmst-microservice toolkit
anshu2185 7478845
Merge branch 'master' into pkmst
sanshuman e185b75
formatted
rkumar-pk e653796
replaces tab with blank spaces
rkumar-pk bfe2685
adding documentation folder
ninodpillai 3c01f9d
adding documentation folder
ninodpillai 81749f5
Update readme.mustache
ninodpillai 2595347
updated readme
sanshuman 73a0c99
Update io.swagger.codegen.CodegenConfig
ninodpillai f4a4c6f
Update readme.mustache
rkumar-pk ad08778
renamed according to convention and added typeinfoannotation
sanshuman 860e873
removed tabs
sanshuman dc941aa
updated codegen which extends abstractjavacodegen
sanshuman d1c2654
Added the script files and rectified the errors
sanshuman 5bc164f
folder name changed and commons -lang3 version upgraded
sanshuman 741c72a
updated readme.mustache
sanshuman 598df24
updated logging filter
sanshuman 326c864
Added petstore to samples and updated the pom for the same
rkumar-pk 51ef6c1
Added java-pkmst sample to pom.xml.circleci
rkumar-pk cb26f96
updated readme.mustache
sanshuman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1,457 changes: 1,457 additions & 0 deletions
1,457
modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PkmstServerCodegen.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
modules/swagger-codegen/src/main/resources/pkmst/RFC3339DateFormat.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package {{basePackage}}; | ||
|
||
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; | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
modules/swagger-codegen/src/main/resources/pkmst/SpringBootApplication.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package {{basePackage}}; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; | ||
{{#eurekaUri}} | ||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; | ||
{{/eurekaUri}} | ||
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
/** | ||
* starts the spring boot application | ||
* @author pkmst | ||
* | ||
*/ | ||
|
||
@SpringBootApplication | ||
@EnableSwagger2 | ||
{{#eurekaUri}} | ||
@EnableEurekaClient | ||
{{/eurekaUri}} | ||
@EnableCircuitBreaker | ||
@EnableHystrixDashboard | ||
public class {{serviceName}}Application { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger({{serviceName}}Application.class); | ||
|
||
public static void main(String[] args) { | ||
LOGGER.debug("Running spring boot application"); | ||
SpringApplication.run({{serviceName}}Application.class, args); | ||
} | ||
} | ||
|
87 changes: 87 additions & 0 deletions
87
modules/swagger-codegen/src/main/resources/pkmst/api.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* NOTE: This class is auto generated by the swagger code generator program ({{{generatorVersion}}}). | ||
* https://github.com/swagger-api/swagger-codegen | ||
* Do not edit the class manually. | ||
*/ | ||
package {{package}}; | ||
|
||
{{#imports}}import {{import}}; | ||
{{/imports}} | ||
|
||
import io.swagger.annotations.*; | ||
{{#jdk8}} | ||
import org.springframework.http.HttpStatus; | ||
{{/jdk8}} | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.multipart.MultipartFile; | ||
{{^useSpringCloudClient}} | ||
import java.io.IOException; | ||
{{/useSpringCloudClient}} | ||
|
||
import java.util.List; | ||
{{#useOptional}} | ||
import java.util.Optional; | ||
{{/useOptional}} | ||
{{#async}} | ||
import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; | ||
{{/async}} | ||
{{#useBeanValidation}} | ||
import org.springframework.validation.annotation.Validated; | ||
import javax.validation.constraints.*; | ||
import javax.validation.Valid; | ||
{{/useBeanValidation}} | ||
/** | ||
* Provides the info about api methods | ||
* @author pkmst | ||
* | ||
*/ | ||
{{>generatedAnnotation}} | ||
@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") | ||
{{#operations}} | ||
public interface {{classname}} { | ||
{{#operation}} | ||
|
||
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { | ||
{{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { | ||
{{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, | ||
{{/hasMore}}{{/scopes}} | ||
}{{/isOAuth}}){{#hasMore}}, | ||
{{/hasMore}}{{/authMethods}} | ||
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }) | ||
@ApiResponses(value = { {{#responses}} | ||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}} }) | ||
{{#implicitHeaders}} | ||
@ApiImplicitParams({ | ||
{{#headerParams}}{{>implicitHeader}}{{/headerParams}} | ||
}) | ||
{{/implicitHeaders}} | ||
@RequestMapping(value = "{{{path}}}",{{#singleContentTypes}} | ||
produces = "{{{vendorExtensions.x-accepts}}}", | ||
consumes = "{{{vendorExtensions.x-contentType}}}",{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} | ||
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} | ||
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} | ||
method = RequestMethod.{{httpMethod}}) | ||
{{#useSpringCloudClient}} | ||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { | ||
// do some magic! | ||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; | ||
}{{/jdk8}} | ||
|
||
{{/useSpringCloudClient}} | ||
{{^useSpringCloudClient}} | ||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}} @RequestHeader(value = "Accept", required = false) String accept) throws Exception{{^jdk8}};{{/jdk8}}{{#jdk8}} { | ||
// do some magic! | ||
return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK){{#async}}){{/async}}; | ||
}{{/jdk8}} | ||
|
||
{{/useSpringCloudClient}} | ||
{{/operation}} | ||
} | ||
{{/operations}} |
115 changes: 115 additions & 0 deletions
115
modules/swagger-codegen/src/main/resources/pkmst/apiController.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package {{package}}; | ||
|
||
{{^jdk8-no-delegate}} | ||
{{#imports}}import {{import}}; | ||
{{/imports}} | ||
|
||
import io.swagger.annotations.*; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
{{/jdk8-no-delegate}} | ||
import org.springframework.stereotype.Controller; | ||
{{^jdk8-no-delegate}} | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.List; | ||
{{#useOptional}} | ||
import java.util.Optional; | ||
{{/useOptional}} | ||
{{#async}} | ||
import java.util.concurrent.Callable; | ||
{{/async}} | ||
{{/jdk8-no-delegate}} | ||
{{^useSpringCloudClient}} | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.io.IOException; | ||
{{/useSpringCloudClient}} | ||
{{#useBeanValidation}} | ||
import javax.validation.constraints.*; | ||
import javax.validation.Valid; | ||
{{/useBeanValidation}} | ||
/** | ||
* Api implemention | ||
* @author pkmst | ||
* | ||
*/ | ||
{{>generatedAnnotation}} | ||
@Controller | ||
{{#operations}} | ||
public class {{classname}}Controller implements {{classname}} { | ||
private final ObjectMapper objectMapper; | ||
@Autowired | ||
public {{classname}}Controller(ObjectMapper objectMapper) { | ||
this.objectMapper = objectMapper; | ||
} | ||
|
||
{{#isDelegate}} | ||
private final {{classname}}Delegate delegate; | ||
|
||
@org.springframework.beans.factory.annotation.Autowired | ||
public {{classname}}Controller({{classname}}Delegate delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
{{/isDelegate}} | ||
{{^jdk8-no-delegate}} | ||
{{#operation}} | ||
public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}, | ||
{{/allParams}}@RequestHeader(value = "Accept", required = false) String accept) throws Exception { | ||
// do some magic! | ||
{{#useSpringCloudClient}} | ||
{{^isDelegate}} | ||
{{^async}} | ||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); | ||
{{/async}} | ||
{{#async}} | ||
return new Callable<ResponseEntity<{{>returnTypes}}>>() { | ||
@Override | ||
public ResponseEntity<{{>returnTypes}}> call() throws Exception { | ||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); | ||
} | ||
}; | ||
{{/async}} | ||
{{/isDelegate}} | ||
{{#isDelegate}} | ||
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); | ||
{{/isDelegate}} | ||
{{/useSpringCloudClient}} | ||
{{^useSpringCloudClient}} | ||
{{^isDelegate}} | ||
{{^async}} | ||
{{#examples}} | ||
|
||
if (accept != null && accept.contains("{{{contentType}}}")) { | ||
return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.OK); | ||
} | ||
|
||
{{/examples}} | ||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); | ||
{{/async}} | ||
{{#async}} | ||
return new Callable<ResponseEntity<{{>returnTypes}}>>() { | ||
@Override | ||
public ResponseEntity<{{>returnTypes}}> call() throws Exception { | ||
return new ResponseEntity<{{>returnTypes}}>(HttpStatus.OK); | ||
} | ||
}; | ||
{{/async}} | ||
{{/isDelegate}} | ||
{{#isDelegate}} | ||
return delegate.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); | ||
{{/isDelegate}} | ||
{{/useSpringCloudClient}} | ||
} | ||
|
||
{{/operation}} | ||
{{/jdk8-no-delegate}} | ||
} | ||
{{/operations}} |
10 changes: 10 additions & 0 deletions
10
modules/swagger-codegen/src/main/resources/pkmst/apiException.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
modules/swagger-codegen/src/main/resources/pkmst/apiOriginFilter.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package {{apiPackage}}; | ||
|
||
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, | ||
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); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
} | ||
|
||
@Override | ||
public void init(FilterConfig filterConfig) throws ServletException { | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
modules/swagger-codegen/src/main/resources/pkmst/apiResponseMessage.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package {{apiPackage}}; | ||
|
||
import javax.xml.bind.annotation.XmlTransient; | ||
|
||
{{>generatedAnnotation}} | ||
@javax.xml.bind.annotation.XmlRootElement | ||
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; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you keep the alphabetical order ?