OpenAPITools / OpenAPITools/openapi-generator
[BUG] [R] Nested anyOf/oneOf cause the R client to generate unusable code
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
The linked spec containing an anyOf within a oneOf generates code which does not load the Foo object correctly:
> library(openapi)
>
> foo <- Foo$new()
> foo$fromJSONString('{ "tag": "Bar", "contents": ["baz", ["x"]] }')
{
"tag": "Bar"
}
> foo$contents
NULL
foo$contents should not be NULL.
openapi-generator version
6.2.1 and master branch
OpenAPI declaration file content or url
https://gist.github.com/avandecreme/c68ec04615dbc9faaaf70c6d27599a14
Generation Details
openapi-generator-cli generate -i ./openapi.json -g r -o ./generated-sdk
Steps to reproduce
Generate the api and run the example code above.
Suggest a fix
The issue comes from this generated line of code:
self$`contents` <- ApiClient$new()$deserializeObj(this_object$`contents`, "array[AnyOfstringarray]", loadNamespace("openapi"))
array[AnyOfstringarray] is not valid.
I couldn't find how to fix that though.
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 spec and reproduce the issue using openapi-generator-cli generate -i ./openapi.json -g r -o ./generated-sdk. Inspect the generated R model and the ApiClient$new()$deserializeObj call for the invalid array[AnyOfstringarray] type, then verify that foo$contents loads from the sample JSON instead of remaining NULL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, r
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100