Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Other commands:

- [`avrotize pcf`](#create-the-parsing-canonical-form-pcf-of-an-avrotize-schema) - Create the Parsing Canonical Form (PCF) of an Avrotize Schema.
- [`avrotize validate`](#validate-json-instances-against-schemas) - Validate JSON instances against Avro or JSON Structure schemas.
- [`avrotize validate-tmsl`](#validate-tmsl-scripts-locally) - Validate TMSL scripts locally against documented object structure.

JSON Structure conversions:

Expand Down Expand Up @@ -1484,6 +1485,35 @@ avrotize validate events.jsonl --schema events.jstruct.json
avrotize validate data.json --schema schema.avsc --quiet
```

### Validate TMSL scripts locally

```bash
avrotize validate-tmsl [input] [--quiet]
```

Parameters:

- `[input]`: Path to the TMSL JSON file. If omitted, the file is read from stdin.
- `--quiet`: (optional) Suppress output. Exit code 0 if valid, 1 if invalid.

Validation notes:

- Performs local structural validation aligned with Microsoft TMSL object definitions for compatibility level 1200+.
- Validates `createOrReplace` command payload shape for the database/model/table/column path.
- Enforces documented column `dataType` enum values (`automatic`, `string`, `int64`, `double`, `dateTime`, `decimal`, `boolean`, `binary`, `unknown`, `variant`).
- Enforces strict object property checks (`additionalProperties: false`) for the validated subset.
- This is not a semantic engine validation; semantic checks still require execution against an XMLA endpoint.

Example:

```bash
# Validate a generated TMSL file
avrotize validate-tmsl model.tmsl.json

# CI mode with exit code only
avrotize validate-tmsl model.tmsl.json --quiet
```

### Convert JSON Structure schema to GraphQL schema

```bash
Expand Down
4 changes: 4 additions & 0 deletions avrotize/avrotojstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def build_type_definition(self, avro_schema, namespace, definitions):
props = {"name": name, "type": "object", "properties": {}, "required": []}
if "doc" in avro_schema:
props["description"] = avro_schema["doc"]
if isinstance(avro_schema.get("unique"), list):
props["x-avrotize-unique"] = avro_schema["unique"]
if isinstance(avro_schema.get("foreignKeys"), list):
props["x-avrotize-foreignKeys"] = avro_schema["foreignKeys"]

# Namespace for resolving field types within this record
record_fields_namespace = avro_schema.get("namespace", namespace)
Expand Down
Loading
Loading