Repository navigation
Add Pydantic v2 schema.org models for CodeMeta JSON-LD - #1
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Implement clean-room schema.org models with Pydantic v2
Add Pydantic v2 schema.org models for CodeMeta JSON-LD
Jun 4, 2026
Collaborator
|
👍 its definitely easiest to just skip figuring out how to migrate the codegen stuff in pydantic_schemaorg and keep going generating it all like this. The only real issue I had while back was migrating whatever deferred importing magic was happening (if you have all of the possible schema.org type models that can constitute SoftwareSourceCode imported at runtime its unusably slow), but that will probably also be much easier just generating everything from scratch |
- rename package to codemeta_datamodel - add containerization and support for package publishing and uv - add initial AGENTS.md scaffolding
address permissions errors with generated files on the volume mounts being owned by root instead
Add CreativeWork, PostalAddress, Role, ComputerLanguage, MediaObject, DataFeed, Review, and ScholarlyArticle types. Fix SoftwareApplication to extend CreativeWork instead of SoftwareSourceCode (schema.org treats them as siblings). Update field types per spec: programmingLanguage accepts ComputerLanguage, license/citation accept CreativeWork, and author/contributor/maintainer now include Role. Also fix from_jsonld return type to use Self, add sameAs to Thing, document CodeMeta version-lock constraint in its docstring, fix spec path reference (codemeta_pydantic → codemeta_datamodel), and add Conventional Commits directive to AGENTS.md.
Build and push the Docker image to GitHub Container Registry on release publication. Tags follow semver (major.minor.patch, major.minor, major) with 'latest' applied to stable releases only. Uses GHA cache for layer reuse across builds.
alee
force-pushed
the
copilot/code-meta-schema-implementation
branch
from
August 17, 2026 03:24
bd2c70d to
ec4400b
Compare
…odels - Rename package codemeta_datamodel -> pydantic_codemeta - Rename pyproject distribution codemeticulous -> pydantic-codemeta - Add VersionedLanguage type and broaden programmingLanguage to accept it - Broaden many CreativeWork/SoftwareSourceCode fields to accept lists - Add SoftwareSourceCode fields: applicationCategory, applicationSubCategory, fileSize, permissions, releaseNotes, softwareVersion, fileFormat, isAccessibleForFree, position, isPartOf, hasPart, encoding, creator, editor, copyrightHolder, copyrightYear - Add CodeMeta before-validators: map bare type/id keys, collapse JSON-LD @context dicts, coalesce embargoDate/contIntegration/creator into v3 terms - Add SchemaOrgBase.dict/json/yaml serialization helpers and pyyaml dep - Allow SoftwareApplication as CodeMeta @type - Update AGENTS.md and docs to reflect new package name TODO: full alignment with codemeticulous client usage
- add explicit CodeMetaV3 and v3/canonical adapters - move JSON-LD normalization and legacy migrations into pure helpers - preserve open extensions while enforcing the v3 context and source-code root - broaden CodeMeta relation ranges and support unknown CreativeWork subtypes - reject known non-CreativeWork nodes in CreativeWork relationship fields - document model boundaries and add focused round-trip, migration, and validation coverage
- separate the open CodeMeta model from its v3-specific binding - make ordinary JSON-LD parsing pure and legacy migration explicit - adopt snake_case Python fields with schema.org and CodeMeta aliases - preserve structured contexts, unknown JSON values, and explicit nulls - enforce alias collisions, relationship cardinalities, and type boundaries - remove legacy serialization helpers and the PyYAML dependency - expand the living specification, README, and regression coverage
- reject coercion of Python-only values in raw JSON fields - enforce CreativeWork type invariants and strict scalar ranges - preserve structured PropertyValue and DataFeed values - expand cardinality, validation, and round-trip coverage - test supported Python versions and validate built distributions - include JSON test fixtures in source distributions - declare typing-extensions for every supported Python version - align contributor guidance, commands, and documented requirements - reduce GitHub Actions permissions Co-authored-by: Codex <codex@openai.com>
alee
marked this pull request as ready for review
August 18, 2026 22:45
- pin gh actions to SHAs - minor readme refinement, prepwork for release - bump python min to 3.11 since 3.10 is EOL this october
- add codemeta and citation.cff dogfood - add format, lint, validation checks
alee
approved these changes
Aug 19, 2026
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.
This introduces a clean-room, Pydantic v2-only schema.org model layer for the CodeMeta subset used by the package. It removes any need for legacy
pydantic.v1schema models while preserving JSON-LD behavior and forward-compatible round-tripping of unknown properties.Schema.org model layer
SchemaOrgBasewith Pydantic v2 config, JSON-LD aliases, andto_jsonld()/from_jsonld()helpersThing,Person,Organization,ContactPoint,PropertyValue,SoftwareSourceCode, andSoftwareApplicationauthor,publisher,identifier, andcontactPointCodeMeta wrapper semantics
CodeMetaas aSoftwareSourceCodeconvenience wrapper rather than a distinct schema type@context: https://w3id.org/codemeta/3.0@type: SoftwareSourceCodeJSON-LD compatibility
@context,@type, and@idvia aliasesextra="allow"so non-modeled fields survive full round-trip serializationdatetime.dateinternallyFixtures and focused coverage
Original prompt
The project is migrating entirely to Pydantic v2.
The current CodeMeta implementation relies on a legacy schema.org model layer that uses
pydantic.v1.BaseModel. This dependency must be removed.Your task is to create a clean-room implementation of a small subset of schema.org models
needed for CodeMeta support. Do not copy code from
pydantic_schemaorgor any other project.Goal
Create a minimal, production-quality, extensible schema.org model layer using Pydantic v2 only.
The implementation should:
pydantic.v1.This is not intended to be a complete schema.org implementation.
Non-goals
Do NOT:
Pydantic Requirements
Use only Pydantic v2 APIs.
Allowed:
Not allowed:
No deprecated v1 APIs.
All models should inherit a shared base class and use:
Unknown properties must round-trip successfully.
JSON-LD Requirements
Support the JSON-LD keywords:
Use aliases:
The canonical serialization contract is:
Provide convenience helpers:
from_jsonld()should simply delegate tomodel_validate().Design Principles
Explicit typing
Use explicit unions rather than
Any.Preferred:
Avoid:
Forward references
Use:
or equivalent typing techniques to avoid circular import issues.
Extensibility
The implementation should be organized around reusable base classes.
Future schema.org types should be easy to add by subclassing existing models.
Schema.org Types to Implement
Implement exactly these classes and no others.
No additional schema.org classes should be introduced.
CodeMeta Wrapper Semantics
CodeMetais NOT a distinct schema.org type.It is a convenience wrapper around
SoftwareSourceCode.It should always serialize as:
{ "@context": "https://w3id.org/codemeta/3.0", "@type": "SoftwareSourceCode" }Implement:
The defaults should be treated as fixed conventions of the wrapper class.
Changing them should require subclassing rather than ordinary usage.
Fields
SchemaOrgBase
Thing
Type:
Do not simplify
identifierto string-only.CodeMeta frequently uses structured identifiers such as DOI metadata.
Person
Types:
Organization
ContactPoint
--...