JSON Reference \"#/definitions/ <...> \" cannot be resolved in RestAssured tests

Issue #191 resolved
Former user created an issue

I've encountered problem that one of my definitions is not resolved.

When I tried to debug it looks one definition is missing in new schema what is converted from swagger 2.0 to open api. Definition is missing in inventory instance (during debug).

class: io.swagger.v3.parser.converter.SwaggerConverter
method: public SwaggerParseResult convert(SwaggerDeserializationResult parse) 
line: SwaggerInventory inventory = (new SwaggerInventory()).process(parse.getSwagger());

While I was debuggng, almost all definitions and references to them where updated from #/definitions/ to #/components/schemas/

But all references to one definition are not updated, when it was $ref in allOf. It is used in allOf.

I've tried to test in: com.atlassian.oai.validator.restassuredOpenApiValidationFilterTest, my method below:

    @Test
    public void filter_returnsResponse_ifValidationSucceeds_forGetWithLinkArrays() {
        OpenApiInteractionValidator validator = OpenApiInteractionValidator
                .createFor("api-with-linkArrays-swagger.yaml")
//                .withLevelResolver(LevelResolverFactory.withAdditionalPropertiesIgnored())
                .build();
        classUnderTest = new OpenApiValidationFilter(validator);
        assertThat(classUnderTest.filter(
                requestSpec("GET", "/hello/John"), null,
                response(200,
                        ClasspathHelper.loadFileFromClasspath("api-with-linkArrays-expected-response.json"))),
                notNullValue());
    }

See part of spec (below), full file in attachment.

definitions:
  Message:
    type: object
    properties:
      message:
        type: string
      links:
        allOf:
          - $ref: '#/definitions/Links'
  Links:
    discriminator: type
    type: array

Error: com.atlassian.oai.validator.restassured.OpenApiValidationFilter$OpenApiValidationException: { "messages" : [ { "key" : "validation.response.body.schema.processingError", "level" : "ERROR", "message" : "JSON Reference \"#/definitions/Links\" cannot be resolved", "context" : { "requestPath" : "/hello/John", "responseStatus" : 200, "location" : "RESPONSE", "requestMethod" : "GET" } } ] }

Comments (4)

  1. Tomasz Zdunek

    I was debugging for several hours and I haven't found solution, but I can help how to reproduce it. I hope this is a valid problem at all. I would need this solution to use your restassured.OpenApiValidationFilterfilter in a lot of tests for API project.

  2. Log in to comment