|
1 | 1 | package io.swagger.generator.online;
|
2 | 2 |
|
3 | 3 | import com.fasterxml.jackson.databind.JsonNode;
|
4 |
| - |
5 |
| -import io.swagger.codegen.CliOption; |
6 |
| -import io.swagger.codegen.ClientOptInput; |
7 |
| -import io.swagger.codegen.ClientOpts; |
8 |
| -import io.swagger.codegen.Codegen; |
9 |
| -import io.swagger.codegen.CodegenConfig; |
10 |
| -import io.swagger.codegen.CodegenConfigLoader; |
| 4 | +import io.swagger.codegen.*; |
11 | 5 | import io.swagger.generator.exception.ApiException;
|
12 | 6 | import io.swagger.generator.exception.BadRequestException;
|
13 | 7 | import io.swagger.generator.model.GeneratorInput;
|
14 | 8 | import io.swagger.generator.model.InputOption;
|
15 | 9 | import io.swagger.generator.util.ZipUtil;
|
16 | 10 | import io.swagger.models.Swagger;
|
| 11 | +import io.swagger.models.auth.AuthorizationValue; |
17 | 12 | import io.swagger.parser.SwaggerParser;
|
18 | 13 | import io.swagger.util.Json;
|
19 |
| - |
20 | 14 | import org.slf4j.Logger;
|
21 | 15 | import org.slf4j.LoggerFactory;
|
22 | 16 |
|
@@ -79,11 +73,24 @@ private static String generate(String language, GeneratorInput opts, Type type)
|
79 | 73 | Swagger swagger;
|
80 | 74 | if (node == null) {
|
81 | 75 | if (opts.getSwaggerUrl() != null) {
|
82 |
| - swagger = new SwaggerParser().read(opts.getSwaggerUrl()); |
| 76 | + if(opts.getAuthorizationValue() != null) { |
| 77 | + List<AuthorizationValue> authorizationValues = new ArrayList<AuthorizationValue>(); |
| 78 | + authorizationValues.add(opts.getAuthorizationValue()); |
| 79 | + |
| 80 | + swagger = new SwaggerParser().read(opts.getSwaggerUrl(), authorizationValues, true); |
| 81 | + } |
| 82 | + else { |
| 83 | + swagger = new SwaggerParser().read(opts.getSwaggerUrl()); |
| 84 | + } |
83 | 85 | } else {
|
84 | 86 | throw new BadRequestException("No swagger specification was supplied");
|
85 | 87 | }
|
86 |
| - } else { |
| 88 | + } else if(opts.getAuthorizationValue() != null) { |
| 89 | + List<AuthorizationValue> authorizationValues = new ArrayList<AuthorizationValue>(); |
| 90 | + authorizationValues.add(opts.getAuthorizationValue()); |
| 91 | + swagger = new SwaggerParser().read(node, authorizationValues, true); |
| 92 | + } |
| 93 | + else { |
87 | 94 | swagger = new SwaggerParser().read(node, true);
|
88 | 95 | }
|
89 | 96 | if (swagger == null) {
|
|
0 commit comments