Skip to content

Swagger UI does not work correctly in Ligare.web >= 0.5.0 due to dependency connexion == 3.2.0 #222

@aholmes

Description

@aholmes

Ligare.web >= 0.5.0 depends on connexion==3.2.0, which has a breaking change regarding access to /openapi.json (which is used by Swagger UI). For any Ligare web application running on version >= 0.5.0, after a POST request, subsequent access to /openapi.json will cause a 500 error. For example:

<InvalidSpecification: "{'required': True, 'content': {'application/json': {'schema': {'properties': {'time_started': {'type': 'string'}, 'time_finished': {'type': 'string'}, 'slurm_id': {'type': 'string'}, 'user': {'type': 'string'}, 'reason': {'type': 'string'}, 'archive_files': {'type': 'array', 'items': {'type': 'object', 'properties': {'blob_url': {'type': 'string'}, 'file_path': {'type': 'string'}, 'exists_in_hot': {'type': 'boolean'}, 'exists_in_archive': {'type': 'boolean'}, 'archive_time': {'type': 'string'}, 'file_size': {'type': 'integer'}}}}}, 'components': {'schemas': {'ArchiveTask': {'properties': {'time_started': {'type': 'string'}, 'time_finished': {'type': 'string'}, 'slurm_id': {'type': 'string'}, 'user': {'type': 'string'}, 'reason': {'type': 'string'}, 'archive_files': {'type': 'array', 'items': {'type': 'object', 'properties': {'blob_url': {'type': 'string'}, 'file_path': {'type': 'string'}, 'exists_in_hot': {'type': 'boolean'}, 'exists_in_archive': {'type': 'boolean'}, 'archive_time': {'type': 'string'}, 'file_size': {'type': 'integer'}}}}}}}}}}}} is not valid under any of the given schemas">
Traceback (most recent call last):
  File "/home/aholmes/repos/package-archive-db-api/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/aholmes/repos/package-archive-db-api/.venv/lib/python3.10/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
  File "/home/aholmes/repos/package-archive-db-api/.venv/lib/python3.10/site-packages/connexion/middleware/swagger_ui.py", line 110, in _get_openapi_json
    content=jsonifier.dumps(self._spec_for_prefix(request)),
  File "/home/aholmes/repos/package-archive-db-api/.venv/lib/python3.10/site-packages/connexion/middleware/swagger_ui.py", line 73, in _spec_for_prefix
    return self.specification.with_base_path(base_path).raw
  File "/home/aholmes/repos/package-archive-db-api/.venv/lib/python3.10/site-packages/connexion/spec.py", line 221, in with_base_path
    new_spec = self.clone()
  File "/home/aholmes/repos/package-archive-db-api/.venv/lib/python3.10/site-packages/connexion/spec.py", line 207, in clone
    return type(self)(copy.deepcopy(self._spec))
  File "/home/aholmes/repos/package-archive-db-api/.venv/lib/python3.10/site-packages/connexion/spec.py", line 82, in __init__
    self._validate_spec(raw_spec)
  File "/home/aholmes/repos/package-archive-db-api/.venv/lib/python3.10/site-packages/connexion/spec.py", line 98, in _validate_spec
    raise InvalidSpecification.create_from(e)
connexion.exceptions.InvalidSpecification: {'required': True, 'content': {'application/json': {'schema': {'properties': {'time_started': {'type': 'string'}, 'time_finished': {'type': 'string'}, 'slurm_id': {'type': 'string'}, 'user': {'type': 'string'}, 'reason': {'type': 'string'}, 'archive_files': {'type': 'array', 'items': {'type': 'object', 'properties': {'blob_url': {'type': 'string'}, 'file_path': {'type': 'string'}, 'exists_in_hot': {'type': 'boolean'}, 'exists_in_archive': {'type': 'boolean'}, 'archive_time': {'type': 'string'}, 'file_size': {'type': 'integer'}}}}}, 'components': {'schemas': {'ArchiveTask': {'properties': {'time_started': {'type': 'string'}, 'time_finished': {'type': 'string'}, 'slurm_id': {'type': 'string'}, 'user': {'type': 'string'}, 'reason': {'type': 'string'}, 'archive_files': {'type': 'array', 'items': {'type': 'object', 'properties': {'blob_url': {'type': 'string'}, 'file_path': {'type': 'string'}, 'exists_in_hot': {'type': 'boolean'}, 'exists_in_archive': {'type': 'boolean'}, 'archive_time': {'type': 'string'}, 'file_size': {'type': 'integer'}}}}}}}}}}}} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['requestBody']:
    {'oneOf': [{'$ref': '#/definitions/RequestBody'},
               {'$ref': '#/definitions/Reference'}]}

On instance['paths']['/archivetask']['post']['requestBody']:
    {'required': True,
     'content': {'application/json': {'schema': {'properties': {'time_started': {'type': 'string'},
                                                                'time_finished': {'type': 'string'},
                                                                'slurm_id': {'type': 'string'},
                                                                'user': {'type': 'string'},
                                                                'reason': {'type': 'string'},
                                                                'archive_files': {'type': 'array',
                                                                                  'items': {'type': 'object',
                                                                                            'properties': {'blob_url': {'type': 'string'},
                                                                                                           'file_path': {'type': 'string'},
                                                                                                           'exists_in_hot': {'type': 'boolean'},
                                                                                                           'exists_in_archive': {'type': 'boolean'},
                                                                                                           'archive_time': {'type': 'string'},
                                                                                                           'file_size': {'type': 'integer'}}}}},
                                                 'components': {'schemas': {'ArchiveTask': {'properties': {'time_started': {'type': 'string'},
                                                                                                           'time_finished': {'type': 'string'},
                                                                                                           'slurm_id': {'type': 'string'},
                                                                                                           'user': {'type': 'string'},
                                                                                                           'reason': {'type': 'string'},
                                                                                                           'archive_files': {'type': 'array',
                                                                                                                             'items': {'type': 'object',
                                                                                                                                       'properties': {'blob_url': {'type': 'string'},
                                                                                                                                                      'file_path': {'type': 'string'},
                                                                                                                                                      'exists_in_hot': {'type': 'boolean'},
                                                                                                                                                      'exists_in_archive': {'type': 'boolean'},
                                                                                                                                                      'archive_time': {'type': 'string'},
                                                                                                                                                      'file_size': {'type': 'integer'}}}}}}}}}}}}
INFO:     127.0.0.1:49570 - "GET /openapi.json HTTP/1.1" 500 Internal Server Error

The issue is described here spec-first/connexion#2046.

For Ligare web applications, a temporary fix is to run pip install connexion==3.1.0 after installing the other application dependencies.

Metadata

Metadata

Assignees

Labels

blockedBlocked by other issuesdependenciesPull requests that update a dependency file

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions