mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-13 16:03:43 +00:00
Bugfix for remote specs with params (#21634)
* [Bugfix][Maven-Plugin] Bugfix for remote input specs with parameters If the inputSpec was a web address that contained parameters, code generation would fail, because the filepath would contain illegal characters, since the code inside the if-block would be skipped. A side effect of this was, that in the log and in the filename in linux the parameters would be leaked, which could potentially sensitive information like Gitlab Access Tokens * [Test][Gradle Plugin] Update GenerateTaskDslTest.kt Extended the Test for testing remote inputSpecs with urlParams, a case that caused problems in the maven plugin.
This commit is contained in:
parent
edbacaa3c7
commit
1c2ef3356d
@ -34,6 +34,7 @@ class GenerateTaskDslTest : TestBase() {
|
||||
@Test
|
||||
fun `openApiGenerate should create an expected file structure from URL config`() {
|
||||
val specUrl = "https://raw.githubusercontent.com/OpenAPITools/openapi-generator/b6b8c0db872fb4a418ae496e89c7e656e14be165/modules/openapi-generator-gradle-plugin/src/test/resources/specs/petstore-v3.0.yaml"
|
||||
val urlParams ="?meaningless=params&so=it&results=in&illegal=filenames&on=windows"
|
||||
// Arrange
|
||||
val buildContents = """
|
||||
plugins {
|
||||
@ -41,7 +42,7 @@ class GenerateTaskDslTest : TestBase() {
|
||||
}
|
||||
openApiGenerate {
|
||||
generatorName = "kotlin"
|
||||
remoteInputSpec = "$specUrl"
|
||||
remoteInputSpec = "$specUrl$urlParams"
|
||||
outputDir = file("build/kotlin").absolutePath
|
||||
apiPackage = "org.openapitools.example.api"
|
||||
invokerPackage = "org.openapitools.example.invoker"
|
||||
|
@ -1066,7 +1066,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
String name = inputSpecFile.getName();
|
||||
|
||||
URL url = inputSpecRemoteUrl();
|
||||
if (inputSpecFile.exists() && url != null) {
|
||||
if (url != null) {
|
||||
String[] segments = url.getPath().split("/");
|
||||
name = Files.getNameWithoutExtension(segments[segments.length - 1]);
|
||||
}
|
||||
|
@ -68,6 +68,10 @@ public class CodeGenMojoTest extends BaseTestCase {
|
||||
testCommonConfiguration("jar");
|
||||
}
|
||||
|
||||
public void testCommonConfigurationWithRemoteInputSpec() throws Exception {
|
||||
testCommonConfiguration("remote");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void testCommonConfiguration(String profile) throws Exception {
|
||||
CodeGenMojo mojo = loadMojo(newTempFolder(), "src/test/resources/default", profile);
|
||||
|
@ -55,6 +55,12 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>remote</id>
|
||||
<properties>
|
||||
<inputSpec>https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml?meaningless=params&so=it&results=in&illegal=filenames&on=windows</inputSpec>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<build>
|
||||
<finalName>common-maven</finalName>
|
||||
|
Loading…
x
Reference in New Issue
Block a user