Skip to content

Consider use of pydantic built-ins to generate JSON schemas from python data classes #702

Description

@ahouseholder

now that we're using pydantic for the python data classes, there are some built-in functions available to us like GenerateJsonSchema that we should consider integrating in so that we can ensure our ability to round-trip between the python and javascript usages.

Originally posted by @ahouseholder in #697

This would get us another step closer to unifying the different representations of the SSVC datastructures.

Background

We are currently maintaining two distinct processes for creating SSVC related data objects:

  1. Python data classes
  2. manually created JSON Schemas

This leads to situations in which one or the other is either ahead or behind because the process for updating them is not synchronized.

Further, since #674 we have been using Pydantic dataclasses, which have much better built-in support for JSON serialization, deserialization, and schema generation.

The proposal here is that we should leverage the JSON Schema features built into Pydantic to generate the schema files in data/schema. Our current hand-built schemas have some fields that are not natively part of the generated schema, but that all seems to be addressable using features like json_schema_extra and other customization features.

The end result would be that the python dataclasses would be used as the basis for defining the JSON schemas and we could take steps to ensure they're always in sync.

Activity

  1. ahouseholder commented on Mar 4, 2025

    @ahouseholder
    ContributorAuthor

    Important

    In the event that #592 is resolved while this issue remains open, ensure that whatever object class is created in response to that issue also has a corresponding JSON schema generation process similar to the children of this issue.

  2. added
    tech/backendBack-end tools, code, infrastructure
    EpicLarge-scale issues that represent multi-step implementations, used to thematically link other issues
    on Jul 1, 2025
  3. added this to the 2025-09 milestone on Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EpicLarge-scale issues that represent multi-step implementations, used to thematically link other issuestech/backendBack-end tools, code, infrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions