1
1
import logging
2
- from typing import Type , Union
2
+ from typing import Type , Union , Any
3
3
4
4
from . import SchemaFactory
5
5
from ..enumeration import ContentType
@@ -21,15 +21,19 @@ def __init__(self, schema_factory: SchemaFactory, strict_enum: bool = True) -> N
21
21
22
22
def build_list (self , data : dict ) -> list [Content ]:
23
23
return [
24
- self ._create_content (content_type , content_value ['schema' ])
24
+ self ._create_content (content_type , content_value .get ('schema' , {}),
25
+ content_value .get ('example' , None ),
26
+ content_value .get ('examples' , {}))
25
27
for content_type , content_value
26
28
in data .items ()
27
29
]
28
30
29
- def _create_content (self , content_type : str , content_value : dict ) -> Content :
31
+ def _create_content (self , content_type : str , schema : dict , example : Any , examples : dict ) -> Content :
30
32
logger .debug (f"Content building [type={ content_type } ]" )
31
33
ContentTypeCls : ContentTypeType = ContentType if self .strict_enum else LooseContentType
32
34
return Content (
33
35
type = ContentTypeCls (content_type ),
34
- schema = self .schema_factory .create (content_value )
36
+ schema = self .schema_factory .create (schema ),
37
+ example = example ,
38
+ examples = examples
35
39
)
0 commit comments