Skip to content

Commit b22e70a

Browse files
committed
new version
1 parent e4faec6 commit b22e70a

4 files changed

Lines changed: 22 additions & 18 deletions

File tree

‎python_framework/api/src/helper/Serializer.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ def importResource(resourceName, resourceModuleName=None) :
7070
log.warning(importResource, f'Not possible to import "{resourceName}" resource from "{resourceModuleName}" module. Going for a second attempt')
7171
try :
7272
module = importlib.import_module(resourceModuleName)
73-
except :
73+
except Exception as exception:
7474
module = None
75-
log.warning(importResource, f'Not possible to import "{resourceName}" resource from "{resourceModuleName}" module in the second attempt either')
75+
log.error(importResource, f'Not possible to import "{resourceName}" resource from "{resourceModuleName}" module in the second attempt either', exception)
7676
if module :
7777
try :
7878
resource = getattr(module, resourceName)

‎python_framework/api/src/service/openapi/OpenApiDocumentationFile.py‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@
22
from python_helper import Constant as c
33
from python_helper import StringHelper
44

5-
def getDocumentationFilePath(globals):
6-
g = globals
7-
return f'{g.apiPath}api{g.OS_SEPARATOR}resource{g.OS_SEPARATOR}swaggerui{g.OS_SEPARATOR}swagger.json'
5+
KW_OPEN_API = 'swagger'
6+
KW_JSON = 'json'
7+
DOCUMENTATION_FILE = f'{KW_OPEN_API}{c.DOT}{KW_JSON}'
88

9-
def loadDocumentationAsString(globals):
10-
documentationFilePath = getDocumentationFilePath(globals)
11-
with open(documentationFilePath, globals.READ, encoding=globals.ENCODING) as documentationFile :
9+
def getDocumentationFilePath(apiInstance):
10+
# return f'{g.apiPath}api{g.OS_SEPARATOR}resource{g.OS_SEPARATOR}swaggerui{g.OS_SEPARATOR}swagger.json'
11+
return f'{apiInstance.documentationFolder}{g.OS_SEPARATOR}swagger.json'
12+
13+
def loadDocumentationAsString(apiInstance):
14+
documentationFilePath = getDocumentationFilePath(apiInstance)
15+
with open(documentationFilePathapiInstance.documentationFolder, globals.READ, encoding=globals.ENCODING) as documentationFile :
1216
documentationAsString = c.NOTHING.join(documentationFile.readlines())
1317
return documentationAsString
1418

15-
def loadDocumentation(globals):
16-
documentationAsString = loadDocumentationAsString(globals)
19+
def loadDocumentation(apiInstance):
20+
documentationAsString = loadDocumentationAsString(apiInstance)
1721
return json.loads(documentationAsString)
1822

19-
def overrideDocumentation(globals, documentation):
23+
def overrideDocumentation(apiInstance):
24+
globals = apiInstance.globals
2025
documentationAsString = StringHelper.stringfyThisDictionary(documentation)
21-
documentationFilePath = getDocumentationFilePath(globals)
26+
documentationFilePath = getDocumentationFilePath(apiInstance)
2227
with open(documentationFilePath, globals.OVERRIDE, encoding=globals.ENCODING) as documentationFile :
2328
documentationFile.write(documentationAsString)

‎python_framework/api/src/service/openapi/OpenApiManager.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
from python_framework.api.src.service.openapi.OpenApiKey import Key as k
77
from python_framework.api.src.service.openapi.OpenApiValue import Value as v
88
from python_framework.api.src.service.openapi import OpenApiDocumentationFile
9+
from python_framework.api.src.service.openapi.OpenApiDocumentationFile import KW_OPEN_API, KW_JSON, DOCUMENTATION_FILE
910

10-
KW_OPEN_API = 'swagger'
1111
KW_UI = 'ui'
12-
KW_JSON = 'json'
13-
OPEN_API_URL = f'/{KW_OPEN_API}'
14-
DOCUMENTATION_FILE = f'{KW_OPEN_API}{c.DOT}{KW_JSON}'
12+
OPEN_API_URL = f'/{OpenApiDocumentationFile.KW_OPEN_API}'
1513
COLON_DOUBLE_BAR = '://'
1614
LOCAL_HOST = 'localhost'
1715

@@ -68,9 +66,10 @@ def addSwagger(appInstance, apiInstance):
6866
documentationUrl,
6967
DOCUMENTATION_FILE
7068
)
69+
# appInstance.documentationFolder = swaggerUi._static_folder
7170
swaggerUi._static_folder = f'{globals.currentPath}{KW_API}{globals.OS_SEPARATOR}{KW_RESOURCE}{globals.OS_SEPARATOR}{KW_OPEN_API}{KW_UI}{globals.OS_SEPARATOR}'
7271
appInstance.register_blueprint(swaggerUi, url_prefix=documentationUrl)
73-
OpenApiDocumentationFile.overrideDocumentation(globals, apiInstance.documentation)
72+
OpenApiDocumentationFile.overrideDocumentation(apiInstance)
7473

7574
################################################################################
7675

‎setup.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from distutils.core import setup
22

3-
version = '0.0.1-11'
3+
version = '0.0.1-12'
44
name = 'python_framework'
55
url = f'https://github.com/SamuelJansen/{name}/'
66

0 commit comments

Comments
 (0)