Skip to content

Commit

Permalink
Fix L3-iGrant/api#573: Update presentation definition class
Browse files Browse the repository at this point in the history
  • Loading branch information
albinpa authored and georgepadayatti committed Oct 22, 2024
1 parent 44829ae commit c566255
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sdjwt/pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ class InputDescriptor(BaseModel):
name: Optional[str] = None
purpose: Optional[str] = None
constraints: Dict[str, Union[str, List[Field]]]
format: Optional[Dict[str, Union[Dict[str, List[str]], Dict[str, List[str]]]]] = None


class PresentationDefinition(BaseModel):
id: str
input_descriptors: List[InputDescriptor]
format: Dict[str, Union[Dict[str, List[str]], Dict[str, List[str]]]]
format: Optional[Dict[str, Union[Dict[str, List[str]], Dict[str, List[str]]]]] = None


PresentationDefinitionJsonSchema = {
Expand Down Expand Up @@ -264,6 +265,12 @@ def validate_and_deserialise_presentation_definition(
validate(
instance=presentation_definition, schema=PresentationDefinitionJsonSchema
)
presentation_definition_dict = PresentationDefinition(**presentation_definition)
if not presentation_definition_dict.format:
for input_descriptor in presentation_definition_dict.input_descriptors:
format = input_descriptor.format
if not format:
raise PresentationDefinitionValidationError("Format is required")
return PresentationDefinition(**presentation_definition)
except exceptions.ValidationError as e:
# FIXME: Temporary hack to validate presentation definition from itb
Expand Down

0 comments on commit c566255

Please sign in to comment.