codeasashu / openman

Postman to OpenAPI Spec converter with mocking and documentation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Argument must be str, not dict

shuarey opened this issue · comments

Attempted to execute the following command:

C:\Users\{User}\AppData\Local\Programs\Python\Python39\Scripts>openman convert -f json postman_collection.json swagger.json

The output file was 0KB.
I tried to do this with the standard yaml output just to see if anything would work and got a schema output with only the name of my schema and nothing else. So, not super helpful for me.

Traceback (most recent call last):
  File "c:\users\{User}\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\{User}\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\{User}\AppData\Local\Programs\Python\Python39\Scripts\openman.exe\__main__.py", line 7, in <module>
  File "c:\users\{User}\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\{User}\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\{User}\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\{User}\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\{User}\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\{User}\appdata\local\programs\python\python39\lib\site-packages\openman\cli.py", line 34, in convert
    f.write(converted)
TypeError: write() argument must be str, not dict

@shuarey Thanks for pointing this out. This is indeed a bug. I'll add a test and try to resolve shortly.
Thank you for the bug report 😊

@shuarey Can you please give this commit a try? Steps to try:

pip uninstall openman

pip install git+https://github.com/codeasashu/openman@fix-1

and then, try your command:

openman convert -f json postman_collection.json swagger.json

Okay, well, now it outputs a file with no error, but nothing is exported except for the title

{
    "paths": {},
    "info": {
        "title": "Service Network (Authorizer)",
        "version": "1.0.0"
    },
    "openapi": "3.0.0"
}

so, technically, this solved my problem :)
Now, if it would convert the file completely, I'd be happier :)

@shuarey For that, I might need to see what is failing in your file. If you don't mind, can you share the file on gist so I can test? Also, are you using postman export format v2.1+?

yes, using v2.1+

the file format is .txt, but it was exported as .json the conversion behaves identically if saved as either.

collection.txt

@shuarey Can you try now? I had a wrong schema for folder item, causing the issue

Excellent! this worked! Thank you very much :)