= TeDS Default Validation Report
:doctype: book
:toc: left
:toclevels: 3
:sectlinks:
:sectanchors:
:numbered:
:source-highlighter: rouge
:icons: font
:docinfo: shared

== Overview

[cols="1,3"]
|===
| Tool Version | teds {{ tool.version }}
| Specification Support | {{ tool.spec_supported }}
| Recommended Version | {{ tool.spec_recommended }}
| Generated | {{ timestamp }}
| Report File | {{ inputs[0].path }}
|===

{% set doc = inputs[0].doc %}
{% set success_count = 0 %}
{% set warning_count = 0 %}
{% set error_count = 0 %}
{% set schema_warnings = [] %}

== Executive Summary

{% if doc.tests %}
{# Use pre-computed counts from inputs[0].counts #}
{% set success_count = inputs[0].counts.success %}
{% set warning_count = inputs[0].counts.warning %}
{% set error_count = inputs[0].counts.error %}

{# Check for schema warnings and collect with proper anchors #}
{% for ref, grp in doc.tests.items() %}
  {% set valid_cases = (grp.valid or {}) %}
  {% set invalid_cases = (grp.invalid or {}) %}
  {% set ref_anchor = ref.replace('/', '_').replace('#', '_').replace('.', '_') %}

  {% if valid_cases|length == 0 %}
    {% set _ = schema_warnings.append({'text': ref + " has no valid test cases", 'anchor': ref_anchor}) %}
  {% endif %}
  {% if invalid_cases|length == 0 %}
    {% set _ = schema_warnings.append({'text': ref + " has no invalid test cases", 'anchor': ref_anchor}) %}
  {% endif %}
{% endfor %}

[.lead]
This report analyzes *{{ doc.tests|length }}* schema(s) with a total of *{{ success_count + warning_count + error_count }}* test cases.

=== Results Summary

[cols="2,1,3"]
|===
| Status | Count | Description

{% if success_count > 0 %}
| [green]#✓ SUCCESS# | {{ success_count }} | Test cases passed as expected
{% endif %}
{% if warning_count > 0 %}
| [yellow]#⚠ WARNING# | {{ warning_count }} | Test cases with warnings (review recommended)
{% endif %}
{% if error_count > 0 %}
| [red]#✗ ERROR# | {{ error_count }} | Test cases failed validation
{% endif %}
{% if success_count + warning_count + error_count == 0 %}
| [gray]#○ NO RESULTS# | 0 | No test cases found
{% endif %}

| *Total* | *{{ success_count + warning_count + error_count }}* | All test cases processed
|===

{% if schema_warnings %}
=== Schema Coverage Warnings

[WARNING]
====
The following schemas have incomplete test coverage:

{% for warning in schema_warnings %}
* <<{{ warning.anchor }},{{ warning.text }}>>
{% endfor %}

Consider adding both valid and invalid test cases for comprehensive schema validation.
====
{% endif %}

{% else %}
[CAUTION]
====
No test cases found in the specification. Consider adding test cases to validate your schemas.
====
{% endif %}

== Detailed Results

{% if doc.tests %}
{% for ref, grp in doc.tests.items() %}
{% set ref_anchor = ref.replace('/', '_').replace('#', '_').replace('.', '_') %}
[[{{ ref_anchor }}]]
=== {{ ref }}

{% set valid_cases = (grp.valid or {}) %}
{% set invalid_cases = (grp.invalid or {}) %}
{% set total_cases = valid_cases|length + invalid_cases|length %}

==== Schema Summary

[cols="1,1"]
|===
| Valid Cases | {{ valid_cases|length }}
| Invalid Cases | {{ invalid_cases|length }}
| Total Cases | {{ total_cases }}
|===

{% if valid_cases %}
==== Valid Test Cases

[cols="3,2,1,4"]
|===
| Test Case | Payload | Status | Message

{% for case_name, case_data in valid_cases.items() %}
| `{{ case_name }}`
a| [source,yaml]
----
{{ case_data.payload | to_yaml }}
----
{% if case_data.result == "SUCCESS" %}
| [green]#✓ SUCCESS#
{% elif case_data.result == "WARNING" %}
| [yellow]#⚠ WARNING#
{% elif case_data.result == "ERROR" %}
| [red]#✗ ERROR#
{% else %}
| [gray]#○ UNKNOWN#
{% endif %}
| {% if case_data.message %}{{ case_data.message }}{% endif %}{% if case_data.warnings %}{% if case_data.message %} +
+
*Warnings:*{% else %}*Warnings:*{% endif %}{% for warning in case_data.warnings %}{% if warning is string %} +
• {{ warning }}{% else %} +
• {{ warning.generated }}{% endif %}{% endfor %}{% endif %}
{% endfor %}
|===
{% endif %}

{% if invalid_cases %}
==== Invalid Test Cases

[cols="3,2,1,4"]
|===
| Test Case | Payload | Status | Message

{% for case_name, case_data in invalid_cases.items() %}
| `{{ case_name }}`
a| [source,yaml]
----
{{ case_data.payload | to_yaml }}
----
{% if case_data.result == "SUCCESS" %}
| [green]#✓ SUCCESS#
{% elif case_data.result == "WARNING" %}
| [yellow]#⚠ WARNING#
{% elif case_data.result == "ERROR" %}
| [red]#✗ ERROR#
{% else %}
| [gray]#○ UNKNOWN#
{% endif %}
| {% if case_data.message %}{{ case_data.message }}{% endif %}{% if case_data.warnings %}{% if case_data.message %} +
+
*Warnings:*{% else %}*Warnings:*{% endif %}{% for warning in case_data.warnings %}{% if warning is string %} +
• {{ warning }}{% else %} +
• {{ warning.generated }}{% endif %}{% endfor %}{% endif %}
{% endfor %}
|===
{% endif %}

{% if valid_cases|length == 0 and invalid_cases|length == 0 %}
[NOTE]
====
No test cases defined for this schema. Consider adding both valid and invalid test cases.
====
{% endif %}

{% endfor %}
{% endif %}

== Appendix

=== Tool Information

[cols="1,3"]
|===
| TeDS Version | {{ tool.version }}
| Supported Spec Range | {{ tool.spec_supported }}
| Recommended Spec Version | {{ tool.spec_recommended }}
| Report Generation Time | {{ timestamp }}
|===

=== Report Scope

This default report includes:

* **Executive Summary** - High-level overview of validation results
* **Schema Coverage Analysis** - Warnings for incomplete test coverage
* **Detailed Results** - Complete breakdown of all test cases by schema
* **Color-coded Status Indicators** - Visual distinction between SUCCESS, WARNING, and ERROR states
* **Tabular Format** - Structured presentation for easy analysis

For questions about this report or TeDS functionality, please refer to the TeDS documentation.

---
_This report was generated automatically by TeDS (Test-Driven Schema Development Tool)._
