[Feature] Adds Enums #28

Merged
HideyoshiNakazone merged 3 commits from feature/adds-enums into main 2025-06-22 20:25:27 +00:00
3 changed files with 40 additions and 1 deletions
Showing only changes of commit 6c94047ec0 - Show all commits

View File

@@ -0,0 +1,37 @@
Enum Type
==================
An enum type is a special data type that enables a variable to be a set of predefined constants. The enum type is used to define variables that can only take one out of a small set of possible values.
It does not have any specific properties, but it has the generic properties:
- default: Default value for the enum.
- description: Description of the enum field.
Examples
-----------------
.. code-block:: python
from jambo import SchemaConverter
schema = {
"title": "EnumExample",
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": ["active", "inactive", "pending"],
"description": "The status of the object.",
"default": "active",
},
},
"required": ["status"],
}
Model = SchemaConverter.build(schema)
obj = Model(status="active")
print(obj) # Output: EnumExample(status=status.ACTIVE)

View File

@@ -44,4 +44,5 @@ For more complex schemas and types see our documentation on
usage.object
usage.reference
usage.allof
usage.anyof
usage.anyof
usage.enum

View File

@@ -50,6 +50,7 @@ repository = "https://github.com/HideyoshiNakazone/jambo.git"
create-hooks = "bash .githooks/set-hooks.sh"
tests = "python -m coverage run -m unittest discover -v"
tests-report = "python -m coverage xml"
serve-docs = "sphinx-autobuild docs/source docs/build"
# Build System
[tool.hatch.version]