@@ -656,3 +656,101 @@ def test_urlencoded_form_with_array_default(self, deserializer_factory):
656656 result = deserializer .deserialize (value )
657657
658658 assert result == {"tags" : []}
659+
660+ @pytest .mark .xfail (
661+ reason = (
662+ "multipart composed-schema branch selection is not binary-aware"
663+ ),
664+ strict = True ,
665+ )
666+ def test_multipart_oneof_binary_field (self , spec , deserializer_factory ):
667+ mimetype = "multipart/form-data"
668+ schema_dict = {
669+ "oneOf" : [
670+ {
671+ "type" : "object" ,
672+ "properties" : {
673+ "label" : {"type" : "string" },
674+ },
675+ "required" : ["label" ],
676+ },
677+ {
678+ "type" : "object" ,
679+ "properties" : {
680+ "file" : {"type" : "string" , "format" : "binary" },
681+ },
682+ "required" : ["file" ],
683+ },
684+ ]
685+ }
686+ schema = SchemaPath .from_dict (schema_dict )
687+ schema_validator = oas31_schema_validators_factory .create (spec , schema )
688+ parameters = {
689+ "boundary" : "===============2872712225071193122==" ,
690+ }
691+ deserializer = deserializer_factory (
692+ mimetype ,
693+ schema = schema ,
694+ schema_validator = schema_validator ,
695+ parameters = parameters ,
696+ )
697+ value = (
698+ b"--===============2872712225071193122==\n "
699+ b"Content-Type: application/octet-stream\n MIME-Version: 1.0\n "
700+ b'Content-Disposition: form-data; name="file"\n \n \xff \xfe \n '
701+ b"--===============2872712225071193122==--\n "
702+ )
703+
704+ result = deserializer .deserialize (value )
705+
706+ assert result == {
707+ "file" : b"\xff \xfe " ,
708+ }
709+
710+ @pytest .mark .xfail (
711+ reason = (
712+ "multipart composed-schema branch selection is not binary-aware"
713+ ),
714+ strict = True ,
715+ )
716+ def test_multipart_anyof_binary_field (self , spec , deserializer_factory ):
717+ mimetype = "multipart/form-data"
718+ schema_dict = {
719+ "anyOf" : [
720+ {
721+ "type" : "object" ,
722+ "properties" : {
723+ "file" : {"type" : "string" , "format" : "binary" },
724+ },
725+ },
726+ {
727+ "type" : "object" ,
728+ "properties" : {
729+ "label" : {"type" : "string" },
730+ },
731+ },
732+ ]
733+ }
734+ schema = SchemaPath .from_dict (schema_dict )
735+ schema_validator = oas31_schema_validators_factory .create (spec , schema )
736+ parameters = {
737+ "boundary" : "===============2872712225071193122==" ,
738+ }
739+ deserializer = deserializer_factory (
740+ mimetype ,
741+ schema = schema ,
742+ schema_validator = schema_validator ,
743+ parameters = parameters ,
744+ )
745+ value = (
746+ b"--===============2872712225071193122==\n "
747+ b"Content-Type: application/octet-stream\n MIME-Version: 1.0\n "
748+ b'Content-Disposition: form-data; name="file"\n \n \xff \xfe \n '
749+ b"--===============2872712225071193122==--\n "
750+ )
751+
752+ result = deserializer .deserialize (value )
753+
754+ assert result == {
755+ "file" : b"\xff \xfe " ,
756+ }
0 commit comments