Skip to content

Commit 4cc419b

Browse files
authored
Merge pull request #136 from valfirst/add-option-to-configure-auth-for-spec-retrieval
Add option to configure authentication for Spec retrieval
2 parents 9cb23c4 + cad82bf commit 4cc419b

File tree

1 file changed

+13
-1
lines changed
  • swagger-coverage-commandline/src/main/java/com/github/viclovsky/swagger/coverage/core/generator

1 file changed

+13
-1
lines changed

swagger-coverage-commandline/src/main/java/com/github/viclovsky/swagger/coverage/core/generator/Generator.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.github.viclovsky.swagger.coverage.core.results.builder.core.StatisticsBuilder;
99
import io.swagger.parser.OpenAPIParser;
1010
import io.swagger.v3.oas.models.OpenAPI;
11+
import io.swagger.v3.parser.core.models.AuthorizationValue;
1112
import io.swagger.v3.parser.core.models.ParseOptions;
1213
import io.swagger.v3.parser.core.models.SwaggerParseResult;
1314
import org.slf4j.Logger;
@@ -23,6 +24,8 @@ public class Generator {
2324
private static final Logger LOGGER = LoggerFactory.getLogger(Generator.class);
2425

2526
private URI specPath;
27+
private List<AuthorizationValue> specAuths;
28+
2629
private Path inputPath;
2730

2831
private Path configurationPath;
@@ -35,7 +38,7 @@ public void run() {
3538
Configuration configuration = ConfigurationBuilder.build(configurationPath);
3639
ParseOptions parseOptions = new ParseOptions();
3740
parseOptions.setResolve(true);
38-
SwaggerParseResult parsed = parser.readLocation(specPath.toString(), null, parseOptions);
41+
SwaggerParseResult parsed = parser.readLocation(specPath.toString(), specAuths, parseOptions);
3942
parsed.getMessages().forEach(LOGGER::info);
4043
OpenAPI spec = parsed.getOpenAPI();
4144

@@ -73,6 +76,15 @@ public Generator setSpecPath(URI specPath) {
7376
return this;
7477
}
7578

79+
public List<AuthorizationValue> getSpecAuths() {
80+
return specAuths;
81+
}
82+
83+
public Generator setSpecAuths(List<AuthorizationValue> specAuths) {
84+
this.specAuths = specAuths;
85+
return this;
86+
}
87+
7688
public Path getInputPath() {
7789
return inputPath;
7890
}

0 commit comments

Comments
 (0)