enabled url-only reading of specs

This commit is contained in:
Tony Tam
2015-02-17 12:43:10 -08:00
parent 12365b9591
commit 9a473ceae6

View File

@@ -22,15 +22,22 @@ public class Generator {
static Logger LOGGER = LoggerFactory.getLogger(Generator.class);
public static String generateClient(String language, GeneratorInput opts) throws ApiException {
Swagger swagger;
LOGGER.debug("generate client for " + language);
if(opts == null) {
throw new BadRequestException(400, "No options were supplied");
}
JsonNode node = opts.getSpec();
if(node == null) {
throw new BadRequestException(400, "No swagger specification was supplied");
if(opts.getSwaggerUrl() != null) {
swagger = new SwaggerParser().read(opts.getSwaggerUrl());
}
else
throw new BadRequestException(400, "No swagger specification was supplied");
}
else {
swagger = new SwaggerParser().read(node);
}
Swagger swagger = new SwaggerParser().read(node);
if(swagger == null) {
throw new BadRequestException(400, "The swagger specification supplied was not valid");
}