{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/typeship-dev/json-schema/typeship-dev-spec-schema.json",
  "title": "Spec",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/typeship-dev-openapi.json#/components/schemas/Spec",
  "type": "object",
  "required": [
    "id",
    "object",
    "project_id",
    "source",
    "format",
    "patches",
    "graphql",
    "diagnostic_policy",
    "revision_latest_id",
    "created_at",
    "updated_at",
    "request_id"
  ],
  "properties": {
    "id": {
      "$ref": "#/$defs/SpecId"
    },
    "object": {
      "type": "string",
      "const": "spec"
    },
    "project_id": {
      "$ref": "#/$defs/ProjectId"
    },
    "source": {
      "$ref": "#/$defs/SpecSource"
    },
    "format": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "openapi",
        "graphql",
        null
      ]
    },
    "patches": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SpecPatchResponse"
      }
    },
    "graphql": {
      "oneOf": [
        {
          "$ref": "#/$defs/GraphqlSettingsResponse"
        },
        {
          "type": "null"
        }
      ]
    },
    "diagnostic_policy": {
      "$ref": "#/$defs/DiagnosticPolicyResponse"
    },
    "revision_latest_id": {
      "oneOf": [
        {
          "$ref": "#/$defs/SpecRevisionId"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "request_id": {
      "$ref": "#/$defs/RequestId"
    }
  },
  "$defs": {
    "DiagnosticPolicyResponse": {
      "type": "object",
      "description": "Source pull-request enforcement threshold, new-versus-complete baseline, and explicitly reviewed rule or location exceptions.",
      "required": [
        "fail_on",
        "only_new",
        "suppressions"
      ],
      "properties": {
        "fail_on": {
          "type": "string",
          "enum": [
            "never",
            "error",
            "warning"
          ],
          "default": "error",
          "description": "Severity threshold that fails the API change review check."
        },
        "only_new": {
          "type": "boolean",
          "default": true,
          "description": "Enforce only occurrences introduced by the proposed source change."
        },
        "suppressions": {
          "type": "array",
          "default": [],
          "maxItems": 100,
          "items": {
            "$ref": "#/$defs/DiagnosticSuppressionResponse"
          }
        }
      }
    },
    "DiagnosticSuppressionResponse": {
      "type": "object",
      "required": [
        "rule_id",
        "reason"
      ],
      "properties": {
        "rule_id": {
          "type": "string",
          "maxLength": 160
        },
        "path": {
          "type": "string",
          "maxLength": 4096,
          "description": "Exact schema coordinate. Omit only to suppress every occurrence of the rule."
        },
        "reason": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500,
          "description": "The reviewed product decision behind this exception."
        }
      }
    },
    "GraphqlSettingsResponse": {
      "type": "object",
      "description": "What a GraphQL schema cannot say about itself. Ignored for OpenAPI specs.",
      "if": {
        "required": [
          "auth"
        ],
        "properties": {
          "auth": {
            "enum": [
              "api_key",
              "api_key_or_bearer"
            ]
          }
        }
      },
      "then": {
        "required": [
          "api_key_header"
        ]
      },
      "properties": {
        "endpoint": {
          "type": "string",
          "format": "uri",
          "description": "The URL every request is POSTed to; the generated client's default baseUrl. Defaults to the URL the schema was fetched from. Without either, baseUrl is a required client option."
        },
        "environments": {
          "type": "array",
          "maxItems": 10,
          "items": {
            "type": "object",
            "required": [
              "name",
              "url"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            }
          },
          "description": "Named endpoints (sandbox, production). Each becomes a client environment; the first is the default unless endpoint is set."
        },
        "auth": {
          "type": "string",
          "enum": [
            "bearer",
            "basic",
            "basic_api_key",
            "api_key",
            "api_key_or_bearer",
            "none"
          ],
          "default": "bearer",
          "description": "How requests authenticate. bearer sends Authorization: Bearer; basic is for key-pair APIs (public key as username, private key as password); basic_api_key sends one API key as the Basic-auth username with an empty password; api_key sends a header named by api_key_header; api_key_or_bearer sends a key in api_key_header (Authorization for a raw key) and also accepts an OAuth access token as Authorization: Bearer; none generates no auth option."
        },
        "api_key_header": {
          "type": "string",
          "description": "Header carrying the key when auth is api_key or api_key_or_bearer. Required for those modes; Typeship does not invent a vendor-specific header name."
        },
        "title": {
          "type": "string",
          "maxLength": 80,
          "description": "The API's name; drives the package and client names (\"Acme\" gives acme and AcmeClient). Defaults to a name derived from the endpoint's host."
        },
        "scalars": {
          "type": "object",
          "maxProperties": 100,
          "additionalProperties": {
            "type": "string",
            "enum": [
              "string",
              "integer",
              "number",
              "boolean",
              "json"
            ]
          },
          "description": "JSON representation of each custom scalar, keyed by GraphQL scalar name. Unmapped scalars generate as the language's untyped JSON value and produce a warning. Unmatched keys warn."
        },
        "error_types": {
          "type": "array",
          "maxItems": 100,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[_A-Za-z][_0-9A-Za-z]*$"
          },
          "description": "Object types that report a failure when an operation's union or interface result resolves to them (errors returned as data). Replaces the default, which is every member whose name ends in Error when the result can also be something else. An empty array treats no result as a failure. Names that are not object types in the schema produce a generation warning."
        },
        "page_size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000,
          "default": 100,
          "description": "Page size a paginated connection call sends as first when the caller passes neither first nor last. Relay servers such as GitHub reject a connection query without one. Ignored for a connection whose first argument has a schema default."
        }
      }
    },
    "ProjectId": {
      "type": "string",
      "pattern": "^prj_[a-z0-9]{16}$",
      "description": "Unique identifier for a project."
    },
    "RepositoryIdentifier": {
      "type": "string",
      "maxLength": 512,
      "description": "Provider-native repository identity, opaque outside its adapter."
    },
    "RepositoryProvider": {
      "type": "string",
      "enum": [
        "github"
      ],
      "description": "GitHub is the only launch provider; the field is stable for future adapters."
    },
    "RepositorySpecSource": {
      "type": "object",
      "required": [
        "type",
        "repository"
      ],
      "properties": {
        "type": {
          "type": "string",
          "const": "repository"
        },
        "repository": {
          "$ref": "#/$defs/RepositorySpecSourceSettings"
        }
      }
    },
    "RepositorySpecSourceSettings": {
      "type": "object",
      "required": [
        "provider",
        "identifier",
        "path"
      ],
      "properties": {
        "provider": {
          "$ref": "#/$defs/RepositoryProvider"
        },
        "identifier": {
          "$ref": "#/$defs/RepositoryIdentifier"
        },
        "path": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^(?!/)(?!.*\\.\\.).+$",
          "description": "Repository-relative Spec entrypoint."
        }
      }
    },
    "RequestId": {
      "type": "string",
      "pattern": "^req_[a-z0-9]{16}$",
      "description": "Server-generated identifier used to correlate this response with Typeship logs."
    },
    "SpecId": {
      "type": "string",
      "pattern": "^spec_[a-z0-9]{16}$",
      "description": "Unique identifier for a project's logical API Spec."
    },
    "SpecPatchResponse": {
      "type": "object",
      "description": "A fix applied to the resolved Spec before generation. Paths are JSON\nPointers into the document. A patch whose target no longer exists is\nskipped and reported as a warning on the generation, never silently.\n",
      "required": [
        "op",
        "path"
      ],
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "set",
            "append",
            "remove",
            "rename"
          ]
        },
        "path": {
          "type": "string",
          "description": "JSON-Pointer-style path. Pattern segments enable bulk fixes:\n* (any child), ** (any depth), [key=value] (filter), e.g.\n/paths/**/parameters/[name=account_id]/schema/type. Renaming a\nschema under /components/schemas also rewrites its $refs.\n"
        },
        "value": {
          "description": "set only; the replacement value."
        },
        "to": {
          "type": [
            "string",
            "null"
          ],
          "description": "rename only; the new key name."
        },
        "reason": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "SpecRevisionId": {
      "type": "string",
      "pattern": "^srev_[a-z0-9]{16}$",
      "description": "Unique identifier for an immutable resolved Spec Revision."
    },
    "SpecSource": {
      "oneOf": [
        {
          "$ref": "#/$defs/UrlSpecSource"
        },
        {
          "$ref": "#/$defs/RepositorySpecSource"
        }
      ],
      "description": "The single source of truth for where a Project's Spec lives."
    },
    "UrlSpecSource": {
      "type": "object",
      "required": [
        "type",
        "url"
      ],
      "properties": {
        "type": {
          "type": "string",
          "const": "url"
        },
        "url": {
          "$ref": "#/$defs/UrlSpecSourceSettings"
        }
      }
    },
    "UrlSpecSourceSettings": {
      "type": "object",
      "required": [
        "url",
        "headers_configured"
      ],
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "maxLength": 2048,
          "pattern": "^https?://",
          "description": "URL fetched for every generation."
        },
        "headers_configured": {
          "type": "boolean",
          "readOnly": true,
          "description": "Whether Typeship has stored write-only request headers for this URL."
        }
      }
    }
  }
}