HumanSignal / HumanSignal/Adala
JSON Schema converter treats optional properties as required
- Dominant language
- Python
- Stars
- 1.6k
- Forks
- 160
- Avg merge
- 4m
- Merged PRs (30d)
- 4
Description
### Problem
json_schema_to_model() ignores the schema required array and passes Field(...) for every property. As a result, properties that JSON Schema allows callers to omit are rejected by the generated Pydantic model.
### Reproduction
Using a schema with required_name in required and optional_note omitted from required:
Model = json_schema_to_model({
"type": "object",
"properties": {
"required_name": {"type": "string"},
"optional_note": {"type": "string"},
},
"required": ["required_name"],
})
Model(required_name="ok")
Current result:
ValidationError: optional_note - Field required
Both generated fields report is_required() == True.
### Expected behavior
Only fields named in the JSON Schema required array should be mandatory. Optional fields should remain omittable, while explicit null should still be rejected unless the property schema permits null. The field-schema helper used for skill outputs can continue marking all of its supplied fields as required for backward compatibility.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading json_schema_to_model() and the field-schema helper mentioned in the issue, then run the supplied reproduction with required_name and optional_note. Done means only names in the JSON Schema required array are mandatory, omitted optional properties validate, explicit null remains rejected unless allowed, and the skill-output helper keeps its existing required behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 67/100