Skip to content

[BUG] [typescript-fetch] JSON Strings include quotes in response #9364

@vkhougaz-sonatype

Description

@vkhougaz-sonatype

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

I have an API that returns JSON encoded strings, similar to

"API Result Information"

INCLUDING the quotes.

openapi-generator version

Usually 5.1.0, also reproduced on

OpenAPI declaration file content or url

https://github.com/vkhougaz-sonatype/openapi-bug/blob/master/swagger.yaml

swagger: "2.0"
info:
  version: v1
  title: Our API
  description: The REST API for interacting with Our API
host: localhost:1234
schemes:
  - http
paths:
  "/api/job/{jobid}/status":
    get:
      summary: getJobStatus
      description: Get the current status for a job.
      operationId: getJobStatus
      produces:
        - application/json;charset=utf-8
      parameters:
        - required: true
          in: path
          name: jobid
          type: string
      responses:
        "200":
          schema:
            $ref: "#/definitions/JobStatus"
          description: ""
        "404":
          description: "`jobid` not found"
definitions:
  JobStatus:
    type: string
Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i /local/swagger.yaml -g typescript-fetch -o /local/out
Steps to reproduce
  1. Install demo repo
git clone https://github.com/vkhougaz-sonatype/openapi-bug
cd openapi-bug
# node >v10
npm install
./build-and-serve.sh
  1. open browser to http://localhost:1234
  2. See status
Got `"ok"` expected `ok`
Related issues/PRs

#3709
#4028

Suggest a fix

Update api code to not use simple response for "string" type?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions