swagger2markup icon indicating copy to clipboard operation
swagger2markup copied to clipboard

Referenced example values become double quoted strings

Open kidnme opened this issue 8 years ago • 5 comments

Swagger2Markup version:

1.3.1 (via the 1.3.3 swagger2markup maven plugin)

Problem description:

Example values for references of references have the correct value, but they always become double quoted strings regardless of their type.

So, given the following yaml:

---
swagger: '2.0'
info:
  version: 0.0.0
  title: Simple API
tags:
  - name: sample
paths:
  /:
    get:
      tags:
        - sample
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/Response'
          
definitions:
  Response:
    type: object
    properties:
      id1:
        type: integer
        example: 1
      id2:
        $ref: '#/definitions/Id2'
      string1:
        type: string
        example: string1
      string2:
        $ref: '#/definitions/String2'
  Id2:
    type: integer
    example: 2
  String2:
    type: string
    example: string2

The resulting ascii doc is:

...

===== Example HTTP response

====== Response 200
[source,json]
----
{
  "id1" : 1,
  "id2" : "2",
  "string1" : "string1",
  "string2" : "\"string2\""
}
----

instead of the expected:

...


===== Example HTTP response

====== Response 200
[source,json]
----
{
  "id1" : 1,
  "id2" : 2,
  "string1" : "string1",
  "string2" : "string2"
}
----

kidnme avatar Jan 25 '18 18:01 kidnme

Thx for opening an issue. Atm I don't have much time to maintain the project. But I would be happy for review a PR and merge it.

RobWin avatar Jan 29 '18 07:01 RobWin

Issue #448 in the swagger-parser is the root cause and will be fixed with pull request #449 (tested on a local branch).

kidnme avatar Feb 05 '18 15:02 kidnme

Awesome. Thx for the information

RobWin avatar Feb 05 '18 16:02 RobWin

The swagger parser just released version 1.0.35. If a new release of swagger2markup is built with this version, then this problem will be resolved. In addition, if the latest changes (specifically fixes for #264 and #266) are included, then this new release gives me a clean pipeline to produce documents from a swagger spec.

kidnme avatar Apr 17 '18 14:04 kidnme

Now that the pull request has been incorporated, what will cause a new official release of swagger2markup? Eventually, I'd like that as well as a new release of the swagger2markup-maven-plugin that is built with this new release.

kidnme avatar Apr 20 '18 17:04 kidnme