fastapi-hypermodel
fastapi-hypermodel copied to clipboard
Fix empty sequence adding to embedded bug
Implement a check to ensure the sequence length is greater than 0 before adding the field to the embedded dictionary.
For example: if field value is '' then it goes to embedded dict from the model
Could you provide a minimal example where this is a problem?
Of course:
>>> import fastapi_hypermodel
>>> class Process(fastapi_hypermodel.HALHyperModel):
... number: int
... message: str | None
...
>>> process_dict = {"number": 0, "message": ""}
>>> process_hal = Process(**process_dict)
>>> process_hal
Process(links=None, embedded={'message': ''}, number=0)
@ELC are you happy for this one to be merged?