swagger2markup icon indicating copy to clipboard operation
swagger2markup copied to clipboard

Response examples for inline objects are generated improperly

Open kidnme opened this issue 7 years ago • 4 comments

Swagger2Markup version: v1.3.3

Problem description: If an inline schema object is supplied in a response and examples are being generated for them, then the resulting response example will be "object". In addition, if the inline schema does not specify a type (e.g. type: object), then the attempt to generate a response example will NPE. Previous versions of the swagger-parser used to default an unspecified type to be "object" and now they are typed as "untyped".

Given this yaml input::

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

definitions:
  Id2:
    type: integer
    example: 2
  String2:
    type: string
    example: string2

The resulting asciidoc is:

...

==== Example HTTP response

===== Response 200
[source,json]
----
"object"
----

Instead of the expected:

...

==== Example HTTP response

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

Removing the line 'type: object' from the response schema will result in a NullPointerException.

kidnme avatar May 01 '18 19:05 kidnme

Hi @kidnme, can i look at this issue #313 and try to solve it ?

Demmi94 avatar Oct 18 '18 17:10 Demmi94

Sure :)

RobWin avatar Oct 18 '18 17:10 RobWin

ok :) can you also assinged it to me ? btw but not 314 that was mistake :/

Demmi94 avatar Oct 18 '18 19:10 Demmi94

Is this Issue already fixed ? @RobWin

Demmi94 avatar Nov 02 '18 15:11 Demmi94