{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/typeship-dev/json-schema/typeship-dev-spec-update-request-schema.json",
  "title": "SpecUpdateRequest",
  "description": "Omitted fields remain unchanged. Supplied objects and arrays replace the whole field. URL source headers are preserved when the URL is unchanged and headers are omitted; null or empty headers clear them.",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/typeship-dev-openapi.json#/components/schemas/SpecUpdateRequest",
  "type": "object",
  "additionalProperties": false,
  "minProperties": 1,
  "properties": {
    "source": {
      "$ref": "#/$defs/SpecSourceInput"
    },
    "patches": {
      "type": "array",
      "maxItems": 50,
      "items": {
        "$ref": "#/$defs/SpecPatch"
      },
      "description": "Replace all patches in order. An empty array removes every patch; null is invalid."
    },
    "graphql": {
      "description": "Replace all GraphQL settings. Null or an empty object clears them.",
      "oneOf": [
        {
          "$ref": "#/$defs/GraphqlSettings"
        },
        {
          "type": "null"
        }
      ]
    },
    "diagnostic_policy": {
      "$ref": "#/$defs/DiagnosticPolicy",
      "description": "Replace the complete policy and suppression list. Null and an empty object are invalid."
    }
  },
  "$defs": {
    "DiagnosticPolicy": {
      "type": "object",
      "additionalProperties": false,
      "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/DiagnosticSuppression"
          }
        }
      }
    },
    "DiagnosticSuppression": {
      "type": "object",
      "additionalProperties": false,
      "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."
        }
      }
    },
    "GraphqlSettings": {
      "type": "object",
      "additionalProperties": false,
      "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",
            "additionalProperties": false,
            "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."
        }
      }
    },
    "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."
    },
    "RepositorySpecSourceInput": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "repository"
      ],
      "properties": {
        "type": {
          "type": "string",
          "const": "repository"
        },
        "repository": {
          "$ref": "#/$defs/RepositorySpecSourceSettingsInput"
        }
      }
    },
    "RepositorySpecSourceSettingsInput": {
      "type": "object",
      "additionalProperties": false,
      "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."
        }
      }
    },
    "SpecPatch": {
      "type": "object",
      "additionalProperties": false,
      "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"
          ]
        }
      }
    },
    "SpecSourceInput": {
      "oneOf": [
        {
          "$ref": "#/$defs/UrlSpecSourceInput"
        },
        {
          "$ref": "#/$defs/RepositorySpecSourceInput"
        }
      ]
    },
    "UrlSpecSourceInput": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "url"
      ],
      "properties": {
        "type": {
          "type": "string",
          "const": "url"
        },
        "url": {
          "$ref": "#/$defs/UrlSpecSourceSettingsInput"
        }
      }
    },
    "UrlSpecSourceSettingsInput": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "url"
      ],
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "maxLength": 2048,
          "pattern": "^https?://",
          "description": "URL of an OpenAPI document, GraphQL SDL file, or GraphQL endpoint."
        },
        "headers": {
          "oneOf": [
            {
              "type": "object",
              "maxProperties": 20,
              "additionalProperties": {
                "type": "string",
                "maxLength": 4096
              }
            },
            {
              "type": "null"
            }
          ],
          "writeOnly": true,
          "description": "Request headers for a protected URL. Values are never returned or recorded in revision history. When updating the same URL, omit headers to preserve the stored values or pass null to remove them. Changing the URL without headers clears the old values so a credential is never forwarded to a different source."
        }
      }
    }
  }
}