public IActionResult ValidateFormat([FromBody] ValidateFormatRequest request) { var dataFormatService = _dataFormatServices.FirstOrDefault(x => x.Format == request.Format); if (dataFormatService == null) { return(BadRequest("The dataformat is not supported")); } var validationResult = dataFormatService.Validate(request.Content); var response = new ValidateFormatResponse { IsValid = validationResult.Success, ErrorMessage = validationResult.ErrorMessage }; return(Ok(response)); }
public async Task <IActionResult> ValidateFormatWithSchema([FromBody] ValidateFormatRequest request, [FromRoute] string schemaName) { var dataFormatService = _dataFormatServices.FirstOrDefault(x => x.Format == request.Format); if (dataFormatService == null) { return(BadRequest("The dataformat is not supported")); } var schema = await _schemaRepository.GetByNameAsync(schemaName); if (schema == null) { return(NotFound($"The schema with the name '{schemaName}' does not exist")); } var validationResult = dataFormatService.ValidateWithSchema(request.Content, schema.Schema); var response = new ValidateFormatResponse { IsValid = validationResult.Success, ErrorMessage = validationResult.ErrorMessage }; return(Ok(response)); }