0

Given a json schema built by swagger I'd like to validate a json requests and responses of my endpoints. If my json data has not all non-required fields, that are described in the schema, then no errors are returned. How can I modify/extend behavior to determine the absence of that fields?

I disassembled the schema and validator code and didn't found an easy way to override the behavior of the schema and of the validator.

var wholeSchema = JsonSchema.FromFileAsync("mypath\\myJson.json").GetAwaiter().GetResult(); var specificRequestSchema = wholeSchema.Definitions["specificRequest"]; var errors = specificRequestSchema.Validate(jsonData);

ASout
  • 21
  • 1
  • If its a swagger spec you need to read it with OpenApiDocument.ReadFileAsync and the validate using the request schema etc – Rico Suter Sep 09 '19 at 21:08
  • Nswag does not provide this out of the box abd the validator is for json schema but not for openapi (might be differen) – Rico Suter Sep 09 '19 at 21:09

0 Answers0