apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: conditional-fields
  title: Conditional fields
  description: Test conditional fields 
spec:
  parameters:
    - title: Choose if last name is required 
      properties:
        includeLast:
          title: Include last name?
          type: boolean
          default: true
    - title: Write your name
      required:
        - name
      properties:
        name:
          title: Name
          type: string
          description: Name
          ui:autofocus: true
        #  Conditional Field
        dependencies:
          includeLast:
            allOf:
              - if:
                  properties:
                    includeLast:
                      const: true
                then:
                  properties:
                    lastName:
                      title: Last Name
                      type: string
                  required:
                    - lastName
  steps:
    - id: log-hello
      name: Say hello
      action: debug:log
      input:
        message: Hello ${{ parameters.name parameters.lastName }}      
  output:
    text:
    - title: Success
      content: "Template completed"