Skip to content

How to export JSON Schemas

The schemas/ directory holds JSON Schema files generated from the package’s Pydantic models. This guide shows how to regenerate them after the models change, and how consumers use them.

Write one <model>.schema.json file per model into a directory:

Terminal window
researcher-profiles schema export schemas/

Expected output:

wrote schemas/profile_metadata.schema.json
wrote schemas/profile_config.schema.json
wrote schemas/papers_file.schema.json
wrote schemas/summary_file.schema.json
wrote schemas/question.schema.json

The command creates the output directory if it does not exist and overwrites any existing schema files. Run it whenever you change a model in researcher_profiles.schema so the checked-in files stay in sync.

Use export_schemas to write the files, or build_schemas to get the schema dicts in memory:

from researcher_profiles.schema_export import export_schemas, build_schemas
written = export_schemas("schemas") # returns list[Path]
print([p.name for p in written])
schemas = build_schemas() # returns {name: json_schema_dict}
print(sorted(schemas))
FileValidatesSource model
profile_metadata.schema.jsonprofile.yamlProfileMetadata
profile_config.schema.jsonconfig.jsonProfileConfig
papers_file.schema.jsonsources/papers.yamlPapersFile
summary_file.schema.jsonsources/summaries/*.summary.md frontmatterSummaryFile
question.schema.jsonmeta/questions.yaml entriesQuestion

See the schema reference for the fields in each model.

The point of the checked-in files is that a consumer can validate a profile without installing this package, using any JSON Schema validator in any language. Load the schema file and the target artifact (parsing YAML to JSON-compatible data first) and validate. See Validate a profile for a Python example with the jsonschema package.