- id: schema/scalar
  anyOf:
    - number
    - boolean
    - string

- id: schema/description
  anyOf:
    - string
    - object:
        properties:
          short: string
          long: string

- id: schema/base
  object:
    properties:
      additionalCompletions:
        arrayOf: string
      completions:
        arrayOf: string
      id: string
      hidden: boolean
      tags: object
      description:
        ref: schema/description

- id: schema/enum
  object:
    properties:
      enum:
        anyOf:
          - arrayOf:
              ref: schema/scalar
          - object:
              super:
                resolveRef: schema/base
              properties:
                values:
                  arrayOf:
                    ref: schema/scalar

- id: schema/null
  object:
    properties:
      null:
        ref: schema/schema

- id: schema/explicit-schema
  object:
    super:
      resolveRef: schema/base
    properties:
      schema:
        ref: schema/schema

- id: schema/string
  anyOf:
    - object:
        super:
          resolveRef: schema/base
        properties:
          pattern: string
    - object:
        properties:
          string:
            ref: schema/schema
          path:
            ref: schema/schema
          pattern:
            ref: schema/schema

- id: schema/number
  object:
    properties:
      number:
        ref: schema/schema

- id: schema/boolean
  object:
    properties:
      boolean:
        ref: schema/schema

- id: schema/ref
  object:
    super:
      resolveRef: schema/base
    properties:
      ref: string

- id: schema/maybe-array-of
  object:
    super:
      resolveRef: schema/base
    properties:
      maybeArrayOf:
        ref: schema/schema

- id: schema/array-of
  object:
    super:
      resolveRef: schema/base
    properties:
      arrayOf:
        ref: schema/schema

- id: schema/all-of
  object:
    properties:
      allOf:
        anyOf:
          - arrayOf:
              ref: schema/schema
          - object:
              super:
                resolveRef: schema/base
              properties:
                schemas:
                  arrayOf:
                    ref: schema/schema

- id: schema/any-of
  object:
    properties:
      anyOf:
        anyOf:
          - arrayOf:
              ref: schema/schema
          - object:
              super:
                resolveRef: schema/base
              properties:
                schemas:
                  arrayOf:
                    ref: schema/schema

- id: schema/record
  object:
    properties:
      record:
        anyOf:
          - object:
              properties:
                properties:
                  object:
                    additionalProperties:
                      ref: schema/schema
            additionalProperties:
              ref: schema/schema
          - object:
              additionalProperties:
                ref: schema/schema

- id: schema/object
  object:
    properties:
      namingConvention:
        anyOf:
          - enum: ["ignore"]
          - arrayOf:
              enum:
                # because this particular setup is especially likely to lead to typos,
                # we support all naming conventions in describing naming conventions
                - "camelCase"
                - "camel-case"
                - "camel_case"
                - "capitalizationCase"
                - "capitalization-case"
                - "capitalization_case"
                - "underscoreCase"
                - "underscore-case"
                - "underscore_case"
                - "snakeCase"
                - "snake-case"
                - "snake_case"
                - "dashCase"
                - "dash-case"
                - "dash_case"
                - "kebabCase"
                - "kebab-case"
                - "kebab_case"
      properties:
        object:
          additionalProperties:
            ref: schema/schema
      patternProperties:
        object:
          additionalProperties:
            ref: schema/schema
      propertyNames:
        ref: schema/schema
      additionalProperties:
        ref: schema/schema
      super:
        ref: schema/schema
      required:
        anyOf:
          - enum: ["all"]
          - arrayOf: string
      completions:
        arrayOf: string

- id: schema/schema
  anyOf:
    - ref: schema/enum
    - ref: schema/null
    - ref: schema/explicit-schema
    - ref: schema/string
    - ref: schema/number
    - ref: schema/boolean
    - ref: schema/ref
    - ref: schema/any-of
    - ref: schema/all-of
    - ref: schema/record
    - ref: schema/object
    - enum: ["number", "boolean", "path", "string", "null", "object"]
  description: "be a yaml schema"

- id: schema/schema-field
  object:
    properties:
      name: string
      schema:
        ref: schema/schema
      hidden: boolean
      alias: string
      disabled:
        maybeArrayOf: string
      enabled:
        maybeArrayOf: string
      description:
        ref: schema/description
      tags: object
    required: ["name", "schema", "description"]
