manchenkoff / openapi3-parser

OpenAPI 3 parser to use a specification inside of the code in your projects
https://pypi.org/project/openapi3-parser/
MIT License
64 stars 33 forks source link

Fix: Missing import for except block criteria. #47

Closed moisesbenzan closed 1 year ago

moisesbenzan commented 1 year ago

Missing import statement causing another exception to be raised when the second except clause was caught (reproducible with an open API schema URL that would return a 404 Not Found error), due to missing imports.

manchenkoff commented 1 year ago

Hey @moisesbenzan, thanks for the contribution! Actually, it looks like this import is unnecessary since there is no general except block. I would suggest changing it to smth like that:

try:
    logger.debug(f"Resolving specification file")
    self._resolver.parse()
    return self._resolver.specification
except prance.ValidationError as error:
    raise ParserError(f"OpenAPI validation error: {error}")
except Exception as error:
    raise ParserError(f"OpenAPI file parsing error: {error}")

and remove the import of course 🙂

manchenkoff commented 1 year ago

Fixed by #52