跳到主要内容

YAML Form Syntax

The platform supports creating custom Issue templates using YAML syntax, which allows project maintainers to predefine fields that contributors need to fill in. Using YAML to build templates makes it easier to create and maintain templates, and also provides clear guidance for contributors to ensure they provide all necessary information. This simple help document hopes to be of assistance to you.

Basic Structure

A basic Issue template usually contains the following parts:

  • name: The name of the template (required).
  • description: The description of the template, guiding contributors on why and how to use this template (required).
  • title: The preset Issue title (optional).
  • labels: Tags automatically added to the Issue (optional).
  • assignees: Users automatically assigned (optional).
  • body: The body of the template, containing a series of fields to collect information (optional).

YAML Template Example

name: Bug Report
description: Use this template to report bugs in the software.
title: "[BUG] Specific Issue Name"
labels: ["bug"]
assignees:
- username1
- username2

body:
- type: markdown
attributes:
value: |
## Description of the Bug
Please describe the bug you encountered as thoroughly as possible.

- type: input
id: what-happened
attributes:
label: What happened?
description: Describe the problem in detail.
placeholder: Please enter detailed information
validations:
required: true

- type: textarea
id: reproduction
attributes:
label: Steps to Reproduce
description: Briefly describe how to reproduce this issue.
placeholder: 1. Go to '...'
2. Click '....'
3. Scroll down to '....'
4. See the error
validations:
required: true

- type: checkboxes
id: version
attributes:
label: Affected Version
description: Check all affected versions.
options:
- label: v1.0
required: false
- label: v2.0
required: false

- type: dropdown
id: os
attributes:
label: Operating System
description: The operating system you are using.
options:
- label: Windows
- label: macOS
- label: Linux
- label: Other
validations:
required: true

Form Element Definitions

KeyDescriptionRequiredTypeDefaultValid Values
typeThe type of the element.RequiredString-checkboxes
dropdown
input
markdown
textarea
idThe identifier of the element, unless type is set to markdown. It can only contain letters, numbers, -, and _. It must be unique within the form definition. If an id is configured, it serves as the canonical identifier for the field in the URL query parameter prefill.OptionalString--
attributesA set of key-value pairs defining the element's properties.RequiredMap--
validationsA set of key-value pairs setting constraints on the element.OptionalMap--

Explanation of Form Element Types

You can choose one of the following types of form elements. Each type has its own attributes and validations:

  • markdown: Used to add static text to provide additional context for users, but does not submit anything.
  • input: A single-line text field suitable for short text input.
  • textarea: A multi-line text field suitable for longer descriptions or explanations; contributors can also attach files in this field.
  • checkboxes: Multiple checkboxes allowing users to select multiple options.
  • dropdown: A dropdown menu allowing users to select one option from multiple options.

markdown

Used to add static text to provide additional context for users, but does not submit anything.

Attributes Definition

KeyDescriptionRequiredTypeDefaultValid Values
valueThe rendered text. Supports Markdown format.RequiredString--

YAML processing treats the hash symbol as a comment. To insert a Markdown heading, enclose the text in quotes. For multi-line text, you can use the pipe operator.

Here is an example:

body:
- type: markdown
attributes:
value: "## Thank you for your feedback on our project, which will make us better"
- type: markdown
attributes:
value: |
Thank you for taking a few minutes to give us feedback on our shortcomings.

input

A single-line text field suitable for short text input.

Attributes Definition

KeyDescriptionRequiredTypeDefaultValid Values
labelA short description expected from the user, also displayed in the form.RequiredString--
descriptionA description of the field providing context or guidance, displayed in the form.OptionalStringEmpty string
-
placeholderA semi-transparent placeholder shown when the field is empty.OptionalStringEmpty string-
valuePre-filled text in the field.OptionalString--

Validations Definition

KeyDescriptionRequiredTypeDefaultValid Values
requiredPrevents the form from being submitted before the element is completed. Applies only to public projects.OptionalBooleanfalse-

Here is an example:

body:
- type: input
id: input
attributes:
label: Frequency of the bug
description: "How often do you encounter this bug?"
placeholder: "For example: Once every two days when I access the login page"
validations:
required: true

textarea

A multi-line text field suitable for longer descriptions or explanations, where contributors can also attach files.

Attributes Definition

KeyDescriptionRequiredTypeDefaultValid Values
labelA short description expected from the user, also displayed in the form.RequiredString--
descriptionA description of the field providing context or guidance, displayed in the form.OptionalStringEmpty string
-
placeholderA semi-transparent placeholder shown when the field is empty.OptionalStringEmpty string-
valuePre-filled text in the field.OptionalString--
renderIf provided, the submitted text will be formatted as a code block. When this key is provided, the text area will not expand for file attachments or Markdown editing.OptionalString-Known languages. For more information, see language type definitions.

Validations Definition

KeyDescriptionRequiredTypeDefaultValid Values
requiredPrevents the form from being submitted before the element is completed. Applies only to public projects.OptionalBooleanfalse-

Here is an example:

body:
- type: textarea
id: repro
attributes:
label: Steps to Reproduce
description: "How did you trigger this bug? Please walk us through the steps to reproduce it."
value: |
1.
2.
3.
...
render: bash
validations:
required: true

checkboxes

Multiple checkboxes allowing users to select multiple options.

Attributes Definition

KeyDescriptionRequiredTypeDefaultValid Values
labelA short description expected from the user, also displayed in the form.RequiredString--
descriptionA description of the checkboxes, displayed in the form. Supports Markdown formatting.OptionalStringEmpty string
-
optionsA list of checkboxes the user can select from. See below for syntax.RequiredArray--

For each item in the options array, you can set the following keys.

KeyDescriptionRequiredTypeDefaultValid Values
labelThe identifier of the option, displayed in the form. Supports Markdown for bold or italic text formatting and hyperlinks.RequiredString--
requiredPrevents the form from being submitted before the element is completed. Applies only to public projects.OptionalBooleanfalse-

Validations Definition

KeyDescriptionRequiredTypeDefaultValid Values
requiredPrevents the form from being submitted before the element is completed. Applies only to public projects.OptionalBooleanfalse-

Here is an example:

body:
- type: checkboxes
id: operating-systems
attributes:
label: Which operating system are you using?
description: Select at least one.
options:
- label: macOS
- label: Windows
- label: Linux

A dropdown menu allowing users to select one option from multiple options.

Attributes Definition

KeyDescriptionRequiredTypeDefaultValid Values
labelA short description expected from the user, also displayed in the form.RequiredString--
descriptionA description of the field providing context or guidance, displayed in the form.OptionalStringEmpty string
-
multiple
Determines whether the user can select multiple options.OptionalBooleanfalse-
optionsThe options the user can select from. Must not be empty, and all options must be different.OptionalString array--
defaultThe index of the default selected option in the options array. When a default option is specified, "None" or "n/a" cannot be included as an option.Optionalint--

Validations Definition

KeyDescriptionRequiredTypeDefaultValid Values
requiredPrevents the form from being submitted before the element is completed. Applies only to public projects.OptionalBooleanfalse-

Here is an example:

body:
- type: dropdown
id: download
attributes:
label: How did you find out about this software?
options:
- AtomGit
- CSDN
- Github
default: 0
validations:
required: true