fcode-json-schema
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFactorial Code — input parameter schemas
Factorial Code — 输入参数模式
A process's input parameters are defined by a JSON Schema in
. The same schema is what renders as a web
form, so designing the schema is designing the form. Values arrive in code as
(see / ).
parametersSchema.jsonfcode-formsfcode.context.parametersfcode-javascriptfcode-pythonSchemas render with react-jsonschema-form,
so its options apply.
ui:流程的输入参数由中的JSON Schema定义。该模式同时也是渲染为网页表单的依据,因此设计模式就是设计表单。参数值在代码中通过获取(详见 / )。
parametersSchema.jsonfcode-formsfcode.context.parametersfcode-javascriptfcode-python模式使用react-jsonschema-form进行渲染,因此其选项适用。
ui:How to author one
如何编写输入参数模式
- Top level is with a
"type": "object"map (one entry per field) and an optionalpropertiesarray.required - Pick a per field (
type,string,integer,number,boolean,array) and add validation (object/minimum,maximum,format/enum,oneOf, nesteduniqueItems).properties - Control rendering with a per-field object (e.g.
ui)."ui": { "ui:widget": "textarea" } - Open for a complete, copy-pasteable schema exercising every supported type — adapt fields from it rather than guessing the shape.
assets/parametersSchema.sample.json
- 顶级结构为,包含
"type": "object"映射(每个字段对应一个条目)和可选的properties数组。required - 为每个字段选择类型(
type、string、integer、number、boolean、array),并添加验证规则(object/minimum、maximum、format/enum、oneOf、嵌套uniqueItems)。properties - 通过每个字段的对象控制渲染(例如
ui)。"ui": { "ui:widget": "textarea" } - **打开**获取完整的、可复制粘贴的模式示例,涵盖所有支持的类型——建议从中调整字段,而非自行猜测结构。
assets/parametersSchema.sample.json
Field types & widgets (in the sample)
字段类型与组件(示例中包含)
- Text — ;
"type": "string";format: "email"ofui:widget,textarea,color, orhidden.file - Secret — masks the input (e.g. passwords/tokens).
"isSensitive": true - Numbers — /
integerwithnumber/minimum.maximum - Boolean — .
"type": "boolean" - Choices — (select),
enumofoneOf(labeled radio with{ const, title }), or an array withui:widget: "radio"+ui:widget: "checkboxes".uniqueItems - Structured — nested with its own
object/properties; arrays of strings or of objects (required+type: "array"); raw JSON viaitems."ui": { "ui:field": "json" } - Conditional fields — use top-level to show/hide fields based on another field's value (see
dependenciesin the sample).anotherBooleanField
- 文本 — ;
"type": "string";format: "email"可选ui:widget、textarea、color或hidden。file - 敏感信息 — 会屏蔽输入内容(如密码/令牌)。
"isSensitive": true - 数字 — /
integer类型,可设置number/minimum。maximum - 布尔值 — 。
"type": "boolean" - 选择项 — (下拉选择)、
enum搭配oneOf(带标签的单选框,需设置{ const, title }),或数组类型搭配ui:widget: "radio"+ui:widget: "checkboxes"。uniqueItems - 结构化数据 — 嵌套,包含自身的
object/properties;字符串数组或对象数组(required+type: "array");通过items支持原始JSON输入。"ui": { "ui:field": "json" } - 条件字段 — 使用顶级根据其他字段的值显示/隐藏字段(详见示例中的
dependencies)。anotherBooleanField
Gotchas
注意事项
- A file field () is auto-uploaded to Storage before the process runs; the parameter arrives as an
"ui:widget": "file"reference, not the file contents. Strip the prefix beforefcode.storage://….fcode.storage.download(...) - only affects display/masking — still read the value from a secret variable, never hardcode it.
isSensitive: true - The schema is the single source of the form's fields — to change fields, edit the schema, not the form embed code.
- The schema is data, not code. It cannot carry executable JavaScript:
and
embedFormOptions.onChangewere removed, andembedFormOptions.fields.<field>.transformFncontent is sanitized (norawHtml, no inline<script>handlers, noon*URLs). Client-side behaviour belongs in the embedding page — seejavascript:.fcode-forms - Visible text can be translated: schema strings (titles, descriptions,
) accept
ui:placeholdertokens, substituted server-side before the form is served — seefcode.i18n("key").fcode-i18n
- 文件字段()会在流程运行前自动上传至Storage;参数会以
"ui:widget": "file"引用的形式传入,而非文件内容。调用fcode.storage://…前需移除该前缀。fcode.storage.download(...) - ****仅影响显示/屏蔽——仍需从机密变量中读取值,切勿硬编码。
isSensitive: true - 模式是表单字段的唯一数据源——如需修改字段,请编辑模式,而非表单嵌入代码。
- 模式是数据,而非代码。它无法承载可执行JavaScript:和
embedFormOptions.onChange已被移除,embedFormOptions.fields.<field>.transformFn内容会被 sanitize(不允许rawHtml、内联<script>处理程序、on*URL)。客户端行为应放在嵌入页面中——详见javascript:。fcode-forms - 可见文本可翻译:模式中的字符串(标题、描述、)支持
ui:placeholder令牌,表单在服务端渲染前会替换这些令牌——详见fcode.i18n("key")。fcode-i18n