For POST/PUT endpoints whose content type is
application/json or application/xml, an optional Request
Schema tab is shown. When a schema is provided, the request body is
validated against it before the code snippet runs; on failure, the
request is rejected with a structured validation error
(RequestValidationError).
The accepted schema format depends on the content type:
- JSON (application/json): a JSON Schema (Draft 2020-12). The
field accepts both JSON and YAML syntax — YAML is convenient when
authoring schemas inline.
- XML (application/xml): an XML Schema (XSD).
Example JSON Schema (YAML form):
type: object
required: [name, qty]
properties:
name: { type: string }
qty: { type: integer, minimum: 1 }
Example XSD:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="greeting" type="xs:string"/>
</xs:schema>
Tip: when shipping endpoints from a module, the schema can live
in a separate file and be loaded into the field at install time using
the file attribute on the data record:
<field name="request_content_schema" type="char" file="endpoint/demo/content_schema.xsd" />