Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response example is not converted correctly #223

Closed
esteban-eg-kim opened this issue Dec 21, 2016 · 7 comments
Closed

Response example is not converted correctly #223

esteban-eg-kim opened this issue Dec 21, 2016 · 7 comments
Labels
Milestone

Comments

@esteban-eg-kim
Copy link

Swagger2Markup version: 1.1.0

Problem description:
When I tried to convert my test swagger file to adoc file, example of response was not converted correctly.
The mime type (ex. application/json) is represented in example json as a key.

This is my test swagger file.

    :
  responses:
    200:
      description: "successful operation"
      schema:
        type: array
        items:
          $ref: "#/definitions/Pet"
      examples:
        application/json:
        - id: 2331
          name: mungmung
          photoUrls:
            - url1
            - url2
          status: available

When I converted it then I got,

===== Example HTTP response

====== Response 200
[source,json]
----
{
  "application/json" : [ {    <-- ??????
    "id" : 2331,
    "name" : "mungmung",
    "photoUrls" : [ "url1", "url2" ],
    "status" : "available"
  } ]
}
----

But my expect is ...

===== Example HTTP response

====== Response 200
[source,json]
----
[
 {
    "id" : 2331,
    "name" : "mungmung",
    "photoUrls" : [ "url1", "url2" ],
    "status" : "available"
  } 
]
----

What's wrong with my configs?

Thanks
Esteban

@RobWin
Copy link
Member

RobWin commented Dec 21, 2016

Hi,

nothing is wrong in your configuration.
I think we have to enhance the rendering of examples .

Btw if you like and use Swagger2Makup, we would love to get your GitHub star.

@esteban-eg-kim
Copy link
Author

@RobWin Thanks for your comment. And I've given you start :)

cascer1 added a commit to cascer1/swagger2markup that referenced this issue Dec 21, 2016
@cascer1
Copy link
Contributor

cascer1 commented Dec 21, 2016

It looks like the problem is that the Swagger Json.pretty() method converts the example including content-type to a JSON object. The result of this method is a JSON object where the first key is the content-type (for your issue, this would be application/json) and the value of this key is the actual example.

Converting the result of Json.pretty() to a Java array, and then printing the values only should do the trick.

cascer1 added a commit to cascer1/swagger2markup that referenced this issue Dec 23, 2016
RobWin pushed a commit that referenced this issue Jan 2, 2017
RobWin pushed a commit that referenced this issue Jan 2, 2017
cascer1 added a commit to cascer1/swagger2markup that referenced this issue Jan 2, 2017
cascer1 added a commit to cascer1/swagger2markup that referenced this issue Jan 2, 2017
@esteban-eg-kim
Copy link
Author

When do you plan to release the next version(1.1.2 or 1.2) with this fix?
And I'm using "swagger2markup-gradle-plugin" also, but the plugin is now supporting swagger2markup version 1.1.0.
I wish the plugin also be updated with latest swagger2markup.

@RobWin
Copy link
Member

RobWin commented Jan 5, 2017

Hi,

I release it soon, but you can already use it.
The Plugin is not coupled to a specific Swagger2markup version
See https://github.com/Swagger2Markup/swagger2markup-gradle-project-template/blob/master/build.gradle#L11-L12

You can also use the 1.2.0-SNAPSHOT version when you add the SNAPSHOT repo.

@RobWin RobWin added this to the 1.2.0 milestone Jan 5, 2017
@RobWin RobWin added the bug label Jan 5, 2017
@esteban-eg-kim
Copy link
Author

Thanks a lot. :)
It works good.

@RobWin
Copy link
Member

RobWin commented Jan 5, 2017

I published v1.2.0. You can use it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants