Closed vijayseid closed 1 year ago
@vijayseid Thanks, will take a look this issue
@vijayseid For your case, you put body type as null, which normally will not happen on API call. If we specify the json format on postman, it will have error as expected:
But for your case, I add a fix as well. And added two test cases for reference. Please take a look PR: https://github.com/mservicetech/openapi-schema-validation/pull/28
@GavinChenYan Thanks for the quick fix, great advantage of using this lib is lightening response & fix from developer .
@GavinChenYan @stevehu
Even though if pass the request body as empty or null, still it's not validating properly, I saw the change & made the same change on custom lib as well.
Passing as EMPTY :
Passing as NULL:
Can you please confirm you fix?
@GavinChenYan Confirmed, content type is application/json & my request body is null. Still it is not throwing the error for me
requestEntity.setContentType(MediaType.APPLICATION_JSON_VALUE);
Request body is null - >
Status is null ->
if I pass the body, it will say expected key is required & it is missing
Hi @GavinChenYan @stevehu Find a Bug on validating the Request body, could you please fix it.
OpenApiSpec has Mandatory field on request body, here is the piece of line added
RequestBody: required: - feature type: object properties: billerDivisionId: type: string description: Division Id for account, same as spc division id billerAccountNumber: type: string description: Account number in a billing system soloAccountId: type: string description: Account Id in SOLO feature: type: string description: 'Use case for which this token needs to be generated (example: enable-paperless-billing)' description: Billing details
Scenario 0 : Positive - Works as expected
Scenario 1 : Negative - Works as expected
If I Skip the field feature, I got the perfect validation says this field is required & it's missed.
Scenario 2 : Negative - Failed to pass
If I Skip the entire Request body(not passing any body), I Didn't get any validation error, & validation was successful. It should throw the same as scenario 1.