Skip to content
This repository was archived by the owner on Jan 11, 2019. It is now read-only.
This repository was archived by the owner on Jan 11, 2019. It is now read-only.

Compliance Assertion does not validate XML responses #53

@flounderpinto

Description

@flounderpinto

When responses are in XML format, the plugin tries to run them through the JSON parser, resulting in a failure on every XML response.

I was able to fix this by making the following modifications to SwaggerComplianceAssertion.java in validatePayload():

CHANGE:
JsonNode contentObject = Json.mapper().readTree(payload);
TO:
if (contentType.equalsIgnoreCase("application/json")) { final ObjectMapper jsonMapper = new ObjectMapper(); contentObject = jsonMapper.readTree(payload); } else if (contentType.equalsIgnoreCase("application/xml")) { final XmlMapper xmlMapper = new XmlMapper(); contentObject = xmlMapper.readTree(payload); } else { throw new AssertionException( new AssertionError("Swagger Compliance testing failed. Invalid content type: " + contentType)); }

"contentType" is passed into validatePayload() as a parameter. Of course there may be a cleaner way to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions