Enum Values validation for negative scenario.

Issue #227 resolved
Former user created an issue

Hi ,

While working on negative scenarios, sending wrong value(non existing enum value) to an enum field, it is throwing an error as-

com.atlassian.oai.validator.restassured.OpenApiValidationFilter$OpenApiValidationException: "message" : "[Path '/Success'] Instance value ("not yet") not found in enum (possible values: ["yes","no"])",

Comments (7)

  1. James Navin

    Can I clarify what the problem is? It looks like the validation filter is correctly reporting a failed validation…

  2. Dhanya

    I want to send the request to URl and then validate the response as malformed request which i am not able to do through openApiValidationFilter. So, is there any possibility to check that condition

  3. James Navin

    Ah I see.

    One approach to this is to create a filter that only applies validations to the response. Something like:

    private val responseOnlyValidator = SwaggerRequestResponseValidator
            .createFor(swaggerSpec)
            .withLevelResolver(
                LevelResolver.create().withLevel("validation.request", ValidationReport.Level.IGNORE).build()
            )
            .build()
    
    private val responseOnlyValidation = SwaggerValidationFilter(responseOnlyValidator);
    

    Then you can use the responseOnlyValidation filter in your test clauses.

    If you need finer-grained control over the request behavior you can also look at using the whitelist mechanism (see the README for details).

  4. Dhanya

    SwaggerValidationFilter(responseOnlyValidator)-> I am getting error to create a class for this, is there any dependency that i have to include except com.atlassian.oai.validator.*;

  5. Dhanya

    Hi Navin, I am not able to solve the issue. Could you please explain it more briefly. Right now i am using Openapivalidationfilter and while sending request .filter(new openapirequestvalidator(new File(yaml file))).

    So could you please help m on this

  6. Log in to comment