MarketSquare / roboswag

Apache License 2.0
26 stars 2 forks source link

Handle invalid schema #59

Open bhirsz opened 2 years ago

bhirsz commented 2 years ago

It should output user friendly message with schema validation errors.

kamranhaq21 commented 2 years ago

Hi @bhirsz
I was testing roboswag, by using petstore JSON it work properly for me, but when i tried different schemas even they are valid using Prance, it throwing error Processing "katana2.0.json"... -> Resolving external references. Validates OK as Swagger/OpenAPI 2.0! i have tested with swagger 2.0 and openapi 3.0 both, because my schema was in 3.0 https://github.com/LucyBot-Inc/api-spec-converter use this to downgrade my schema. but no luck. Traceback (most recent call last): File "E:\openapidriver\App\Python\lib\runpy.py", line 193, in _run_module_as_main return _run_code(code, main_globals, None, File "E:\openapidriver\App\Python\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "E:\openapidriver\App\Python\Scripts\roboswag.exe__main.py", line 7, in File "E:\openapidriver\App\Python\lib\site-packages\click\core.py", line 1130, in call__ return self.main(*args, kwargs) File "E:\openapidriver\App\Python\lib\site-packages\rich_click\rich_group.py", line 21, in main rv = super().main(args, standalone_mode=False, kwargs) File "E:\openapidriver\App\Python\lib\site-packages\click\core.py", line 1055, in main rv = self.invoke(ctx) File "E:\openapidriver\App\Python\lib\site-packages\click\core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "E:\openapidriver\App\Python\lib\site-packages\click\core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "E:\openapidriver\App\Python\lib\site-packages\click\core.py", line 760, in invoke return __callback(args, kwargs) File "E:\openapidriver\App\Python\lib\site-packages\roboswag\cli.py", line 36, in generate generate_libraries(spec) File "E:\openapidriver\App\Python\lib\site-packages\roboswag\generate\generate.py", line 13, in generate_libraries api_model, swagger = APIModelCreator.from_prance(source) File "E:\openapidriver\App\Python\lib\site-packages\roboswag\generate\models\api.py", line 122, in from_prance api_model.parse_swagger(swagger) File "E:\openapidriver\App\Python\lib\site-packages\roboswag\generate\models\api.py", line 24, in parse_swagger self.parse_paths(swagger) File "E:\openapidriver\App\Python\lib\site-packages\roboswag\generate\models\api.py", line 38, in parse_paths unique_name = pythonify_name(method_body["operationId"]) # TODO fallback since its optional KeyError: 'operationId'