OpenAPITools / OpenAPITools/openapi-generator
[BUG][RUST|KOTLIN] Generated code does not compile: "AnyOfLessThanGreaterThan"
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 (example)?
- 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
In my project, I cannot use the more recent versions of the openapi-generator (>=v7.5.0) because it produces code that does not compile.
openapi-generator version
reproducible on version 7.5.0, 7.6.0, 7.7.0
OpenAPI declaration file content or url
https://gist.github.com/bewee-i/27cb9af7c6a2c12756dd4a41d6fed124
Generation Details
java -jar ./openapi-generator-cli.jar generate -g rust -i api.yaml
java -jar ./openapi-generator-cli.jar generate -g kotlin -i api.yaml
Steps to reproduce
Execute code generation for the provided openapi description. The generated code does not compile because it contains the following:
src/models/profile_response.rs
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ProfileResponse {
#[serde(rename = "email", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
pub email: Option<Option<Box<models::AnyOfLessThanGreaterThan>>>,
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
src/main/kotlin/org/openapitools/client/models/ProfileResponse.kt
data class ProfileResponse (
@Json(name = "email")
val email: AnyOfLessThanGreaterThan? = null,
@Json(name = "id")
val id: kotlin.String? = null
) {
}
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
Start with the linked OpenAPI declaration and reproduce both commands for the Rust and Kotlin generators. Inspect src/models/profile_response.rs and src/main/kotlin/org/openapitools/client/models/ProfileResponse.kt, then verify the generated projects compile; done means neither output contains the reported invalid AnyOfLessThanGreaterThan usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi, rust
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100