Keep schemas in schemas/ and validate from a small custom library so Robot stays readable.
# SchemaValidator.pyimportjsonimportloggingfromjsonschemaimportDraft202012Validatorlogger=logging.getLogger(__name__)classSchemaValidator:defvalidate_json_string(self,body:str,schema:dict)->None:logger.debug("Validating JSON body against schema keys=%s",list(schema.keys()))instance=json.loads(body)Draft202012Validator(schema).validate(instance)
*** Keywords ***
Assert Ok Json
[Arguments] ${response}
Status Should Be 200 ${response}
Should Contain ${response.headers}[content-type] application/json
Validate Json Against Schema ${response.text} ${SCHEMA_LIST}
Cover 4xx (client) and representative 5xx (server or simulated faults). Assert machine-readable fields (code, detail) rather than free-text paragraphs.
*** Settings ***
Library Collections
Resource ../../resources/services/user_service.resource
Resource ../../resources/validators/api_validators.resource
*** Variables ***
${BASE_URL} %{API_BASE_URL}
*** Test Cases ***
User Registration Flow
${user}= Register New User Via Service
Profile Should Exist For User ${user}[id]
Invalid Login Is Rejected
Attempt Login With Bad Password expected_status=401