OpenAPITools / OpenAPITools/openapi-generator
[BUG] Description
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
i am trying to run the openApiGenerate gradle task through intellij (latest version)
openapi-generator version
7.13.0
OpenAPI declaration file content or url
getApiV2Shipments_request:
properties:
tracking_number:
description: Tracking Number(s) to search for.
items:
type: string
type: array```
##### Generation Details
Using gradle within intellij for a java generation (removed other stuff)
plugins {
id("org.openapi.generator") version "7.13.0"
}
openApiGenerate {
generatorName.set("java")
inputSpec.set("${rootDir}/src/main/api/openapi.yaml")
dryRun.set(true)
outputDir.set("c:/sandboxes/mdb/projects/ehubcode/")
skipValidateSpec.set(true)
importMappings.set(mapOf(
Pair("OffsetDateTime", "java.lang.String"),
Pair("LocalDate", "java.lang.String")
))
typeMappings.set(mapOf(
Pair("OffsetDateTime", "java.lang.String"),
Pair("LocalDate", "java.lang.String")
))
configOptions.set(mapOf(
Pair("containerDefaultToNull", "true"),
Pair("dateLibrary", "java8")
))
}
dependencies {
api("io.swagger:swagger-annotations:1.6.5")
api("com.google.code.findbugs:jsr305:3.0.2")
api("com.squareup.okhttp3:okhttp:4.9.3")
api("com.squareup.okhttp3:logging-interceptor:4.9.3")
api("com.google.code.gson:gson:2.9.0")
api("io.gsonfire:gson-fire:1.8.5")
api("javax.ws.rs:jsr311-api:1.1.1")
api("javax.ws.rs:javax.ws.rs-api:2.1.1")
//api("org.openapitools:jackson-databind-nullable:0.2.3")
//api("org.apache.commons:commons-lang3:3.12.0")
api("jakarta.annotation:jakarta.annotation-api:1.3.5")
api("org.junit.jupiter:junit-jupiter-api:5.8.2")
api("org.mockito:mockito-core:3.12.4")
api("org.junit.jupiter:junit-jupiter-engine:5.8.2")
implementation("org.openapitools:openapi-generator-gradle-plugin:7.13.0")
}
##### Steps to reproduce
just run openApiGenerate gradle task. Notable part of output:
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
Could not compute datatypeWithEnum from String, null
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
'scheme' not defined in the spec (2.0). Default to [http] for server URL [http://app.ehub.com/]
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.6.4/userguide/command_line_interface.html#sec:command_line_warnings
1 actionable task: 1 executed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':openApiGenerate'.
> 'com.fasterxml.jackson.core.io.ContentReference com.fasterxml.jackson.dataformat.yaml.YAMLFactory._createContentReference(java.lang.Object)'
##### Related issues/PRs
did not see any.
##### Suggest a fix
I tried debugging and found this section of code in DefaultCodegen.java (line 7391ff):
```java
if (arrayInnerProperty.baseType != null && arrayInnerProperty.enumName != null) {
codegenParameter.datatypeWithEnum = codegenParameter.dataType.replace(arrayInnerProperty.baseType, arrayInnerProperty.enumName);
} else {
LOGGER.warn("Could not compute datatypeWithEnum from {}, {}", arrayInnerProperty.baseType, arrayInnerProperty.enumName);
}
And then also this near line 4115:
// this can cause issues for clients which don't support enums
if (property.isEnum) {
property.datatypeWithEnum = toEnumName(property);
property.enumName = toEnumName(property);
} else {
property.datatypeWithEnum = property.dataType;
}
And it seems nothing will set enumName if it is not already an enum.
Interesting to note, the following CLI works just fine:
"C:\Program Files\Java\jdk-11.0.15\bin\java.exe" -jar C:/Users/mike.billman/AppData/Local/JetBrains/IntelliJIdea2024.3/openapi/codegen/d1f8bb39b5817ae983385027d47d550c/openapi-generator-cli-7.7.0.jar generate -g java -i C:\Sandboxes\mdb\Projects\ehubcode\api\openapi.yaml -o C:\Sandboxes\mdb\Projects\ehubcode\ --skip-validate-spec --import-mappings=OffsetDateTime=java.lang.String,LocalDate=java.lang.String --type-mappings=OffsetDateTime=java.lang.String,LocalDate=java.lang.String --additional-properties=containerDefaultToNull=true
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the Gradle openApiGenerate task with the supplied YAML and compare it with the working CLI invocation. Inspect DefaultCodegen.java around lines 7391 and 4115, then verify the task completes without the reported Jackson failure and datatypeWithEnum warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100