Skip to content

Commit

Permalink
Apply schema changes at top level
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed Nov 11, 2024
1 parent 2b9a33c commit 7ec6102
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/higlass_schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,10 @@ class Viewconf(BaseModel, Generic[ViewT]):


def schema():
return Viewconf.model_json_schema(schema_generator=_GenerateJsonSchema)
json_schema = Viewconf.model_json_schema(schema_generator=_GenerateJsonSchema)
json_schema["$schema"] = _GenerateJsonSchema.schema_dialect
json_schema["title"] = "HiGlass viewconf"
return json_schema


def schema_json(**kwargs):
Expand Down
10 changes: 2 additions & 8 deletions src/higlass_schema/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ def generate(
self, schema: core_schema.CoreSchema, mode: JsonSchemaMode = "validation"
) -> JsonSchemaValue:
json_schema = super().generate(schema, mode=mode)
json_schema["$schema"] = self.schema_dialect
json_schema["title"] = "HiGlass viewconf"
# clear the titles from the definitions
for d in json_schema.get("$defs", {}).values():
d.pop("title", None)

return json_schema


Expand All @@ -43,11 +41,7 @@ def generate(


def get_schema_of(type_: object):
schema = TypeAdapter(type_).json_schema(schema_generator=_GenerateJsonSchema)
# remove the title and $schema fields
schema.pop("title", None)
schema.pop("$schema", None)
return schema
return TypeAdapter(type_).json_schema(schema_generator=_GenerateJsonSchema)


def simplify_enum_schema(schema: Dict[str, Any]):
Expand Down

0 comments on commit 7ec6102

Please sign in to comment.