Skip to content

Commit 0307d38

Browse files
committed
added friendly download links
1 parent 9a473ce commit 0307d38

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/model/ResponseCode.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@
22

33
public class ResponseCode {
44
private String code;
5+
private String link;
6+
public ResponseCode() {}
7+
8+
public ResponseCode(String code, String link) {
9+
setCode(code);
10+
setLink(link);
11+
}
512

613
public String getCode() {
714
return code;
815
}
9-
1016
public void setCode(String code) {
1117
this.code = code;
1218
}
1319

14-
public ResponseCode() {}
15-
16-
public ResponseCode(String code) {
17-
setCode(code);
20+
public String getLink() {
21+
return link;
22+
}
23+
public void setLink(String link) {
24+
this.link = link;
1825
}
1926
}

modules/swagger-generator/src/main/java/com/wordnik/swagger/generator/resource/SwaggerResource.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ else if(config.getTag().equals(CodegenType.SERVER)) {
3434

3535
@GET
3636
@Path("/download/{fileId}")
37-
@Produces({"application/zip", "application/json"})
38-
@ApiOperation(value = "Downloads a pre-generated file", response = File.class)
37+
@Produces({"application/zip"})
38+
@ApiOperation(value = "Downloads a pre-generated file",
39+
response = String.class)
3940
public Response downloadFile(@PathParam("fileId") String fileId) throws Exception {
4041
Generated g = fileMap.get(fileId);
4142
System.out.println("looking for fileId " + fileId);
@@ -57,7 +58,8 @@ public Response downloadFile(@PathParam("fileId") String fileId) throws Exceptio
5758
@POST
5859
@Path("/clients/{language}")
5960
@Produces({"application/zip", "application/json"})
60-
@ApiOperation(value = "Generates a client library based on the config")
61+
@ApiOperation(
62+
value = "Generates a client library based on the config")
6163
public Response generateClient(
6264
@ApiParam(value = "The target language for the client library", allowableValues = "android,java,php,objc,docs", required = true) @PathParam("language") String language,
6365
@ApiParam(value = "Configuration for building the client library", required = true) GeneratorInput opts) throws Exception {
@@ -71,7 +73,8 @@ public Response generateClient(
7173
g.setFriendlyName(language + "-client");
7274
fileMap.put(code, g);
7375
System.out.println(code + ", " + filename);
74-
return Response.ok().entity(new ResponseCode(code)).build();
76+
String link = "http://generator.swagger.io/api/gen/download/" + code;
77+
return Response.ok().entity(new ResponseCode(code, link)).build();
7578
}
7679
else {
7780
return Response.status(500).build();
@@ -120,7 +123,8 @@ public Response generateServerForLanguage(
120123
g.setFriendlyName(framework + "-server");
121124
fileMap.put(code, g);
122125
System.out.println(code + ", " + filename);
123-
return Response.ok().entity(new ResponseCode(code)).build();
126+
String link = "http://generator.swagger.io/api/gen/download/" + code;
127+
return Response.ok().entity(new ResponseCode(code, link)).build();
124128
}
125129
else {
126130
return Response.status(500).build();

0 commit comments

Comments
 (0)