swagger-api / swagger-api/swagger-codegen
[R] strings are unquoted in JSON encoding
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
toJSONString() produces invalid JSON when containing string values.
Swagger-codegen version
swagger-codegen-cli-2.4.0-20180821.200234-311
Swagger declaration file content or url
swagger: "2.0"
info:
description: ""
title: "repro"
version: "1"
paths:
/pet:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
operationId: "addPet"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"
responses:
200:
description: ""
definitions:
Pet:
type: "object"
properties:
foo:
type: string
Command line used for generation
java -jar swagger-codegen-cli-2.4.0-20180821.200234-311.jar generate --lang r -i swagger.yaml
Steps to reproduce
$ R
> library(devtools); install("."); library(swagger)
> Pet$new(foo="bar")$toJSONString()
[1] "{\n \"foo\": bar\n }"
Related issues/PRs
https://github.com/swagger-api/swagger-codegen/issues/8610
Suggest a fix/enhancement
Quote string values.
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 generated R model's toJSONString() path and reproduce the issue using Pet$new(foo="bar") from the report. Verify that string-valued fields are emitted as valid JSON, then add or update coverage for this example and confirm the generated output parses as JSON.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100