feat(examples): add examples.yaml JSON schema and examples-validate tool#4908
Draft
timotheeguerin wants to merge 1 commit into
Draft
feat(examples): add examples.yaml JSON schema and examples-validate tool#4908timotheeguerin wants to merge 1 commit into
timotheeguerin wants to merge 1 commit into
Conversation
Add @azure-tools/typespec-azure-examples, the foundational piece of the Unified Examples Format epic (#4831, issue #4832): - examples.yaml JSON Schema authored in TypeSpec (schema/examples-yaml.tsp) and compiled via @typespec/json-schema. - examples-validate CLI + programmatic API that runs structural (ajv) validation plus the RFC section 3 semantic rules: metadata keys, integer-only status codes, quoted since in service.yaml, per-lineage base/uniqueness, one-interface-per-file, and {api-version}-only placeholder.
Contributor
|
All changed packages have been documented.
Show changes
|
commit: |
Contributor
|
You can try these changes here
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the Unified Examples Format epic (#4831). Implements #4832 — the
examples.yamlJSON Schema +examples-validatetool.What
New package
@azure-tools/typespec-azure-examples, the foundational piece of the epic.schema/examples-yaml.tspis the source of truth (RFC §4 model), compiled via@typespec/json-schematoExamplesYaml.jsonand wrapped asschema.js, mirroring the existingservice.yamlschema pattern intypespec-autorest.ajv(draft 2020-12) validates parsed files against it.examples-validateCLI + programmatic API — discoversexamples.yaml/examples/*.yamlin a service directory, reads the adjacentservice.yamlfor version metadata, reports located diagnostics, and exits non-zero on error (--warn-as-errorto also fail on warnings).Rules enforced (RFC §3)
$schema/$namespacemay be$-prefixed; every other bare top-level key is an operation that must be a list of examples.2XX) anddefaultare rejected.sincemust be a quoted string and a version listed inservice.yaml.title; untitled → default lineage): at most one entry withoutsince, andsincevalues are unique.{api-version}is the only supported placeholder, andapi-versionmust not appear as a request parameter.Notes / scope
@azure-tools/typespec-azure-examplesis intended to host the rest of theexamples-*toolchain (migrate/resolve/scaffold/diff/emit — examples-migrate tool #4833/examples-resolve tool #4834/x-id emission: typespec-autorest + transitional JSON #4835/Auxiliary tooling: examples-scaffold + examples-diff #4837).Record<Example[] | string>indexer (TypeSpec can't emitpatternProperties); the tighter$-metadata vs operation-key rules are enforced by the semantic layer.$schemaURL inazure-rest-api-specsis a follow-up cross-repo step.Validation
Build (schema regen + tsc), 24 vitest tests, oxlint, prettier, cspell, and
tsc -ball pass; CLI verified end-to-end (exit 0 on valid, exit 1 with located diagnostics on invalid).