$schema: https://json-schema.org/draft/2020-12/schema
$id: Form.yaml
type: object
properties:
  id:
    $ref: uuid.yaml
    description: The form's unique identifier.
  name:
    type: string
    description: The form's name.
  description:
    type: string
    description: The form's description.
  instructions:
    anyOf:
      - type: string
      - type: array
        items:
          $ref: File.yaml
    description: The form's instructions.
  jsonSchema:
    $ref: FormJsonSchema.yaml
    description: The form's JSON schema used to render the form and validate responses.
  uiSchema:
    $ref: FormUISchema.yaml
    description: The form's UI schema used to render the form in the browser.
  mappingToCommonGrants:
    $ref: MappingSchema.yaml
    description: A mapping from form schema to CommonGrants schema.
  mappingFromCommonGrants:
    $ref: MappingSchema.yaml
    description: A mapping from CommonGrants schema to form schema.
  customFields:
    $ref: '#/$defs/RecordCustomField'
    description: Custom attributes about the form itself, not custom fields within the form.
  createdAt:
    type: string
    format: date-time
    description: The timestamp (in UTC) at which the record was created.
  lastModifiedAt:
    type: string
    format: date-time
    description: The timestamp (in UTC) at which the record was last modified.
required:
  - id
  - name
  - createdAt
  - lastModifiedAt
unevaluatedProperties:
  not: {}
examples:
  - id: b7c1e2f4-8a3d-4e2a-9c5b-1f2e3d4c5b6a
    name: Form A
    description: Form A description
    instructions: Form A instructions
    jsonSchema:
      $id: formA.json
      type: object
      properties:
        name:
          first:
            type: string
          last:
            type: string
        email:
          type: string
        phone:
          type: string
    uiSchema:
      type: VerticalLayout
      elements:
        - type: Group
          label: Name
          elements:
            - type: Control
              scope: '#/properties/name/first'
            - type: Control
              scope: '#/properties/name/last'
        - type: Control
          scope: '#/properties/email'
        - type: Control
          scope: '#/properties/phone'
    mappingToCommonGrants:
      name:
        firstName:
          field: name.first
        lastName:
          field: name.last
      emails:
        primary:
          field: email
      phones:
        primary:
          field: phone
    mappingFromCommonGrants:
      name:
        first:
          field: name.firstName
        last:
          field: name.lastName
      email:
        field: emails.primary
      phone:
        field: phones.primary
    createdAt: '2025-01-01T17:01:01.000Z'
    lastModifiedAt: '2025-01-02T17:30:00.000Z'
description: A form for collecting data from a user.
$defs:
  RecordCustomField:
    type: object
    properties: {}
    unevaluatedProperties:
      $ref: CustomField.yaml
