MarketSquare / roboswag

Apache License 2.0
26 stars 2 forks source link

Support for API from JSON and YAML #25

Closed mnojek closed 2 years ago

mnojek commented 2 years ago

Check if both of these formats are parsed correctly.

terezachudobova commented 2 years ago

Dear authors, I am attaching a console output while trying to use a yaml file to run roboswag:

 File "C:\Program Files\Python397\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python397\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\cen69317\AppData\Roaming\Python\Python39\Scripts\roboswag.exe\__main__.py", line 7, in <module>
  File "C:\Users\cen69317\AppData\Roaming\Python\Python39\site-packages\roboswag\__main__.py", line 27, in run_roboswag
    generate_cli()
  File "C:\Users\cen69317\AppData\Roaming\Python\Python39\site-packages\roboswag\__main__.py", line 23, in generate_cli
    generate(args.spec)
  File "C:\Users\cen69317\AppData\Roaming\Python\Python39\site-packages\roboswag\generate\generate.py", line 13, in generate
    api_model, swagger = APIModelCreator.from_prance(source)
  File "C:\Users\cen69317\AppData\Roaming\Python\Python39\site-packages\roboswag\generate\models\api.py", line 123, in from_prance
    api_model.parse_swagger(swagger)
  File "C:\Users\cen69317\AppData\Roaming\Python\Python39\site-packages\roboswag\generate\models\api.py", line 25, in parse_swagger
    self.parse_paths(swagger)
  File "C:\Users\cen69317\AppData\Roaming\Python\Python39\site-packages\roboswag\generate\models\api.py", line 39, in parse_paths
    unique_name = pythonify_name(method_body["operationId"])  # TODO fallback since its optional
KeyError: 'operationId'

The output is the same when the .yaml file is converted into the .json. Hopefully this helps in resolving this. Thank you for your extraordinary effort, Tereza

bhirsz commented 2 years ago

# TODO fallback since its optional comment from the source code is our suspect :) And it's most likely not connected to yaml parsing but the fact we're trying to use parameter that is optional. Thanks for the report, I will update the code to use some fallback options if operationId is missing.

terezachudobova commented 2 years ago

Thank you Bartłomiej!

bhirsz commented 2 years ago

@terezachudobova The issue you mentioned will be fixed in the next release (0.3.0, I will release it right now). Now along with other fixes in #43 it's possible to generate classess without any problems. Though it's probably good idea to wait few days since I'll update it with other changes and possibly also check the proxy issue from the other thread.

terezachudobova commented 2 years ago

That's amazing news! Thank you for looking into the issues and I am looking forward to update roboswag in a few days as recommended.