added sort

This commit is contained in:
Tony Tam 2016-02-20 21:09:27 -08:00
parent 7c2d09d0e4
commit 671c5880b9
2 changed files with 28 additions and 22 deletions

View File

@ -11,12 +11,26 @@ import io.swagger.models.parameters.Parameter;
import io.swagger.models.parameters.PathParameter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class DynamicSwaggerConfig extends BeanConfig {
static List<String> clients = new ArrayList<String>();
static List<String> servers = new ArrayList<String>();
static {
List<CodegenConfig> extensions = Codegen.getExtensions();
for (CodegenConfig config : extensions) {
if (config.getTag().equals(CodegenType.CLIENT) || config.getTag().equals(CodegenType.DOCUMENTATION)) {
clients.add(config.getName());
} else if (config.getTag().equals(CodegenType.SERVER)) {
servers.add(config.getName());
}
}
Collections.sort(clients);
Collections.sort(servers);
}
@Override
public Swagger configure(Swagger swagger) {
Path clientPath = swagger.getPaths().get("/gen/clients/{language}");
@ -62,15 +76,4 @@ public class DynamicSwaggerConfig extends BeanConfig {
.host(getHost())
.basePath("/api");
}
static {
List<CodegenConfig> extensions = Codegen.getExtensions();
for (CodegenConfig config : extensions) {
if (config.getTag().equals(CodegenType.CLIENT) || config.getTag().equals(CodegenType.DOCUMENTATION)) {
clients.add(config.getName());
} else if (config.getTag().equals(CodegenType.SERVER)) {
servers.add(config.getName());
}
}
}
}

View File

@ -30,6 +30,20 @@ public class SwaggerResource {
static List<String> servers = new ArrayList<String>();
private static Map<String, Generated> fileMap = new HashMap<String, Generated>();
static {
List<CodegenConfig> extensions = Codegen.getExtensions();
for (CodegenConfig config : extensions) {
if (config.getTag().equals(CodegenType.CLIENT) || config.getTag().equals(CodegenType.DOCUMENTATION)) {
clients.add(config.getName());
} else if (config.getTag().equals(CodegenType.SERVER)) {
servers.add(config.getName());
}
}
Collections.sort(clients);
Collections.sort(servers);
}
@GET
@Path("/download/{fileId}")
@Produces({MediaType.APPLICATION_OCTET_STREAM})
@ -202,15 +216,4 @@ public class SwaggerResource {
return Response.status(500).build();
}
}
static {
List<CodegenConfig> extensions = Codegen.getExtensions();
for (CodegenConfig config : extensions) {
if (config.getTag().equals(CodegenType.CLIENT) || config.getTag().equals(CodegenType.DOCUMENTATION)) {
clients.add(config.getName());
} else if (config.getTag().equals(CodegenType.SERVER)) {
servers.add(config.getName());
}
}
}
}