Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev RELEASE: v0.15.3 #55

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/offat/parsers/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module to parse OAS v3 documentation JSON/YAML files.
'''
from .parser import BaseParser
from ..logger import logger


class InvalidOpenAPIv3File(Exception):
Expand All @@ -27,6 +28,10 @@ def __init__(self, file_or_url: str, spec: dict | None = None) -> None:
def _populate_hosts(self):
servers = self.specification.get('servers', [])
hosts = []
if not servers:
logger.error('Invalid Server Url: Server URLs are missing in spec file')
raise InvalidOpenAPIv3File('Server URLs Not Found in spec file')

for server in servers:
host = server.get('url', '').removeprefix(
'https://').removeprefix('http://').removesuffix('/')
Expand Down
2 changes: 1 addition & 1 deletion src/offat/parsers/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _populate_hosts(self):
host = self.specification.get('host')
if not host:
logger.error('Invalid Host: Host is missing')
raise ValueError('Host Not Found in spec file')
raise InvalidSwaggerFile('Host Not Found in spec file')
hosts = [host]
self.hosts = hosts
self.host = self.hosts[0]
Expand Down
Loading
Loading