added script to generate open api scheme automatically - execute with npm run watch:openapi

This commit is contained in:
GotthardG
2024-11-08 11:28:12 +01:00
parent 501d09e6aa
commit 1fa61f0e78
5 changed files with 649 additions and 96 deletions

View File

@ -79,17 +79,20 @@ async def validate_cell(data: dict):
importer = SampleSpreadsheetImporter()
# Determine the expected type based on column name
# Ensure we've cleaned the value before validation
expected_type = importer.get_expected_type(col_name)
# Clean and validate the cell value
cleaned_value = importer._clean_value(value, expected_type)
logger.info(f"Validating cell: row {row_num}, column {col_name}, value {cleaned_value}")
try:
# Validate the cleaned value using the SpreadsheetModel (Pydantic validation)
SpreadsheetModel(**{col_name: cleaned_value})
# Construct a dictionary with the expected format for validation
validation_data = {col_name: cleaned_value}
SpreadsheetModel(**validation_data)
logger.info(f"Validation succeeded for row {row_num}, column {col_name}")
return {"is_valid": True, "message": ""}
except ValidationError as e:
# If validation fails, return the first error message
# Extract the first error message
message = e.errors()[0]['msg']
logger.error(f"Validation failed for row {row_num}, column {col_name}: {message}")
return {"is_valid": False, "message": message}