javaopenapi

OpenApiInteractionValidator does not find any errors in trivial error cases


OpenApiInteractionValidator seems to be ignoring almost all request errors. Seems like I am missing some configuration option or the tool is really extremely limited. I have checked my spec against several validators (it is correct) and editors (contents are properly understood).

Here is my code:

OpenApiInteractionValidator validator = OpenApiInteractionValidator.createFor(/** my quite complex spec */)
            .withLevelResolver(LevelResolver.create().withDefaultLevel(ValidationReport.Level.ERROR).build())
            .build();

ValidationReport report = validator.validateRequest(SimpleRequest.Builder
    .post("/some-endpoint-from-spec")
    .withBody("{}")
    .build()
);

assertThat(report.hasErrors())
   .describedAs("Errors from the report: %s", report.getMessages())
   .isFalse();
log.info("Messages from the report: {}", report.getMessages());

JSON body is required for the my endpoint and the JSON object must contain several properties. OpenApiInteractionValidator considers correct following cases:

The only errors it has detected:

No message is produced in report, so this is not a case of errors being ignored.

Is the tool really that limited or am I missing something essential in configuration?


Solution

  • After some debugging.

    It seems the library does not reject and cannot verify requests without content type. After adding content type the library correctly spots all kind of errors.