Service Virtualization

Expand all | Collapse all

Example JSON response in swagger spec causes "LinkedHashMap cannot be cast to String" error

  • 1.  Example JSON response in swagger spec causes "LinkedHashMap cannot be cast to String" error

    Posted 03-22-2016 12:26 AM

    I'm trying to make the VS created from our APIs have more realistic responses.  But, although my Swagger spec is valid DevTest 9.0 fails to create the transaction.

    The part of the spec it appears to fail on (works when removed) looks like: (full spec is attached)

          responses:

            '200':

              description: OK

              schema:

                $ref: '#/definitions/DomainViewDto'

              examples:

                application/json:

                  id: 1507

                  name: JasonDomain

                  description: Jasons Test Domain

                  owner: Jason

                  roles:

                    - name: Writers

                      membersGroup: "Domain_DEV"

          deprecated: false

     

    The stack trace looks like:

    java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to java.lang.String

      at com.itko.lisa.vse.swagger.helper.SwaggerHelper.getResponses(SwaggerHelper.java:428)

      at com.itko.lisa.vse.swagger.helper.SwaggerHelper.getTransactions(SwaggerHelper.java:238)

      at com.itko.lisa.vse.stateful.protocol.http.FromSwaggerProtocolHandler.beginRecordProcess(FromSwaggerProtocolHandler.java:319)

      at com.itko.lisa.vse.stateful.protocol.http.FromSwaggerProtocolHandler.configure(FromSwaggerProtocolHandler.java:607)

      at com.itko.lisa.vse.stateful.protocol.http.SwaggerDefinitionsPanel.save(SwaggerDefinitionsPanel.java:190)

      at com.itko.lisa.gui.WizardPanel.savePanel(WizardPanel.java:631)

      at com.itko.lisa.gui.WizardPanel.next(WizardPanel.java:432)

    Swagger "examples:" is supported as a text example response works well.

          responses:

            '200':

              description: OK

              schema:

                $ref: '#/definitions/DomainViewDto'

              examples:

                application/text: "Hello World"

          deprecated: false

    I have tried both importing both YAML and JSON swagger definitions. (Attached)

    Attachment(s)

    zip
    swagger_resp.yaml.zip   755B 1 version
    zip
    swagger_resp.json.zip   889B 1 version


  • 2.  Re: Example JSON response in swagger spec causes "LinkedHashMap cannot be cast to String" error

    Posted 03-22-2016 03:39 PM

    Looks like a bug to me, you will have to open a support ticket.