openapi-python-generator icon indicating copy to clipboard operation
openapi-python-generator copied to clipboard

error with Swagger Editor petstore example

Open andrew222651 opened this issue 1 year ago • 4 comments

Describe the bug OpenAPI v3.0.3 file has an error and client not generated

To Reproduce The file openapi.json is from https://editor.swagger.io/ (File | Convert and save as JSON). It has the following error:

$ openapi-python-generator --version
openapi-python-generator, version 0.5.0

$ openapi-python-generator ./openapi.json client1
Generating data from ./openapi.json
Traceback (most recent call last):
  File "/tmp/plop/.venv/bin/openapi-python-generator", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/tmp/plop/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/plop/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/tmp/plop/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/plop/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/plop/.venv/lib/python3.11/site-packages/openapi_python_generator/__main__.py", line 56, in main
    generate_data(
  File "/tmp/plop/.venv/lib/python3.11/site-packages/openapi_python_generator/generate_data.py", line 149, in generate_data
    result = generator(
             ^^^^^^^^^^
  File "/tmp/plop/.venv/lib/python3.11/site-packages/openapi_python_generator/language_converters/python/generator.py", line 39, in generator
    services = generate_services(data.paths, library_config)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/plop/.venv/lib/python3.11/site-packages/openapi_python_generator/language_converters/python/service_generator.py", line 325, in generate_services
    sync_so = generate_service_operation(op, path_name, False)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/plop/.venv/lib/python3.11/site-packages/openapi_python_generator/language_converters/python/service_generator.py", line 279, in generate_service_operation
    params = generate_params(op)
             ^^^^^^^^^^^^^^^^^^^
  File "/tmp/plop/.venv/lib/python3.11/site-packages/openapi_python_generator/language_converters/python/service_generator.py", line 150, in generate_params
    raise Exception(
Exception: Unsupported request body type: <class 'openapi_schema_pydantic.v3.v3_1_0.request_body.RequestBody'>

andrew222651 avatar Mar 15 '24 16:03 andrew222651

same here

yswtrue avatar Mar 16 '24 23:03 yswtrue

I'm seeing the same issue on my OpenAPI v3.1.0 spec that was created with FastAPI.

setu4993 avatar Aug 02 '24 06:08 setu4993