1
1
"""OpenAPI core infos factories module"""
2
+ from openapi_core .compat import lru_cache
3
+ from openapi_core .schema .contacts .factories import ContactFactory
2
4
from openapi_core .schema .infos .models import Info
5
+ from openapi_core .schema .licenses .factories import LicenseFactory
3
6
4
7
5
8
class InfoFactory (object ):
@@ -11,4 +14,31 @@ def create(self, info_spec):
11
14
info_deref = self .dereferencer .dereference (info_spec )
12
15
title = info_deref ['title' ]
13
16
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