From d64211e8a9829d5166959760429556d2394ab2e2 Mon Sep 17 00:00:00 2001 From: Sujoy Gupta Date: Mon, 27 Apr 2026 01:38:15 -0700 Subject: [PATCH] chore: Add precommit checks for JSON schema. --- .pre-commit-config.yaml | 18 ++++++++++++++++++ source/services/shopping/embedded.openrpc.json | 1 + source/services/shopping/mcp.openrpc.json | 1 + source/services/shopping/rest.openapi.json | 1 + 4 files changed, 21 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1077037d3..b59ec2b48 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,6 +25,24 @@ repos: - id: check-added-large-files - id: check-shebang-scripts-are-executable - id: check-executables-have-shebangs + # JSON Schema: validate UCP schema files against their declared meta-schema + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.33.0 + hooks: + - id: check-metaschema + files: ^source/(schemas|discovery)/.*\.json$ + - id: check-jsonschema + name: Validate OpenAPI definitions + files: ^source/(services/.*\.openapi\.json|handlers/.*/openapi\.json)$ + args: + - --schemafile + - https://spec.openapis.org/oas/3.1/schema/2022-10-07 + - id: check-jsonschema + name: Validate OpenRPC definitions + files: ^source/services/.*\.openrpc\.json$ + args: + - --schemafile + - https://meta.open-rpc.org/ # Python: Ruff - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.14.13 diff --git a/source/services/shopping/embedded.openrpc.json b/source/services/shopping/embedded.openrpc.json index 4210fea00..2c56872e7 100644 --- a/source/services/shopping/embedded.openrpc.json +++ b/source/services/shopping/embedded.openrpc.json @@ -2,6 +2,7 @@ "openrpc": "1.3.2", "info": { "title": "UCP Shopping Embedded Protocol", + "version": "draft", "description": "Embedded Protocol (EP) methods for the UCP shopping service. Methods are sent from Merchant to Host via postMessage using JSON-RPC 2.0. Method prefixes indicate capability scope: ep.{capability} (i.e. ep.checkout). Schema references are logical pointers - actual payload shape is determined by negotiated capabilities.\n\nEmbedded Protocol is a client-to-client postMessage interface, so there is no endpoint URL to access this API. Platforms detect merchant support for this protocol based on the presence of `services[\"dev.ucp.shopping\"][transport=embedded]` in discovery responses." }, "servers": [], diff --git a/source/services/shopping/mcp.openrpc.json b/source/services/shopping/mcp.openrpc.json index 6cc7e2c15..257a66c98 100644 --- a/source/services/shopping/mcp.openrpc.json +++ b/source/services/shopping/mcp.openrpc.json @@ -2,6 +2,7 @@ "openrpc": "1.3.2", "info": { "title": "UCP Shopping Service", + "version": "draft", "description": "Canonical MCP/JSON-RPC interface for UCP Shopping service. Schema references are logical pointers - actual payload shape is determined by negotiated capabilities.\n\n**Endpoint Resolution:** This spec defines methods only. The endpoint URL MUST be obtained from the merchant's discovery profile at `/.well-known/ucp` under `services[\"dev.ucp.shopping\"][transport=mcp].endpoint`. The server entry below is a placeholder for tooling compatibility." }, "servers": [ diff --git a/source/services/shopping/rest.openapi.json b/source/services/shopping/rest.openapi.json index a7896f972..c7d9f7f16 100644 --- a/source/services/shopping/rest.openapi.json +++ b/source/services/shopping/rest.openapi.json @@ -2,6 +2,7 @@ "openapi": "3.1.0", "info": { "title": "UCP Shopping Service", + "version": "draft", "description": "Canonical REST interface for UCP Shopping service. Schema references are logical pointers - actual payload shape is determined by negotiated capabilities.\n\n**Endpoint Resolution:** This spec defines operations only. The base URL MUST be obtained from the merchant's discovery profile at `/.well-known/ucp` under `services[\"dev.ucp.shopping\"][transport=rest].endpoint`. The `{endpoint}` server variable below is a placeholder for tooling compatibility." }, "servers": [