Enum Values validation for negative scenario.
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)
-
-
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
-
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).
-
Hoo Ok Navin,Will try it, Thank you so much
-
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.*;
-
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
-
- changed status to resolved
Closing due to inactivity. Please feel free to reopen if needed.
- Log in to comment
Can I clarify what the problem is? It looks like the validation filter is correctly reporting a failed validation…