OpenAPITools / OpenAPITools/openapi-generator

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

Open
#19,260 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

https://github.com/OpenAPITools/openapi-generator/pull/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>()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GenerateTask.kt and ValidateTask.kt, where inputSpec is declared with Gradle file input annotations. Run ./gradlew openApiValidate using the attached project and inspect how the jar: URI is converted. Done means the task accepts the jar: inputSpec and produces the expected successful validation output.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.