Skip to content

Add runtime schema definition generation - #85

Open
CSullivan102 wants to merge 1 commit into
slackhq:masterfrom
CSullivan102:csullivan/runtime-schema-definition
Open

Add runtime schema definition generation#85
CSullivan102 wants to merge 1 commit into
slackhq:masterfrom
CSullivan102:csullivan/runtime-schema-definition

Conversation

@CSullivan102

Copy link
Copy Markdown

Summary

Adds an opt-in generateHackRuntimeSchemaDefinition schema flag that generates a static memoized getRuntimeSchemaDefinition(): dict<string, mixed> method on generated validators.

The runtime schema definition is self-contained for consumers that need the schema at runtime without reading or resolving the source JSON schema.

Behavior

The generated runtime definition:

  • resolves $ref values
  • preserves a local description / desc override on resolved refs
  • strips codegen-only metadata
  • strips $ref for hackIgnoreRef subtrees to avoid dangling runtime refs
  • converts desc to description
  • converts draft-04 boolean exclusiveMinimum / exclusiveMaximum to numeric bounds

Tests

  • ./vendor/bin/hacktest tests/RuntimeSchemaDefinitionTest.php
  • ./vendor/bin/hh-autoload && hh_server --check .
  • ./vendor/bin/hacktest tests
  • ./vendor/bin/hhast-lint src/Codegen/Codegen.php tests/RuntimeSchemaDefinitionTest.php

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
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.

2 participants