{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cosuno/json-schema/cosuno-optional-custom-field-create-request-schema.json",
  "title": "OptionalCustomFieldCreateRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cosuno-subcontractor-custom-fields-api-openapi.yml#/components/schemas/OptionalCustomFieldCreateRequest",
  "anyOf": [
    {
      "$ref": "#/$defs/OptionalCustomFieldRequestSelect"
    },
    {
      "$ref": "#/$defs/OptionalCustomFieldRequestNonSelect"
    }
  ],
  "$defs": {
    "CustomFieldSelectTypes": {
      "type": "string",
      "enum": [
        "singleSelect",
        "multiSelect"
      ]
    },
    "Exclude_CUSTOM_FIELD_TYPE.CustomFieldSelectTypes_": {
      "type": "string",
      "enum": [
        "number",
        "checkbox",
        "currency",
        "date",
        "dateTime",
        "text"
      ],
      "description": "Exclude from T those types that are assignable to U"
    },
    "OptionalCustomFieldRequestNonSelect": {
      "properties": {
        "label": {
          "type": "string",
          "description": "Display label shown to users when viewing or editing the custom field."
        },
        "position": {
          "type": "number",
          "format": "double",
          "description": "Zero-based position of the field in the list of custom fields. Must be between 0 and the current number of fields (inclusive)."
        },
        "type": {
          "$ref": "#/$defs/Exclude_CUSTOM_FIELD_TYPE.CustomFieldSelectTypes_",
          "description": "Non-select field type (e.g. `text`, `number`, `date`, `checkbox`)."
        }
      },
      "required": [
        "label",
        "position",
        "type"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "OptionalCustomFieldRequestSelect": {
      "properties": {
        "label": {
          "type": "string",
          "description": "Display label shown to users when viewing or editing the custom field."
        },
        "position": {
          "type": "number",
          "format": "double",
          "description": "Zero-based position of the field in the list of custom fields. Must be between 0 and the current number of fields (inclusive)."
        },
        "type": {
          "$ref": "#/$defs/CustomFieldSelectTypes",
          "description": "Single- or multi-select field type. When set, `options` must also be provided."
        },
        "options": {
          "items": {
            "properties": {
              "label": {
                "type": "string"
              }
            },
            "required": [
              "label"
            ],
            "type": "object"
          },
          "type": "array",
          "description": "The options that users can choose from when filling in this field."
        }
      },
      "required": [
        "label",
        "position",
        "type",
        "options"
      ],
      "type": "object",
      "additionalProperties": false
    }
  }
}