I get a ValidationError : 'OperationOutcome' object is not subscriptable when running the above code. What I want to do is to instanciate the BundleEntry with the outcome instead of a dictionnary.
The exception is thrown due to this code in r4.py :
class BundleEntry(BackboneElement):
(...)
resource: typing.Optional["Resource"]
""" A resource in the bundle.
Type `Resource` (represented as `dict` in JSON). """
@pydantic.validator("resource", pre=True, each_item=True)
def resource_factory(cls, value):
return from_dict(value)
BundleEntry expect only to get a dictionnary. What I suggest to do add a line to the code :
@pydantic.validator("resource", pre=True, each_item=True)
def resource_factory(cls, value):
if isinstance(value, Resource):
return value
return from_dict(value)
I get a
ValidationError : 'OperationOutcome' object is not subscriptable
when running the above code. What I want to do is to instanciate the BundleEntry with the outcome instead of a dictionnary.The exception is thrown due to this code in
r4.py
:BundleEntry expect only to get a dictionnary. What I suggest to do add a line to the code :
Change must be done here : https://github.com/skalarsystems/fhirzeug/blob/f08330ab4f3e67eeedc1b45e91926c8155db3a04/fhirzeug/generators/python_pydantic/templates/resource.py.jinja2#L52