|
24 | 24 | import io.swagger.v3.core.util.Yaml; |
25 | 25 | import io.swagger.v3.parser.OpenAPIResolver; |
26 | 26 | import io.swagger.v3.parser.OpenAPIV3Parser; |
| 27 | +import io.swagger.v3.parser.core.models.AuthorizationValue; |
27 | 28 | import io.swagger.v3.parser.core.models.ParseOptions; |
28 | 29 | import lombok.Setter; |
29 | 30 | import org.apache.commons.io.FileUtils; |
|
37 | 38 | import org.apache.maven.project.MavenProject; |
38 | 39 | import org.apache.maven.project.MavenProjectHelper; |
39 | 40 | import org.openapitools.codegen.*; |
| 41 | +import org.openapitools.codegen.auth.AuthParser; |
40 | 42 | import org.openapitools.codegen.config.CodegenConfigurator; |
41 | 43 | import org.openapitools.codegen.config.GlobalSettings; |
42 | 44 | import org.openapitools.codegen.config.MergedSpecBuilder; |
@@ -1002,8 +1004,10 @@ private String calculateInputSpecHash(String inputSpec) { |
1002 | 1004 | parseOptions.setResolve(true); |
1003 | 1005 |
|
1004 | 1006 | final URL remoteUrl = inputSpecRemoteUrl(); |
| 1007 | + final List<AuthorizationValue> authorizationValues = AuthParser.parse(this.auth); |
| 1008 | + |
1005 | 1009 | return Hashing.sha256().hashBytes( |
1006 | | - new OpenAPIParser().readLocation(remoteUrl == null ? inputSpec : remoteUrl.toString(), null, parseOptions) |
| 1010 | + new OpenAPIParser().readLocation(remoteUrl == null ? inputSpec : remoteUrl.toString(), authorizationValues, parseOptions) |
1007 | 1011 | .getOpenAPI().toString().getBytes(StandardCharsets.UTF_8) |
1008 | 1012 | ).toString(); |
1009 | 1013 | } |
@@ -1089,7 +1093,9 @@ private Path createCollapsedSpec() throws MojoExecutionException { |
1089 | 1093 | // Merge the OpenAPI spec file. |
1090 | 1094 | final var parseOptions = new ParseOptions(); |
1091 | 1095 | parseOptions.setResolve(true); |
1092 | | - final var openApiMerged = new OpenAPIResolver(new OpenAPIV3Parser().readLocation(inputSpec, null, parseOptions).getOpenAPI()).resolve(); |
| 1096 | + final List<AuthorizationValue> authorizationValues = AuthParser.parse(this.auth); |
| 1097 | + |
| 1098 | + final var openApiMerged = new OpenAPIResolver(new OpenAPIV3Parser().readLocation(inputSpec, authorizationValues, parseOptions).getOpenAPI()).resolve(); |
1093 | 1099 |
|
1094 | 1100 | // Switch based on JSON or YAML. |
1095 | 1101 | final var extension = inputSpec.toLowerCase(Locale.ROOT).endsWith(".json") ? ".json" : ".yaml"; |
|
0 commit comments