private static IEnumerable <HttpValidationError> ValidateBody( RouteSpecRequestBody body, JToken bodyContent, string contentType) { if (body == null) { yield return(ValidationError.UnexpectedContentType(contentType)); yield break; } if (bodyContent == null && body.Required) { yield return(ValidationError.BodyRequired()); yield break; } var schemaErrors = body.Schema.ValidateValue(bodyContent).ToArray(); if (schemaErrors.Any()) { yield return(ValidationError.InvalidBody(schemaErrors)); } }
public RouteSpecBuilder WithBody(JSchema schema, bool required = false) { var body = new RouteSpecRequestBody("application/json", required, schema, new List <string>()); Bodies.Add(body); return(this); }