mirror of
https://github.com/rendercv/rendercv.git
synced 2026-04-17 13:33:53 -04:00
Revert "Fix #689: Allow arbitrary font names in JSON schema while keeping enum suggestions"
This reverts commit 9ebcebd3ccc6abee3c71c07c884488614044b958.
This commit is contained in:
47
schema.json
47
schema.json
@@ -9031,33 +9031,26 @@
|
||||
"type": "object"
|
||||
},
|
||||
"rendercv__schema__models__design__font_family__FontFamily": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
"DejaVu Sans Mono",
|
||||
"EB Garamond",
|
||||
"Fontin",
|
||||
"Gentium Book Plus",
|
||||
"Lato",
|
||||
"Libertinus Serif",
|
||||
"Mukta",
|
||||
"New Computer Modern",
|
||||
"Noto Sans",
|
||||
"Open Sans",
|
||||
"Open Sauce Sans",
|
||||
"Poppins",
|
||||
"Raleway",
|
||||
"Roboto",
|
||||
"Source Sans 3",
|
||||
"Ubuntu",
|
||||
"XCharter"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
"enum": [
|
||||
"DejaVu Sans Mono",
|
||||
"EB Garamond",
|
||||
"Fontin",
|
||||
"Gentium Book Plus",
|
||||
"Lato",
|
||||
"Libertinus Serif",
|
||||
"Mukta",
|
||||
"New Computer Modern",
|
||||
"Noto Sans",
|
||||
"Open Sans",
|
||||
"Open Sauce Sans",
|
||||
"Poppins",
|
||||
"Raleway",
|
||||
"Roboto",
|
||||
"Source Sans 3",
|
||||
"Ubuntu",
|
||||
"XCharter"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"rendercv__schema__models__locale__english_locale__Phrases__1": {
|
||||
"additionalProperties": false,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Literal
|
||||
|
||||
from pydantic.json_schema import SkipJsonSchema
|
||||
|
||||
available_font_families = sorted(
|
||||
[
|
||||
# Typst built-ins
|
||||
@@ -25,4 +27,4 @@ available_font_families = sorted(
|
||||
)
|
||||
|
||||
|
||||
type FontFamily = str | Literal[*tuple(available_font_families)] # ty: ignore[invalid-type-form]
|
||||
type FontFamily = SkipJsonSchema[str] | Literal[*tuple(available_font_families)] # ty: ignore[invalid-type-form]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import pytest
|
||||
import rendercv_fonts
|
||||
|
||||
from rendercv.schema.json_schema_generator import generate_json_schema
|
||||
from rendercv.schema.models.design.font_family import available_font_families
|
||||
|
||||
icon_font_families = {"Font Awesome 7"}
|
||||
@@ -26,18 +25,3 @@ def test_bundled_fonts_are_in_available_font_families(font_family):
|
||||
)
|
||||
def test_no_extra_fonts_in_available_font_families(font_family):
|
||||
assert font_family in rendercv_fonts.available_font_families
|
||||
|
||||
|
||||
def test_json_schema_accepts_arbitrary_font_names():
|
||||
schema = generate_json_schema()
|
||||
font_schema = schema["$defs"][
|
||||
"rendercv__schema__models__design__font_family__FontFamily"
|
||||
]
|
||||
# Schema should use anyOf to accept both known fonts (enum) and arbitrary strings
|
||||
assert "anyOf" in font_schema
|
||||
types = [option.get("type") for option in font_schema["anyOf"]]
|
||||
assert "string" in types
|
||||
# The enum with known fonts should still be present
|
||||
enum_options = [option for option in font_schema["anyOf"] if "enum" in option]
|
||||
assert len(enum_options) == 1
|
||||
assert "Source Sans 3" in enum_options[0]["enum"]
|
||||
|
||||
Reference in New Issue
Block a user