11"""OpenAPI core infos factories module"""
2+ from openapi_core .compat import lru_cache
3+ from openapi_core .schema .contacts .factories import ContactFactory
24from openapi_core .schema .infos .models import Info
5+ from openapi_core .schema .licenses .factories import LicenseFactory
36
47
58class InfoFactory (object ):
@@ -11,4 +14,31 @@ def create(self, info_spec):
1114 info_deref = self .dereferencer .dereference (info_spec )
1215 title = info_deref ['title' ]
1316 version = info_deref ['version' ]
14- return Info (title , version )
17+ description = info_deref .get ('description' )
18+ terms_of_service = info_deref .get ('termsOfService' )
19+
20+ contact = None
21+ if 'contact' in info_deref :
22+ contact_spec = info_deref .get ('contact' )
23+ contact = self .contact_factory .create (contact_spec )
24+
25+ license = None
26+ if 'license' in info_deref :
27+ license_spec = info_deref .get ('license' )
28+ license = self .license_factory .create (license_spec )
29+
30+ return Info (
31+ title , version ,
32+ description = description , terms_of_service = terms_of_service ,
33+ contact = contact , license = license ,
34+ )
35+
36+ @property
37+ @lru_cache ()
38+ def contact_factory (self ):
39+ return ContactFactory (self .dereferencer )
40+
41+ @property
42+ @lru_cache ()
43+ def license_factory (self ):
44+ return LicenseFactory (self .dereferencer )
0 commit comments