99 extract_typed_props ,
1010)
1111from openapi_parser .errors import ParserError
12+ from openapi_parser .logging import log_ctx
1213from openapi_parser .specification import Contact , Info , License
1314
1415logger = logging .getLogger (__name__ )
@@ -19,29 +20,34 @@ class InfoBuilder:
1920
2021 def build (self , data : dict [str , Any ]) -> Info :
2122 """Build an Info object from a raw dict."""
22- title = data .get ("title" )
23-
24- if title is None :
25- raise ParserError ("Info section is missing required 'title' property" )
26-
27- logger .debug (f"Info section parsing [title={ title } ]" )
28-
29- attrs_map = {
30- "title" : PropertyMeta (name = "title" , cast = str ),
31- "version" : PropertyMeta (name = "version" , cast = str ),
32- "description" : PropertyMeta (name = "description" , cast = str ),
33- "terms_of_service" : PropertyMeta (name = "termsOfService" , cast = str ),
34- "license" : PropertyMeta (name = "license" , cast = self ._create_license ),
35- "contact" : PropertyMeta (name = "contact" , cast = self ._create_contact ),
36- }
37-
38- attrs = extract_typed_props (data , attrs_map )
39- attrs ["extensions" ] = extract_extension_attributes (data )
40-
41- if attrs ["extensions" ]:
42- logger .debug (f"Extracted custom properties [{ attrs ['extensions' ].keys ()} ]" )
43-
44- return Info (** attrs )
23+ with log_ctx ("info" ):
24+ title = data .get ("title" )
25+
26+ if title is None :
27+ raise ParserError (
28+ "Info section is missing required 'title' property" ,
29+ )
30+
31+ logger .debug (f"Info section parsing [title={ title } ]" )
32+
33+ attrs_map = {
34+ "title" : PropertyMeta (name = "title" , cast = str ),
35+ "version" : PropertyMeta (name = "version" , cast = str ),
36+ "description" : PropertyMeta (name = "description" , cast = str ),
37+ "terms_of_service" : PropertyMeta (name = "termsOfService" , cast = str ),
38+ "license" : PropertyMeta (name = "license" , cast = self ._create_license ),
39+ "contact" : PropertyMeta (name = "contact" , cast = self ._create_contact ),
40+ }
41+
42+ attrs = extract_typed_props (data , attrs_map )
43+ attrs ["extensions" ] = extract_extension_attributes (data )
44+
45+ if attrs ["extensions" ]:
46+ logger .debug (
47+ f"Extracted custom properties [{ attrs ['extensions' ].keys ()} ]"
48+ )
49+
50+ return Info (** attrs )
4551
4652 @staticmethod
4753 def _create_license (data : dict [str , Any ]) -> License :
0 commit comments