Skip to content

Commit aab280d

Browse files
committed
made generation timestamp optional
1 parent 4bb1287 commit aab280d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+207
-220
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJerseyServerCodegen.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import java.util.*;
88

99
public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
10+
boolean showGenerationTimestamp = false;
11+
1012
public JavaJerseyServerCodegen() {
1113
super();
1214

@@ -46,6 +48,7 @@ public JavaJerseyServerCodegen() {
4648
cliOptions.add(library);
4749
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
4850
cliOptions.add(new CliOption("title", "a title describing the application"));
51+
cliOptions.add(new CliOption("showGenerationTimestamp", "shows the timestamp when files were generated"));
4952
}
5053

5154
@Override
@@ -84,7 +87,7 @@ public void processOpts() {
8487
supportingFiles.add(new SupportingFile("ApiResponseMessage.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiResponseMessage.java"));
8588
supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
8689
supportingFiles.add(new SupportingFile("jacksonJsonProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JacksonJsonProvider.java"));
87-
supportingFiles.add(new SupportingFile("bootstrap.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java"));
90+
writeOptional(outputFolder, new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java"));
8891

8992
writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
9093
supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
@@ -93,7 +96,7 @@ public void processOpts() {
9396
setDateLibrary(additionalProperties.get("dateLibrary").toString());
9497
additionalProperties.put(dateLibrary, "true");
9598
}
96-
if(DEFAULT_LIBRARY.equals(library)) {
99+
if(DEFAULT_LIBRARY.equals(library) || library == null) {
97100
if(templateDir.startsWith(JAXRS_TEMPLATE_DIRECTORY_NAME)) {
98101
// set to the default location
99102
templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey1_18";
@@ -147,5 +150,9 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
147150
}
148151
opList.add(co);
149152
co.baseName = basePath;
150-
}
153+
}
154+
155+
public void showGenerationTimestamp(boolean showGenerationTimestamp) {
156+
this.showGenerationTimestamp = showGenerationTimestamp;
157+
}
151158
}

modules/swagger-codegen/src/main/resources/JavaJaxRS/jersey1_18/api.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public class {{classname}} {
4646
{{/hasMore}}{{/authMethods}}
4747
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
4848
@io.swagger.annotations.ApiResponses(value = { {{#responses}}
49-
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},
50-
{{/hasMore}}{{/responses}} })
51-
52-
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/allParams}}@Context SecurityContext securityContext)
49+
@io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},{{/hasMore}}{{/responses}} })
50+
public Response {{nickname}}(
51+
{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},
52+
{{/allParams}}@Context SecurityContext securityContext)
5353
throws NotFoundException {
5454
return delegate.{{nickname}}({{#allParams}}{{#isFile}}inputStream, fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/allParams}}securityContext);
5555
}
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
{{#isFormParam}}
2-
// it's a form param!
3-
{{#notFile}}
4-
{{^vendorExtensions.x-multipart}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{/vendorExtensions.x-multipart}}
5-
{{#vendorExtensions.x-multipart}}@FormDataParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}}@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}
6-
{{/notFile}}
7-
{{#isFile}}
8-
@FormDataParam("file") InputStream inputStream,
9-
@FormDataParam("file") FormDataContentDisposition fileDetail
10-
{{/isFile}}
11-
{{/isFormParam}}
1+
{{#isFormParam}}{{#notFile}}{{^vendorExtensions.x-multipart}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{/vendorExtensions.x-multipart}}{{#vendorExtensions.x-multipart}}@FormDataParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}}@FormParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{/notFile}}{{#isFile}}@FormDataParam("file") InputStream inputStream,
2+
@FormDataParam("file") FormDataContentDisposition fileDetail{{/isFile}}{{/isFormParam}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
1+
{{#showGenerationTimestamps}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/showGenerationTimestamps}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
1+
{{#showGenerationTimestamps}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/showGenerationTimestamps}}

modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JaxRSServerOptionsProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public Map<String, String> createOptions() {
2727
builder.putAll(options)
2828
.put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE)
2929
//.put(JavaJaxRSJersey1ServerCodegen.DATE_LIBRARY, "joda") //java.lang.IllegalArgumentException: Multiple entries with same key: dateLibrary=joda and dateLibrary=joda
30-
.put("title", "Test title");
30+
.put("title", "Test title")
31+
.put("showGenerationTimestamp", "true");
3132

3233
return builder.build();
3334
}
Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
package io.swagger.api;
22

33
import io.swagger.model.Pet;
4+
import io.swagger.model.InlineResponse200;
45
import java.io.File;
56

67
import javax.ws.rs.*;
78
import javax.ws.rs.core.Response;
89

10+
import org.apache.cxf.jaxrs.ext.multipart.*;
11+
912
@Path("/")
1013
public interface PetApi {
11-
@PUT
14+
@POST
1215
@Path("/pet")
1316
@Consumes({ "application/json", "application/xml" })
1417
@Produces({ "application/json", "application/xml" })
15-
public Response updatePet(Pet body);
18+
public Response addPet(Pet body);
1619
@POST
17-
@Path("/pet")
20+
@Path("/pet?testing_byte_array=true")
1821
@Consumes({ "application/json", "application/xml" })
1922
@Produces({ "application/json", "application/xml" })
20-
public Response addPet(Pet body);
23+
public Response addPetUsingByteArray(byte[] body);
24+
@DELETE
25+
@Path("/pet/{petId}")
26+
27+
@Produces({ "application/json", "application/xml" })
28+
public Response deletePet(@PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey);
2129
@GET
2230
@Path("/pet/findByStatus")
2331

@@ -33,31 +41,31 @@ public interface PetApi {
3341

3442
@Produces({ "application/json", "application/xml" })
3543
public Response getPetById(@PathParam("petId") Long petId);
44+
@GET
45+
@Path("/pet/{petId}?response=inline_arbitrary_object")
46+
47+
@Produces({ "application/json", "application/xml" })
48+
public Response getPetByIdInObject(@PathParam("petId") Long petId);
49+
@GET
50+
@Path("/pet/{petId}?testing_byte_array=true")
51+
52+
@Produces({ "application/json", "application/xml" })
53+
public Response petPetIdtestingByteArraytrueGet(@PathParam("petId") Long petId);
54+
@PUT
55+
@Path("/pet")
56+
@Consumes({ "application/json", "application/xml" })
57+
@Produces({ "application/json", "application/xml" })
58+
public Response updatePet(Pet body);
3659
@POST
3760
@Path("/pet/{petId}")
3861
@Consumes({ "application/x-www-form-urlencoded" })
3962
@Produces({ "application/json", "application/xml" })
4063
public Response updatePetWithForm(@PathParam("petId") String petId,@Multipart(value = "name", required = false) String name,@Multipart(value = "status", required = false) String status);
41-
@DELETE
42-
@Path("/pet/{petId}")
43-
44-
@Produces({ "application/json", "application/xml" })
45-
public Response deletePet(@PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey);
4664
@POST
4765
@Path("/pet/{petId}/uploadImage")
4866
@Consumes({ "multipart/form-data" })
4967
@Produces({ "application/json", "application/xml" })
5068
public Response uploadFile(@PathParam("petId") Long petId,@Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file", required = false) InputStream fileInputStream,
5169
@Multipart(value = "file" , required = false) Attachment fileDetail);
52-
@GET
53-
@Path("/pet/{petId}?testing_byte_array=true")
54-
55-
@Produces({ "application/json", "application/xml" })
56-
public Response petPetIdtestingByteArraytrueGet(@PathParam("petId") Long petId);
57-
@POST
58-
@Path("/pet?testing_byte_array=true")
59-
@Consumes({ "application/json", "application/xml" })
60-
@Produces({ "application/json", "application/xml" })
61-
public Response addPetUsingByteArray(byte[] body);
6270
}
6371

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
11
package io.swagger.api;
22

3-
import java.util.Map;
43
import io.swagger.model.Order;
4+
import java.util.Map;
55

66
import javax.ws.rs.*;
77
import javax.ws.rs.core.Response;
88

9+
import org.apache.cxf.jaxrs.ext.multipart.*;
10+
911
@Path("/")
1012
public interface StoreApi {
13+
@DELETE
14+
@Path("/store/order/{orderId}")
15+
16+
@Produces({ "application/json", "application/xml" })
17+
public Response deleteOrder(@PathParam("orderId") String orderId);
18+
@GET
19+
@Path("/store/findByStatus")
20+
21+
@Produces({ "application/json", "application/xml" })
22+
public Response findOrdersByStatus(@QueryParam("status") String status);
1123
@GET
1224
@Path("/store/inventory")
1325

1426
@Produces({ "application/json", "application/xml" })
1527
public Response getInventory();
16-
@POST
17-
@Path("/store/order")
28+
@GET
29+
@Path("/store/inventory?response=arbitrary_object")
1830

1931
@Produces({ "application/json", "application/xml" })
20-
public Response placeOrder(Order body);
32+
public Response getInventoryInObject();
2133
@GET
2234
@Path("/store/order/{orderId}")
2335

2436
@Produces({ "application/json", "application/xml" })
2537
public Response getOrderById(@PathParam("orderId") String orderId);
26-
@DELETE
27-
@Path("/store/order/{orderId}")
38+
@POST
39+
@Path("/store/order")
2840

2941
@Produces({ "application/json", "application/xml" })
30-
public Response deleteOrder(@PathParam("orderId") String orderId);
42+
public Response placeOrder(Order body);
3143
}
3244

samples/server/petstore/jaxrs-cxf/gen/java/io/swagger/api/UserApi.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import javax.ws.rs.*;
77
import javax.ws.rs.core.Response;
88

9+
import org.apache.cxf.jaxrs.ext.multipart.*;
10+
911
@Path("/")
1012
public interface UserApi {
1113
@POST
@@ -23,6 +25,16 @@ public interface UserApi {
2325

2426
@Produces({ "application/json", "application/xml" })
2527
public Response createUsersWithListInput(List<User> body);
28+
@DELETE
29+
@Path("/user/{username}")
30+
31+
@Produces({ "application/json", "application/xml" })
32+
public Response deleteUser(@PathParam("username") String username);
33+
@GET
34+
@Path("/user/{username}")
35+
36+
@Produces({ "application/json", "application/xml" })
37+
public Response getUserByName(@PathParam("username") String username);
2638
@GET
2739
@Path("/user/login")
2840

@@ -33,20 +45,10 @@ public interface UserApi {
3345

3446
@Produces({ "application/json", "application/xml" })
3547
public Response logoutUser();
36-
@GET
37-
@Path("/user/{username}")
38-
39-
@Produces({ "application/json", "application/xml" })
40-
public Response getUserByName(@PathParam("username") String username);
4148
@PUT
4249
@Path("/user/{username}")
4350

4451
@Produces({ "application/json", "application/xml" })
4552
public Response updateUser(@PathParam("username") String username,User body);
46-
@DELETE
47-
@Path("/user/{username}")
48-
49-
@Produces({ "application/json", "application/xml" })
50-
public Response deleteUser(@PathParam("username") String username);
5153
}
5254

samples/server/petstore/jaxrs/src/gen/java/io/swagger/api/ApiException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.swagger.api;
22

3-
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-02T17:03:59.929-06:00")
3+
44
public class ApiException extends Exception{
55
private int code;
66
public ApiException (int code, String msg) {

0 commit comments

Comments
 (0)