Skip to content

[Issue #370] Generate json schemas per version - #426

Merged
widal001 merged 13 commits into
mainfrom
issue-370-generate-json-schemas
Nov 21, 2025
Merged

widal001 merged 13 commits into
mainfrom
issue-370-generate-json-schemas

Conversation

@widal001

@widal001 widal001 commented Nov 20, 2025 •

Copy link
Copy Markdown
Collaborator

Summary

Auto-generates JSON schemas for each version of a model, field, enum etc.

Changes proposed

What was added, updated, or removed in this PR.

  • Changelog emitter: Updates the changelog output to be more structured, so it could be used to generate different versions of each JSON schema
  • Website
    • Updates SchemaChangelog to work with new changelog output
    • Adds script to generate JSON schemas for each version of a given model

Context for reviewers

Testing instructions, background context, more in-depth details of the implementation, and anything else you'd like to call out or ask reviewers. Explain how the changes were verified.

This PR doesn't yet publish all of JSON schema versions on the website. I had a few questions about where/how we wanted to do this:

  • Right now we have the latest version of each schema available at /schemas/yaml/ we could:
    • Preserve /schemas/yaml/ for the latest version but then expose all versions in /schemas/yaml/versions/[v1 | v2 | v3]/
    • Make the latest available at /schemas/yaml/latest/ and then do /schemas/yaml/v2/ etc. for earlier versions
    • Treat the latest version the same as others and expose them all at /schemas/yaml/v3/ etc.
  • In terms of how we want to link to these published versions, do we want to:

Additional information

Screenshots, GIF demos, code examples or output to help show the changes working as expected.

Schema versions

  1. Checkout the PR
  2. Run pnpm --filter typespec-versioning-changelog test:coverage to build the updated changelog emitter
  3. Run npm run typespec && npm run generate:versioned-schemas from within the website/ directory
  4. Go to tsp-output/schemas/ to view the auto-generated schemas
Screenshot 2025-11-20 at 3 59 14 PM Screenshot of auto-generated folders
  1. View the auto-generated schemas for v0.2.0/Form.yml and v0.3.0/FormBase.yml
Comparison of Form.yaml and FormBase.yml

Changelog outputs

Old output
{
  "FormBase": [
    {
      "version": "0.2.0",
      "changes": [
        "Added `Form` model"
      ]
    },
    {
      "version": "0.3.0",
      "changes": [
        "Renamed model from `Form` to `FormBase`",
        "Added `version` field"
      ]
    }
  ]
}
New output
{
  "versions": ["0.1.0", "0.2.0", "0.3.0"],
  "logs": {
    "FormBase": {
      "0.2.0": [
        {
          "message": "Added `Form` model",
          "action": "added",
          "targetKind": "model",
          "currTargetName": "Form"
        }
      ],
      "0.3.0": [
        {
          "message": "Renamed model from `Form` to `FormBase`",
          "action": "renamed",
          "targetKind": "model",
          "prevTargetName": "Form",
          "currTargetName": "FormBase"
        },
        {
          "message": "Added `version` field",
          "action": "added",
          "targetKind": "field",
          "currTargetName": "version"
        }
      ]
    }
  }
}

Previously changes in the changelog were just unstructured strings.
This commit adds support for structured log messages with these fields:
- message (original log message)
- action
- targetKind
- currTargetName
- prevTargetName
- currDataType
- prevDataType
Updates to match the new changelog output format.
@github-actions github-actions Bot added website Issues related to the website typescript Issue or PR related to TypeScript tooling labels Nov 20, 2025
@github-actions

github-actions Bot commented Nov 20, 2025 •

Copy link
Copy Markdown
Contributor

🚀 Website Preview Deployed!

Preview your changes at: https://cg-pr-426.billy-daly.workers.dev

This preview will be automatically deleted when the PR is closed.

@widal001
widal001 marked this pull request as ready for review November 20, 2025 21:04

@DavidDudas-Intuitial DavidDudas-Intuitial left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added one non-blocking comment.

In response the questions posed in the Summary:

  • re: the latest version of each schema available at /schemas/yaml/
    I am in favor of preserving /schemas/yaml/ for the latest version and also exposing all versions in /schemas/yaml/versions[v0.1 | v0.2 | etc].

  • re: how we want to link to these published versions
    IMO the Changelog table is the perfectly contextual place to link to the versioned schemas. Changes and versions go hand in hand, whereas the Formats section is more about examples of the latest version in different languages.

Comment thread website/src/lib/schema/version-generator.ts Outdated
Uses the exported types from the changelog emitter dependency
instead of declaring the same ones.
@widal001
widal001 merged commit f7d654a into main Nov 21, 2025
6 checks passed
@widal001
widal001 deleted the issue-370-generate-json-schemas branch November 21, 2025 16:23
@github-actions

Copy link
Copy Markdown
Contributor

🗑️ Preview Cleaned Up

The preview for this PR has been automatically deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript Issue or PR related to TypeScript tooling website Issues related to the website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JSON schema versioning] Emit versioned schemas

2 participants