# JSON Schema

> Validate a map with any tool, and editor support for the files.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://cases.docs.sypnia.com/format/json-schema/

For agents: Schemas (JSON Schema 2020-12): https://cases.sypnia.com/schema/v1/map.json, navigation.json and case.json, plus event.json for the event envelope (served as application/json), also shipped in @sypnia/cases (`@sypnia/cases/spec`: mapSchema, navigationSchema, caseSchema, eventSchema; parseMap(dir) then validateMap(map) → { ok, errors: [{ file, path, line, message, kind }], findings }; and the files in the package's schema/ folder). Add `# yaml-language-server: $schema=...` for editor completion. The format is open for anyone to implement.

Three schemas describe the format, in JSON Schema 2020-12, and a fourth the envelope of every event:

| File                                                                                                         | Schema                                               |
| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------- |
| `cases/map.yaml`                                                                                             | `https://cases.sypnia.com/schema/v1/map.json`        |
| `cases/navigation.yaml`                                                                                      | `https://cases.sypnia.com/schema/v1/navigation.json` |
| `cases/**/*.case.yaml`                                                                                       | `https://cases.sypnia.com/schema/v1/case.json`       |
| an event ([What each event carries](https://cases.docs.sypnia.com/runtime/delivery#what-each-event-carries)) | `https://cases.sypnia.com/schema/v1/event.json`      |

They also ship inside the package, for offline use, as exports and as files in its `schema/` folder:

```ts
import { mapSchema, navigationSchema, caseSchema, eventSchema, parseMap, validateMap } from '@sypnia/cases/spec';

const map = await parseMap('cases');
const result = validateMap(map); // { ok, errors: [{ file, path, line, message, kind }], findings }
```

## In your editor

Add the schema line at the top of a file and editors with YAML support complete fields and show errors as you type:

```yaml
# yaml-language-server: $schema=https://cases.sypnia.com/schema/v1/case.json
id: place-order
```

`npx @sypnia/cases init` adds it for you.
