# cjm-fasthtml-jsonschema
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
## Install
``` bash
pip install cjm_fasthtml_jsonschema
```
## Demo Application
Run the demo to see the library in action:
``` bash
python demo_app.py
```
Then visit:
- http://localhost:5001/ - Demo page with example form from
`./test_files/`
``` bash
$ python ./demo_app.py -h
usage: demo_app.py [-h] [--schema SCHEMA] [--port PORT] [--host HOST]
JSON Schema to UI Demo Application
options:
-h, --help show this help message and exit
--schema SCHEMA Path to the JSON schema file (default: test_files/voxtral_config_schema.json)
--port PORT Port to run the server on (default: 5001)
--host HOST Host to run the server on (default: 0.0.0.0)
```
## Project Structure
nbs/
├── components/ (1)
│ └── fields.ipynb # Field component generators for different JSON Schema types.
├── core/ (2)
│ ├── parser.ipynb # JSON Schema parsing utilities.
│ └── types.ipynb # Type definitions for JSON Schema elements.
└── generators/ (1)
└── form.ipynb # Main form generator that creates UI from JSON Schema.
Total: 4 notebooks across 3 directories
## Module Dependencies
``` mermaid
graph LR
components_fields[components.fields<br/>fields]
core_parser[core.parser<br/>parser]
core_types[core.types<br/>types]
generators_form[generators.form<br/>form]
components_fields --> core_types
core_parser --> core_types
generators_form --> core_parser
generators_form --> components_fields
```
*4 cross-module dependencies detected*
## CLI Reference
No CLI commands found in this project.
## Module Overview
Detailed documentation for each module in the project:
### fields (`fields.ipynb`)
> Field component generators for different JSON Schema types.
#### Import
``` python
from cjm_fasthtml_jsonschema.components.fields import (
create_label,
create_description,
create_string_field,
create_enum_field,
create_number_field,
create_range_field,
create_boolean_field,
create_field
)
```
#### Functions
``` python
def create_label(
prop: SchemaProperty # SchemaProperty object
) -> FT: # Label component
"Create a label for a field."
```
``` python
def create_description(
prop: SchemaProperty # SchemaProperty object
) -> Optional[FT]: # P component with description or None
"Create a description/help text for a field."
```
``` python
def create_string_field(
prop: SchemaProperty, # SchemaProperty object
value: Any = None # Current value
) -> FT: # Div containing the field
"Create a string input field."
```
``` python
def create_enum_field(
prop: SchemaProperty, # SchemaProperty object
value: Any = None # Current value
) -> FT: # Div containing the field
"Create an enum select dropdown field."
```
``` python
def create_number_field(
prop: SchemaProperty, # SchemaProperty object
value: Any = None # Current value
) -> FT: # Div containing the field
"Create a number input field."
```
``` python
def create_range_field(
prop: SchemaProperty, # SchemaProperty object
value: Any = None # Current value
) -> FT: # Div containing the field
"Create a range slider field."
```
``` python
def create_boolean_field(
prop: SchemaProperty, # SchemaProperty object
value: Any = None # Current value
) -> FT: # Div containing the field
"Create a boolean toggle field."
```
``` python
def create_field(
prop: SchemaProperty, # SchemaProperty object
value: Any = None # Current value
) -> FT: # Div containing the field
"Create an appropriate field based on the property type."
```
### form (`form.ipynb`)
> Main form generator that creates UI from JSON Schema.
#### Import
``` python
from cjm_fasthtml_jsonschema.generators.form import (
generate_form_ui
)
```
#### Functions
``` python
def generate_form_ui(
schema: Dict[str, Any], # JSON Schema dictionary
values: Optional[Dict[str, Any]] = None, # Optional dictionary of current values
show_title: bool = True, # Whether to show the schema title
show_description: bool = True, # Whether to show schema description
compact: bool = False, # Use compact layout (less spacing)
card_wrapper: bool = True # Wrap the form in a card component
) -> FT: # FastHTML component containing the generated form UI
"Generate a FastHTML form UI from a JSON Schema."
```
### parser (`parser.ipynb`)
> JSON Schema parsing utilities.
#### Import
``` python
from cjm_fasthtml_jsonschema.core.parser import (
SchemaParser
)
```
#### Classes
``` python
class SchemaParser:
def __init__(
self,
schema: Dict[str, Any] # JSON Schema dictionary
)
"Parse JSON Schema and extract property information."
def __init__(
self,
schema: Dict[str, Any] # JSON Schema dictionary
)
"Initialize parser with a JSON Schema."
def get_property(
self,
name: str # Property name
) -> Optional[SchemaProperty]: # SchemaProperty object or None if not found
"Get a specific property by name."
def get_required_properties(
self
) -> List[SchemaProperty]: # List of all required SchemaProperty objects
"Get all required properties."
def get_optional_properties(
self
) -> List[SchemaProperty]: # List of all optional SchemaProperty objects
"Get all optional properties."
```
### types (`types.ipynb`)
> Type definitions for JSON Schema elements.
#### Import
``` python
from cjm_fasthtml_jsonschema.core.types import (
SchemaProperty
)
```
#### Classes
``` python
@dataclass
class SchemaProperty:
"Represents a single property in a JSON Schema."
name: str
schema: Dict[str, Any]
required: bool = False
value: Any
def type(
self
) -> str: # The property's type (e.g., 'string', 'number', 'boolean')
"Get the property type."
def is_nullable(
self
) -> bool: # True if the property allows null values
"Check if property allows null values."
def default(
self
) -> Any: # The default value for this property, or None if not specified
"Get default value if specified."
def description(
self
) -> Optional[str]: # The property's description text, or None if not provided
"Get property description."
def enum_values(
self
) -> Optional[List[Any]]: # List of allowed enum values, or None if not an enum
"Get enum values if property is an enum."
def examples(
self
) -> Optional[List[Any]]: # List of example values, or None if not provided
"Get example values if provided."
def minimum(
self
) -> Optional[Union[int, float]]: # Minimum allowed value for numeric types, or None if not specified
"Get minimum value for numeric types."
def maximum(
self
) -> Optional[Union[int, float]]: # Maximum allowed value for numeric types, or None if not specified
"Get maximum value for numeric types."
def min_length(
self
) -> Optional[int]: # Minimum length for string types, or None if not specified
"Get minimum length for string types."
def max_length(
self
) -> Optional[int]: # Maximum length for string types, or None if not specified
"Get maximum length for string types."
def pattern(
self
) -> Optional[str]: # Regex pattern for string validation, or None if not specified
"Get regex pattern for string validation."
def format(
self
) -> Optional[str]: # Format hint (e.g., 'email', 'uri', 'date'), or None if not specified
"Get format hint (e.g., 'email', 'uri', 'date')."
```
Raw data
{
"_id": null,
"home_page": "https://github.com/cj-mills/cjm-fasthtml-jsonschema",
"name": "cjm-fasthtml-jsonschema",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "nbdev jupyter notebook python",
"author": "Christian J. Mills",
"author_email": "9126128+cj-mills@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/a2/d2/b5ebf03e252f9bb06460f6eb655db8fe1138547fc080fe33764b73894b12/cjm_fasthtml_jsonschema-0.0.6.tar.gz",
"platform": null,
"description": "# cjm-fasthtml-jsonschema\n\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n## Install\n\n``` bash\npip install cjm_fasthtml_jsonschema\n```\n\n## Demo Application\n\nRun the demo to see the library in action:\n\n``` bash\npython demo_app.py\n```\n\nThen visit:\n\n- http://localhost:5001/ - Demo page with example form from\n `./test_files/`\n\n``` bash\n$ python ./demo_app.py -h\nusage: demo_app.py [-h] [--schema SCHEMA] [--port PORT] [--host HOST]\n\nJSON Schema to UI Demo Application\n\noptions:\n -h, --help show this help message and exit\n --schema SCHEMA Path to the JSON schema file (default: test_files/voxtral_config_schema.json)\n --port PORT Port to run the server on (default: 5001)\n --host HOST Host to run the server on (default: 0.0.0.0)\n```\n\n## Project Structure\n\n nbs/\n \u251c\u2500\u2500 components/ (1)\n \u2502 \u2514\u2500\u2500 fields.ipynb # Field component generators for different JSON Schema types.\n \u251c\u2500\u2500 core/ (2)\n \u2502 \u251c\u2500\u2500 parser.ipynb # JSON Schema parsing utilities.\n \u2502 \u2514\u2500\u2500 types.ipynb # Type definitions for JSON Schema elements.\n \u2514\u2500\u2500 generators/ (1)\n \u2514\u2500\u2500 form.ipynb # Main form generator that creates UI from JSON Schema.\n\nTotal: 4 notebooks across 3 directories\n\n## Module Dependencies\n\n``` mermaid\ngraph LR\n components_fields[components.fields<br/>fields]\n core_parser[core.parser<br/>parser]\n core_types[core.types<br/>types]\n generators_form[generators.form<br/>form]\n\n components_fields --> core_types\n core_parser --> core_types\n generators_form --> core_parser\n generators_form --> components_fields\n```\n\n*4 cross-module dependencies detected*\n\n## CLI Reference\n\nNo CLI commands found in this project.\n\n## Module Overview\n\nDetailed documentation for each module in the project:\n\n### fields (`fields.ipynb`)\n\n> Field component generators for different JSON Schema types.\n\n#### Import\n\n``` python\nfrom cjm_fasthtml_jsonschema.components.fields import (\n create_label,\n create_description,\n create_string_field,\n create_enum_field,\n create_number_field,\n create_range_field,\n create_boolean_field,\n create_field\n)\n```\n\n#### Functions\n\n``` python\ndef create_label(\n prop: SchemaProperty # SchemaProperty object\n) -> FT: # Label component\n \"Create a label for a field.\"\n```\n\n``` python\ndef create_description(\n prop: SchemaProperty # SchemaProperty object\n) -> Optional[FT]: # P component with description or None\n \"Create a description/help text for a field.\"\n```\n\n``` python\ndef create_string_field(\n prop: SchemaProperty, # SchemaProperty object\n value: Any = None # Current value\n) -> FT: # Div containing the field\n \"Create a string input field.\"\n```\n\n``` python\ndef create_enum_field(\n prop: SchemaProperty, # SchemaProperty object\n value: Any = None # Current value\n) -> FT: # Div containing the field\n \"Create an enum select dropdown field.\"\n```\n\n``` python\ndef create_number_field(\n prop: SchemaProperty, # SchemaProperty object\n value: Any = None # Current value\n) -> FT: # Div containing the field\n \"Create a number input field.\"\n```\n\n``` python\ndef create_range_field(\n prop: SchemaProperty, # SchemaProperty object\n value: Any = None # Current value\n) -> FT: # Div containing the field\n \"Create a range slider field.\"\n```\n\n``` python\ndef create_boolean_field(\n prop: SchemaProperty, # SchemaProperty object\n value: Any = None # Current value\n) -> FT: # Div containing the field\n \"Create a boolean toggle field.\"\n```\n\n``` python\ndef create_field(\n prop: SchemaProperty, # SchemaProperty object\n value: Any = None # Current value\n) -> FT: # Div containing the field\n \"Create an appropriate field based on the property type.\"\n```\n\n### form (`form.ipynb`)\n\n> Main form generator that creates UI from JSON Schema.\n\n#### Import\n\n``` python\nfrom cjm_fasthtml_jsonschema.generators.form import (\n generate_form_ui\n)\n```\n\n#### Functions\n\n``` python\ndef generate_form_ui(\n schema: Dict[str, Any], # JSON Schema dictionary\n values: Optional[Dict[str, Any]] = None, # Optional dictionary of current values\n show_title: bool = True, # Whether to show the schema title\n show_description: bool = True, # Whether to show schema description\n compact: bool = False, # Use compact layout (less spacing)\n card_wrapper: bool = True # Wrap the form in a card component\n) -> FT: # FastHTML component containing the generated form UI\n \"Generate a FastHTML form UI from a JSON Schema.\"\n```\n\n### parser (`parser.ipynb`)\n\n> JSON Schema parsing utilities.\n\n#### Import\n\n``` python\nfrom cjm_fasthtml_jsonschema.core.parser import (\n SchemaParser\n)\n```\n\n#### Classes\n\n``` python\nclass SchemaParser:\n def __init__(\n self,\n schema: Dict[str, Any] # JSON Schema dictionary\n )\n \"Parse JSON Schema and extract property information.\"\n \n def __init__(\n self,\n schema: Dict[str, Any] # JSON Schema dictionary\n )\n \"Initialize parser with a JSON Schema.\"\n \n def get_property(\n self,\n name: str # Property name\n ) -> Optional[SchemaProperty]: # SchemaProperty object or None if not found\n \"Get a specific property by name.\"\n \n def get_required_properties(\n self\n ) -> List[SchemaProperty]: # List of all required SchemaProperty objects\n \"Get all required properties.\"\n \n def get_optional_properties(\n self\n ) -> List[SchemaProperty]: # List of all optional SchemaProperty objects\n \"Get all optional properties.\"\n```\n\n### types (`types.ipynb`)\n\n> Type definitions for JSON Schema elements.\n\n#### Import\n\n``` python\nfrom cjm_fasthtml_jsonschema.core.types import (\n SchemaProperty\n)\n```\n\n#### Classes\n\n``` python\n@dataclass\nclass SchemaProperty:\n \"Represents a single property in a JSON Schema.\"\n \n name: str\n schema: Dict[str, Any]\n required: bool = False\n value: Any\n \n def type(\n self\n ) -> str: # The property's type (e.g., 'string', 'number', 'boolean')\n \"Get the property type.\"\n \n def is_nullable(\n self\n ) -> bool: # True if the property allows null values\n \"Check if property allows null values.\"\n \n def default(\n self\n ) -> Any: # The default value for this property, or None if not specified\n \"Get default value if specified.\"\n \n def description(\n self\n ) -> Optional[str]: # The property's description text, or None if not provided\n \"Get property description.\"\n \n def enum_values(\n self\n ) -> Optional[List[Any]]: # List of allowed enum values, or None if not an enum\n \"Get enum values if property is an enum.\"\n \n def examples(\n self\n ) -> Optional[List[Any]]: # List of example values, or None if not provided\n \"Get example values if provided.\"\n \n def minimum(\n self\n ) -> Optional[Union[int, float]]: # Minimum allowed value for numeric types, or None if not specified\n \"Get minimum value for numeric types.\"\n \n def maximum(\n self\n ) -> Optional[Union[int, float]]: # Maximum allowed value for numeric types, or None if not specified\n \"Get maximum value for numeric types.\"\n \n def min_length(\n self\n ) -> Optional[int]: # Minimum length for string types, or None if not specified\n \"Get minimum length for string types.\"\n \n def max_length(\n self\n ) -> Optional[int]: # Maximum length for string types, or None if not specified\n \"Get maximum length for string types.\"\n \n def pattern(\n self\n ) -> Optional[str]: # Regex pattern for string validation, or None if not specified\n \"Get regex pattern for string validation.\"\n \n def format(\n self\n ) -> Optional[str]: # Format hint (e.g., 'email', 'uri', 'date'), or None if not specified\n \"Get format hint (e.g., 'email', 'uri', 'date').\"\n```\n",
"bugtrack_url": null,
"license": "Apache Software License 2.0",
"summary": "Library for generating FastHTML user interfaces from JSON Schema configurations.",
"version": "0.0.6",
"project_urls": {
"Homepage": "https://github.com/cj-mills/cjm-fasthtml-jsonschema"
},
"split_keywords": [
"nbdev",
"jupyter",
"notebook",
"python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "98577dd9e67ac970cb17f0b9347dfd463f3d8b5d02aae7bc078fa18f9a09e460",
"md5": "e11871c93b228ed0abb28baa2761d1f5",
"sha256": "0bcece16237efcd1f8c9df6459833281c3e89a7cfd6735a589d1da18c275d8e5"
},
"downloads": -1,
"filename": "cjm_fasthtml_jsonschema-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e11871c93b228ed0abb28baa2761d1f5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 16036,
"upload_time": "2025-10-24T22:18:55",
"upload_time_iso_8601": "2025-10-24T22:18:55.108620Z",
"url": "https://files.pythonhosted.org/packages/98/57/7dd9e67ac970cb17f0b9347dfd463f3d8b5d02aae7bc078fa18f9a09e460/cjm_fasthtml_jsonschema-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a2d2b5ebf03e252f9bb06460f6eb655db8fe1138547fc080fe33764b73894b12",
"md5": "8cad019f6887ef2a5074cb67d3c713c8",
"sha256": "6ecf8385243e14aeb946b640bc9d43ce892f139c3603e736eb2b9d5be7ac78ae"
},
"downloads": -1,
"filename": "cjm_fasthtml_jsonschema-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "8cad019f6887ef2a5074cb67d3c713c8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 16424,
"upload_time": "2025-10-24T22:18:56",
"upload_time_iso_8601": "2025-10-24T22:18:56.324272Z",
"url": "https://files.pythonhosted.org/packages/a2/d2/b5ebf03e252f9bb06460f6eb655db8fe1138547fc080fe33764b73894b12/cjm_fasthtml_jsonschema-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-24 22:18:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cj-mills",
"github_project": "cjm-fasthtml-jsonschema",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cjm-fasthtml-jsonschema"
}