schemaorg-validate 0.3.0

Parse and validate Schema.org structured data (JSON-LD, Microdata, RDFa) against the official vocabulary and Google Rich Results profiles.
Documentation
# CLI Reference

`schemaorg-validate` -- validate Schema.org structured data in HTML.

## Installation

```bash
cargo install schemaorg-validate
```

## Synopsis

```
schemaorg-validate [OPTIONS]
```

Exactly one input source is required: `--file`, `--url`, or `--stdin`.

## Options

### Input (mutually exclusive)

| Option | Description |
|--------|-------------|
| `--file <PATH>` | Path to a local HTML file |
| `--url <URL>` | URL to fetch and validate |
| `--stdin` | Read HTML from standard input |

### Validation

| Option | Default | Description |
|--------|---------|-------------|
| `--profile <PROFILE>` | `google` | Validation profile: `google`, `baseline`, `none` |
| `--severity <LEVEL>` | `warning` | Minimum severity: `error`, `warning`, `info` |

### Output

| Option | Default | Description |
|--------|---------|-------------|
| `--format <FORMAT>` | `text` | Output format: `text`, `json`, `sarif` |
| `--no-color` | | Disable colored output (also respects `NO_COLOR` env) |
| `--quiet` | | Suppress output, exit code only |

### Other

| Option | Description |
|--------|-------------|
| `--schema-version` | Print the vendored Schema.org version and exit |
| `--version` | Print the tool version and exit |
| `--help` | Print help information |

## Exit Codes

| Code | Meaning |
|------|---------|
| `0` | No validation errors found |
| `1` | Validation errors found (or profile not eligible) |
| `2` | Input error (file not found, HTTP error, etc.) |

## Output Formats

### Text (default)

Human-readable colored output with sections for vocabulary diagnostics
and profile results:

```
-- schemaorg-validate ----------------------------------------
  Source:  page.html
  Profile: google-rich-results
  Schema.org: v30.0

  ✓ No vocabulary issues found

-- Profile Results ------------------------------------------
  Product: ELIGIBLE
    Recommended missing: sku, gtin/isbn/mpn

  Eligibility: Eligible (with warnings)

  0 error(s), 3 warning(s)
```

### JSON

Structured JSON with extraction metadata, vocabulary diagnostics, and
optional profile results:

```json
{
  "source": "page.html",
  "schema_version": "30.0",
  "extraction": {
    "node_count": 1,
    "formats": ["JsonLd"],
    "warning_count": 0
  },
  "vocabulary": {
    "diagnostics": [...],
    "error_count": 0,
    "warning_count": 0
  },
  "profile": {
    "eligibility": "WarningsOnly",
    "type_results": [...],
    "diagnostics": [...]
  }
}
```

### SARIF

[SARIF 2.1.0](https://sarifweb.azurewebsites.net/) output compatible with
GitHub Code Scanning and other static analysis tools:

```json
{
  "$schema": "https://...sarif-schema-2.1.0.json",
  "version": "2.1.0",
  "runs": [{
    "tool": {
      "driver": {
        "name": "schemaorg-validate",
        "rules": [...]
      }
    },
    "results": [...]
  }]
}
```

### SARIF Rule IDs

| ID | Diagnostic |
|----|-----------|
| `SCHEMA001` | Unknown type |
| `SCHEMA002` | Unknown property |
| `SCHEMA003` | Invalid value type |
| `SCHEMA004` | Deprecated type |
| `SCHEMA005` | Deprecated property |
| `SCHEMA006` | Property not for type |
| `SCHEMA007` | Pending type |
| `SCHEMA008` | Pending property |
| `SCHEMA009` | Expected URL got text |
| `SCHEMA010` | Expected text got node |
| `SCHEMA011` | Invalid enum value |
| `SCHEMA012` | Invalid boolean |
| `SCHEMA013` | Invalid number |
| `PROFILE001` | Required field missing |
| `PROFILE002` | Recommended field missing |
| `PROFILE003` | Nested required field missing |
| `PROFILE004` | Invalid field value |
| `PROFILE005` | Eligibility restricted |

## Examples

### Validate a local file with Google profiles

```bash
schemaorg-validate --file index.html --profile google
```

### Validate a URL and get JSON output

```bash
schemaorg-validate --url https://example.com/product --format json
```

### Pipe HTML through stdin

```bash
curl -s https://example.com | schemaorg-validate --stdin --profile google
```

### CI integration: fail on errors only

```bash
schemaorg-validate --file dist/index.html --quiet --profile google
if [ $? -eq 1 ]; then
  echo "Structured data has errors"
  exit 1
fi
```

### Generate SARIF for GitHub Code Scanning

```bash
schemaorg-validate --file page.html --format sarif > results.sarif
```

### Vocabulary validation only (no profile)

```bash
schemaorg-validate --file page.html --profile none
```

### Show only errors (hide warnings)

```bash
schemaorg-validate --file page.html --severity error
```

### Check Schema.org version

```bash
schemaorg-validate --schema-version
# Schema.org v30.0
```