KnowledgeCaptureAndDiscovery / OBA

Ontology based APIs
Apache License 2.0
37 stars 11 forks source link

OBA is not geneating the class variables #134

Closed mosoriob closed 4 years ago

mosoriob commented 4 years ago

I removed the description line from the config.yaml file and re-generated it. Everything works fine until I try and start the server when it returns two errors:

Dougal-Watts-Retina-MacBook-Pro:server dwatt$ docker run -p 8080:8080 openapi_server
2020-10-10 04:20:29,473 - root - ERROR - /usr/src/app/contexts/context_overwrite.json missing
2020-10-10 04:20:29,905 - openapi_server.cached - WARNING - Cache file does not exist: [Errno 2] No such file or directory: '/usr/src/app/openapi_server/openapi/openapi.yaml.cache'
2020-10-10 04:20:30,018 - root - ERROR - /usr/src/app/contexts/context_overwrite.json missing
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/connexion/apis/abstract.py", line 209, in add_paths
    self.add_operation(path, method)
  File "/usr/local/lib/python3.8/site-packages/connexion/apis/abstract.py", line 162, in add_operation
    operation = make_operation(
  File "/usr/local/lib/python3.8/site-packages/connexion/operations/__init__.py", line 8, in make_operation
    return spec.operation_cls.from_spec(spec, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/connexion/operations/openapi.py", line 128, in from_spec
    return cls(
  File "/usr/local/lib/python3.8/site-packages/connexion/operations/openapi.py", line 75, in __init__
    super(OpenAPIOperation, self).__init__(
  File "/usr/local/lib/python3.8/site-packages/connexion/operations/abstract.py", line 96, in __init__
    self._resolution = resolver.resolve(self)
  File "/usr/local/lib/python3.8/site-packages/connexion/resolver.py", line 40, in resolve
    return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
  File "/usr/local/lib/python3.8/site-packages/connexion/resolver.py", line 64, in resolve_function_from_operation_id
    raise ResolverError(msg, sys.exc_info())
connexion.exceptions.ResolverError: <ResolverError: Cannot resolve operationId "openapi_server.controllers.business_user_controller.business_users_get"! Import error was "cannot import name 'BUSINESSUSER_TYPE_NAME' from 'openapi_server.utils.vars' (/usr/src/app/openapi_server/utils/vars.py)">

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/src/app/openapi_server/__main__.py", line 20, in <module>
    main()
  File "/usr/src/app/openapi_server/__main__.py", line 13, in main
    app.add_api('openapi.yaml',
  File "/usr/local/lib/python3.8/site-packages/connexion/apps/flask_app.py", line 57, in add_api
    api = super(FlaskApp, self).add_api(specification, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/connexion/apps/abstract.py", line 144, in add_api
    api = self.api_cls(specification,
  File "/usr/local/lib/python3.8/site-packages/connexion/apis/abstract.py", line 111, in __init__
    self.add_paths()
  File "/usr/local/lib/python3.8/site-packages/connexion/apis/abstract.py", line 216, in add_paths
    self._handle_add_operation_error(path, method, err.exc_info)
  File "/usr/local/lib/python3.8/site-packages/connexion/apis/abstract.py", line 231, in _handle_add_operation_error
    raise value.with_traceback(traceback)
  File "/usr/local/lib/python3.8/site-packages/connexion/resolver.py", line 61, in resolve_function_from_operation_id
    return self.function_resolver(operation_id)
  File "/usr/local/lib/python3.8/site-packages/connexion/utils.py", line 123, in get_function_from_name
    raise last_import_error
  File "/usr/local/lib/python3.8/site-packages/connexion/utils.py", line 111, in get_function_from_name
    module = importlib.import_module(module_name)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/app/openapi_server/controllers/business_user_controller.py", line 4, in <module>
    from openapi_server.utils.vars import BUSINESSUSER_TYPE_NAME, BUSINESSUSER_TYPE_URI
ImportError: cannot import name 'BUSINESSUSER_TYPE_NAME' from 'openapi_server.utils.vars' (/usr/src/app/openapi_server/utils/vars.py)

Originally posted by @DougalW in https://github.com/KnowledgeCaptureAndDiscovery/OBA/issues/132#issuecomment-706485328

mosoriob commented 4 years ago

Confirmed.

The controller file doesn't match with the vars file vars.py

import connexion
import six
from openapi_server import query_manager
from openapi_server.utils.vars import BUSINESSUSER_TYPE_NAME, BUSINESSUSER_TYPE_URI
BUSINESS_USER_TYPE_URI = "https://businessontology.com/ontology/Business_User"
BUSINESS_USER_TYPE_NAME = "Business_User"
mosoriob commented 4 years ago

@dgarijo you can test it.

dgarijo commented 4 years ago

I tested it and everything works. Thanks