OpenAPITools / OpenAPITools/openapi-generator
[BUG] [R] Invalid syntax for lists default parameters - uses brackets instead of `list()`
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 R generator creates default list values [] which is not valid R code (should be list()).
openapi-generator version
openapi-generator-cli 7.8.0-SNAPSHOT
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Sample API
version: 0.0.0
paths:
/:
get:
responses:
'200':
description: Foo
content:
application/json:
schema:
$ref: "#/components/schemas/ExampleSchema"
components:
schemas:
ExampleSchema:
properties:
field:
items:
type: string
type: array
default: []
type: object
title: ExampleSchema
Steps to reproduce
openapi-generator-cli generate \
-i openapi.json \
-g r \
-o ./output
Relevant R code:
./output/R/example_schema.R
initialize = function(`field` = [], ...) {
This should have been:
initialize = function(`field` = list(), ...) {
This also applies to the default arguments to requests - I can file a separate ticket but I'd assume it's the same underlying code
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
Reproduce the issue with the supplied OpenAPI declaration and the openapi-generator-cli generate command, then inspect ./output/R/example_schema.R. Trace how the R generator turns array defaults into request and model arguments. Done means generated R defaults use list() rather than [], including request arguments, and the generated code is valid R.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, r
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100