OpenAPITools / OpenAPITools/openapi-generator

[BUG] Gradle plugin uses string type instead of file type

Open
#17,380 1 comment 0 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

The field inputSpec in the task ValidateTask does not use the correct type.

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt#L55-L57

The provided annotation for input/output checks won't work properly. @InputFile has been assigned but the type is not a file property type. Incremental build functionality and build caching work as expected. For example, if you change the contents of the assigned file provided as a string. The string doesn't change, however, the content does and therefore doesn't trigger a re-run of the task.

This issue isn't limited to the task ValidateTask. The same issue applies to other task types provided by the plugin.

openapi-generator version

OpenAPI Gradle plugin 7.1.0.

OpenAPI declaration file content or url
plugins {
    id "org.openapi.generator" version "7.1.0"
}

openApiValidate {
    inputSpec = "$rootDir/petstore-v3.0-invalid.yaml"
    recommend = true
}
Steps to reproduce

Run the task openApiValidate.

Suggest a fix

The field should use the type RegularFileProperty.

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 modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/ValidateTask.kt at lines 55-57, then inspect the other task types provided by the plugin for similarly typed inputSpec fields. Run openApiValidate with the supplied configuration and change the contents of the referenced file; done means the relevant file-property inputs trigger the task again and are handled correctly by Gradle input/output checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.