Skip to content

feat: support PureQL specification 0.1.0-preview.2.0.1 - #76

Merged
kudima03 merged 2 commits into
mainfrom
feat/pureql-specification-0.1.0-preview.2.0.1
Oct 14, 2026
Merged

kudima03 merged 2 commits into
mainfrom
feat/pureql-specification-0.1.0-preview.2.0.1

Conversation

@kudima03

@kudima03 kudima03 commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

PureQLQueryDocumentTransformer could not transform the current PureQL specification (0.1.0-preview.2.0.1): it threw NullReferenceException inside Microsoft.OpenApi. Since 0.1.0-preview.1.0.0 the specification keeps its definitions in a flat draft 2020-12 $defs (add.decimal@row, declares.integer.nullable, …) instead of the nested definitions tree the transformer was written for, and it uses constructs Microsoft.OpenApi cannot read back. This PR makes the transformer produce a correct OpenAPI document from the current specification, keeps support for the older definitions layout, and tests it against the real specification, pinned as a submodule.

Equivalence was checked end to end: the transformed components, turned back into a JSON Schema, accept all 96 valid queries in samples/valid and reject all 1636 in samples/invalid with ajv, exactly like the original specification. Specifications 0.1.0-preview.0.5.0, 1.0.0, 2.0.0 and 2.0.1 all transform with no dangling $ref.

Changes

  • Read the flat $defs of current specifications: each entry becomes a component and #/$defs/... references are rewritten to #/components/schemas/.... The nested definitions tree of earlier specifications is still supported.
  • Map characters not allowed in OpenAPI component names to _ (add.decimal@row → add.decimal_row).
  • Drop $id and version from the Query schema along with $schema. Otherwise $id rebases every component $ref onto the specification's release URL.
  • Spell boolean subschemas ("right": true, "then": true) as {} / { "not": {} }. Microsoft.OpenApi reads them as null and throws.
  • Spell a non-string const as a one-value enum. Microsoft.OpenApi stores const as a string, which turned "const": true into "const": "True" and made valid queries invalid. A const next to an existing enum joins it through allOf, because an empty enum would be dropped.
  • Add the PureQL-Specification submodule at src/Tests/PureQL-Specification, pinned to tag 0.1.0-preview.2.0.1 (same layout as PureQL.CSharp.Model.Serialization), and check out submodules in the build-and-test workflow.
  • Add SpecificationTests against the real specification: every definition is emitted, component names are valid, no reference dangles or points outside the components, and boolean consts stay boolean.
  • Add FlatDefinitionsTests covering $defs naming, reference rewriting, metadata stripping, boolean subschemas in every position, and const handling.
  • Set the CI gates to the levels measured on this branch: COVERAGE_THRESHOLD 0 → 40 (line rate 40.83%, 265 / 649) and MUTATION_THRESHOLD 0 → 64 (mutation score 64.96%).
  • Update the README to describe the $defs / definitions handling and the normalizations.

Screenshots

Not applicable (no UI changes).

@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Complexity Health
PureQL.CSharp.Model.OpenAPI.Schema 41% 34% 345 ➖
Summary 41% (265 / 649) 34% (113 / 330) 345 ➖

Minimum allowed line rate is 40%

@kudima03
kudima03 merged commit 21d4627 into main Oct 14, 2026
1 check passed
@kudima03
kudima03 deleted the feat/pureql-specification-0.1.0-preview.2.0.1 branch October 14, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant