openapi: 3.1.0
info:
  title: Dagweave template catalogue
  version: "1"
  summary: Static, read-only JSON and YAML for the Dagweave Argo WorkflowTemplate catalogue.
  description: |
    Every document is a static file, so any static host serves this API. Fields are
    added but never renamed or removed within v1. A version's template.yaml never
    changes after release, and documents carry no timestamps.
  license:
    name: Apache License 2.0
    identifier: Apache-2.0
servers:
  - url: https://catalog.dagweave.com/api/v1
paths:
  /index.json:
    get:
      operationId: getIndex
      summary: Every item in the catalogue
      responses:
        "200":
          description: The index.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Index" }
  /search-index.json:
    get:
      operationId: getSearchIndex
      summary: A flat index for client-side search
      responses:
        "200":
          description: The search index.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/SearchIndex" }
  /items/{name}.json:
    get:
      operationId: getItem
      summary: One item with its parameters, images and versions
      parameters:
        - $ref: "#/components/parameters/Name"
      responses:
        "200":
          description: The item.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Item" }
        "404": { description: No such item. }
  /items/{name}/{version}.json:
    get:
      operationId: getItemVersion
      summary: One version of an item, with install commands and the template
      parameters:
        - $ref: "#/components/parameters/Name"
        - $ref: "#/components/parameters/Version"
      responses:
        "200":
          description: The version.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/VersionDoc" }
        "404": { description: No such item or version. }
  /items/{name}/{version}/template.yaml:
    get:
      operationId: getTemplate
      summary: The raw Argo WorkflowTemplate of a version
      description: Only versions with installable true have a template.yaml.
      parameters:
        - $ref: "#/components/parameters/Name"
        - $ref: "#/components/parameters/Version"
      responses:
        "200":
          description: The WorkflowTemplate, byte for byte as pinned.
          content:
            application/yaml:
              schema: { type: string }
        "404": { description: No such item, or a version whose manifest is not vendored. }
  /openapi.yaml:
    get:
      operationId: getOpenAPI
      summary: This description
      responses:
        "200":
          description: OpenAPI 3.1 document.
          content:
            application/yaml:
              schema: { type: string }
components:
  parameters:
    Name:
      name: name
      in: path
      required: true
      description: The item id, which is also the WorkflowTemplate name.
      schema: { type: string, examples: [slack-post-message] }
    Version:
      name: version
      in: path
      required: true
      description: A semver from the item's changelog, or latest.
      schema: { type: string, examples: ["1.0.1", latest] }
  schemas:
    Count:
      type: object
      required: [name, count]
      properties:
        name: { type: string }
        count: { type: integer }
    Image:
      type: object
      required: [ref, repository, digest]
      properties:
        ref: { type: string, description: The image reference as written in the template. }
        repository: { type: string }
        tag: { type: string, description: The tag the digest was taken from, when the template records it. }
        digest: { type: string, pattern: "^sha256:[0-9a-f]{64}$" }
    Parameter:
      type: object
      required: [name, required]
      properties:
        name: { type: string }
        title: { type: string }
        description: { type: string }
        type: { type: string }
        required: { type: boolean }
        default: { type: string }
        enum: { type: array, items: { type: string } }
        example: { type: string }
    VersionSummary:
      type: object
      required: [version, latest, installable, url]
      properties:
        version: { type: string }
        date: { type: string, format: date }
        notes: { type: string }
        latest: { type: boolean }
        installable: { type: boolean, description: True when template.yaml exists for this version. }
        url: { type: string, format: uri }
        templateUrl: { type: string, format: uri }
    IndexItem:
      type: object
      required: [name, title, description, category, tags, latestVersion, versions, parameters, images, url, templateUrl, page]
      properties:
        name: { type: string }
        title: { type: string }
        description: { type: string }
        category: { type: string }
        tags: { type: array, items: { type: string } }
        latestVersion: { type: string }
        versions: { type: array, items: { type: string }, description: Newest first. }
        parameters: { type: array, items: { type: string } }
        images: { type: array, items: { type: string } }
        url: { type: string, format: uri }
        templateUrl: { type: string, format: uri }
        page: { type: string, format: uri }
    Index:
      type: object
      required: [apiVersion, catalogSha, count, categories, tags, items]
      properties:
        apiVersion: { const: v1 }
        catalogSha: { type: string }
        count: { type: integer }
        categories: { type: array, items: { $ref: "#/components/schemas/Count" } }
        tags: { type: array, items: { $ref: "#/components/schemas/Count" } }
        items: { type: array, items: { $ref: "#/components/schemas/IndexItem" } }
    Item:
      allOf:
        - $ref: "#/components/schemas/IndexItem"
        - type: object
          required: [entrypoint, parameterDetails, imageDetails, versionDetails, source, catalogSha]
          properties:
            entrypoint: { type: string }
            parameterDetails: { type: array, items: { $ref: "#/components/schemas/Parameter" } }
            imageDetails: { type: array, items: { $ref: "#/components/schemas/Image" } }
            versionDetails: { type: array, items: { $ref: "#/components/schemas/VersionSummary" } }
            source: { type: string, format: uri }
            catalogSha: { type: string }
    VersionDoc:
      allOf:
        - $ref: "#/components/schemas/VersionSummary"
        - type: object
          required: [name, title, category, tags, entrypoint, parameters, images, source, catalogSha]
          properties:
            name: { type: string }
            title: { type: string }
            category: { type: string }
            tags: { type: array, items: { type: string } }
            entrypoint: { type: string }
            parameters: { type: array, items: { $ref: "#/components/schemas/Parameter" } }
            images: { type: array, items: { $ref: "#/components/schemas/Image" } }
            install:
              type: object
              required: [kubectl, argo]
              properties:
                kubectl: { type: string }
                argo: { type: string }
            template: { type: string, description: The WorkflowTemplate YAML, present when installable. }
            templateSha256: { type: string }
            source: { type: string, format: uri }
            catalogSha: { type: string }
    SearchIndex:
      type: object
      required: [apiVersion, items]
      properties:
        apiVersion: { const: v1 }
        items:
          type: array
          items:
            type: object
            required: [name, title, description, category, tags, parameters, images, version, url, text]
            properties:
              name: { type: string }
              title: { type: string }
              description: { type: string }
              category: { type: string }
              tags: { type: array, items: { type: string } }
              parameters: { type: array, items: { type: string } }
              images: { type: array, items: { type: string } }
              version: { type: string }
              url: { type: string, format: uri }
              text: { type: string, description: Lower-cased text of every searchable field. }
