Skip to content

[BUG] [openapi-generator-gradle-plugin] jar: URL resolution not allowed by gradle #19260

@arthurtemple

Description

@arthurtemple
Description

This recent Pull Request enabled inputSpec resolution from a jar: URI in maven projects (thanks a lot, by the way!).

We hoped to use this new feature in gradle projects, unfortunately gradle tries to resolve the inputSpec as a file and fails to do so when a jar: URI is provided.

openapi-generator version

Gradle plugin version 7.7.0.

Steps to reproduce

A simple project is available as attachment here:
open-api-uri-issue.zip

In order to reproduce, simply run
./gradlew openApiValidate

Expected output

./gradlew openApiValidate

> Task :openApiValidate
Validating spec jar:file:src/main/resources/petstore.jar!/petstore.yaml
Spec is valid.

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

Actual output

./gradlew openApiValidate
> Task :openApiValidate FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':openApiValidate'.
> Cannot convert URL 'jar:file:src/main/resources/petstore.jar!/petstore.yaml' to a file.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 605ms
1 actionable task: 1 executed
Related issues/PRs

#18576

Suggest a fix

A fix seems to remove the constraint in GenerateTask.kt and ValidateTask.kt:

- @get:InputFile
- @PathSensitive(PathSensitivity.RELATIVE)
+ @get:Input
val inputSpec = project.objects.property<String>()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions