Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }