forked from loafle/openapi-generator-original
added friendly download links
This commit is contained in:
parent
9a473ceae6
commit
0307d3818a
@ -2,18 +2,25 @@ package com.wordnik.swagger.generator.model;
|
|||||||
|
|
||||||
public class ResponseCode {
|
public class ResponseCode {
|
||||||
private String code;
|
private String code;
|
||||||
|
private String link;
|
||||||
|
public ResponseCode() {}
|
||||||
|
|
||||||
|
public ResponseCode(String code, String link) {
|
||||||
|
setCode(code);
|
||||||
|
setLink(link);
|
||||||
|
}
|
||||||
|
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCode(String code) {
|
public void setCode(String code) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseCode() {}
|
public String getLink() {
|
||||||
|
return link;
|
||||||
public ResponseCode(String code) {
|
}
|
||||||
setCode(code);
|
public void setLink(String link) {
|
||||||
|
this.link = link;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,8 +34,9 @@ public class SwaggerResource {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/download/{fileId}")
|
@Path("/download/{fileId}")
|
||||||
@Produces({"application/zip", "application/json"})
|
@Produces({"application/zip"})
|
||||||
@ApiOperation(value = "Downloads a pre-generated file", response = File.class)
|
@ApiOperation(value = "Downloads a pre-generated file",
|
||||||
|
response = String.class)
|
||||||
public Response downloadFile(@PathParam("fileId") String fileId) throws Exception {
|
public Response downloadFile(@PathParam("fileId") String fileId) throws Exception {
|
||||||
Generated g = fileMap.get(fileId);
|
Generated g = fileMap.get(fileId);
|
||||||
System.out.println("looking for fileId " + fileId);
|
System.out.println("looking for fileId " + fileId);
|
||||||
@ -57,7 +58,8 @@ public class SwaggerResource {
|
|||||||
@POST
|
@POST
|
||||||
@Path("/clients/{language}")
|
@Path("/clients/{language}")
|
||||||
@Produces({"application/zip", "application/json"})
|
@Produces({"application/zip", "application/json"})
|
||||||
@ApiOperation(value = "Generates a client library based on the config")
|
@ApiOperation(
|
||||||
|
value = "Generates a client library based on the config")
|
||||||
public Response generateClient(
|
public Response generateClient(
|
||||||
@ApiParam(value = "The target language for the client library", allowableValues = "android,java,php,objc,docs", required = true) @PathParam("language") String language,
|
@ApiParam(value = "The target language for the client library", allowableValues = "android,java,php,objc,docs", required = true) @PathParam("language") String language,
|
||||||
@ApiParam(value = "Configuration for building the client library", required = true) GeneratorInput opts) throws Exception {
|
@ApiParam(value = "Configuration for building the client library", required = true) GeneratorInput opts) throws Exception {
|
||||||
@ -71,7 +73,8 @@ public class SwaggerResource {
|
|||||||
g.setFriendlyName(language + "-client");
|
g.setFriendlyName(language + "-client");
|
||||||
fileMap.put(code, g);
|
fileMap.put(code, g);
|
||||||
System.out.println(code + ", " + filename);
|
System.out.println(code + ", " + filename);
|
||||||
return Response.ok().entity(new ResponseCode(code)).build();
|
String link = "http://generator.swagger.io/api/gen/download/" + code;
|
||||||
|
return Response.ok().entity(new ResponseCode(code, link)).build();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Response.status(500).build();
|
return Response.status(500).build();
|
||||||
@ -120,7 +123,8 @@ public class SwaggerResource {
|
|||||||
g.setFriendlyName(framework + "-server");
|
g.setFriendlyName(framework + "-server");
|
||||||
fileMap.put(code, g);
|
fileMap.put(code, g);
|
||||||
System.out.println(code + ", " + filename);
|
System.out.println(code + ", " + filename);
|
||||||
return Response.ok().entity(new ResponseCode(code)).build();
|
String link = "http://generator.swagger.io/api/gen/download/" + code;
|
||||||
|
return Response.ok().entity(new ResponseCode(code, link)).build();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Response.status(500).build();
|
return Response.status(500).build();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user