$schema: "http://json-schema.org/draft-06/schema#"
title: SDK Schema
description: The schema for the API Builder SDK definition.
type: object
properties:
  flow-nodes:
    type: object
    # must specify at least one flow-node.  however, this may change later
    # to allow plugging schemas.
    minProperties: 1
    additionalProperties:
      $ref: "#/definitions/flow-node"
required:
  - flow-nodes
additionalProperties: false
definitions:
  flow-node:
    $id: "#flow-node"
    description: A flow-node.
    type: object
    properties:
      name:
        type: string
        description: The friendly name of the flow-node as it appears in the UI.
      icon:
        oneOf:
          - type: string
          - type: "null"
      description:
        type: string
      category:
        type: string
      methods:
        type: object
        # must specify at least one method
        minProperties: 1
        additionalProperties:
          $ref: "#/definitions/method"
    required:
      - name
      - icon
      - description
      - category
    additionalProperties: false
  method:
    $id: "#method"
    description: A flow-node method.
    type: object
    properties:
      name:
        type: string
        description: The friendly name of the flow-node method as it appears in the UI.
      description:
        type: string
      parameters:
        type: object
        additionalProperties:
          $ref: "#/definitions/parameter"
      outputs:
        # must specify at least one output
        minProperties: 1
        additionalProperties:
          $ref: "#/definitions/output-spec"
      returns:
        $ref: "#/definitions/action-response"
      throws:
        $ref: "#/definitions/action-response"
    # parameters are optional
    oneOf:
      - required:
          - name
          - description
          - returns
          - throws
      - required:
          - name
          - description
          - outputs
    additionalProperties: false
  output-context:
    oneOf:
      - type: string
        pattern: \$\.
      - type: "null"
  output-spec:
    $id: "#output-spec"
    description: A flow-node output.
    type: object
    properties:
      name:
        type: string
        description: The friendly name of the output as it appears in the UI.
      description:
        type: string
        description: A description of the output.
      context:
        $ref: "#/definitions/output-context"
      schema:
        $ref: "http://json-schema.org/draft-06/schema#"
    # context, schema are optional
    required:
      - name
      - description
    additionalProperties: false
  action-response:
    type: object
    description: A flow-node action response that returns or throws.
    properties:
      name:
        type: string
        description: The friendly name of the output as it appears in the UI.
      description:
        type: string
        description: A description of the output.
      context:
        $ref: "#/definitions/output-context"
      schema:
        $ref: "http://json-schema.org/draft-06/schema#"
    # context, schema are optional
    required:
      - name
      - description
    additionalProperties: false
  parameter:
    type: object
    properties:
      name:
        type: string
        description: The friendly name of the method parameter as it appears in the UI.
      description:
        type: string
      required:
        type: boolean
      group:
        type: string
      initialType:
        $ref: "#/definitions/initialType"
      multilineWrapper:
        $ref: "#/definitions/multilineWrapper"
      schema:
        $ref: "http://json-schema.org/draft-06/schema#"
    # group, initialType and multilineWrapper are optional
    required:
      - name
      - description
      - required
      - schema
    additionalProperties: false
  initialType:
    type: string
    description: An parameter initial type option.
    enum:
      - string
      - number
      - boolean
      - object
      - array
      - "null"
      - credential
      - jsonpath
  multilineWrapper:
    type: object
    description: An multi-line wrapper option.
    properties:
      before:
        type: string
      after:
        type: string
    required:
      - before
      - after
    additionalProperties: false
