question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request body assumed always ref

See original GitHub issue

Seems like codegen (0.0.13) expects:

      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Something"

and does not accept:

      requestBody:
        content:
          application/json:
            schema:
              type: string

Log:

Traceback (most recent call last):
  File "/Users/victor/megad-heated-floor-thermostat/.venv/bin/fastapi-codegen", line 8, in <module>
    sys.exit(app())
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/typer/main.py", line 213, in __call__
    return get_command(self)()
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/typer/main.py", line 496, in wrapper
    return callback(**use_params)  # type: ignore
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/fastapi_code_generator/__main__.py", line 26, in main
    return generate_code(input_name, input_text, output_dir, template_dir)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/fastapi_code_generator/__main__.py", line 37, in generate_code
    parsed_object: ParsedObject = parser.parse()
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/fastapi_code_generator/parser.py", line 391, in parse
    return self.parse_paths(openapi)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/fastapi_code_generator/parser.py", line 400, in parse_paths
    return ParsedObject(
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/fastapi_code_generator/parser.py", line 372, in __init__
    operation.arguments
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/functools.py", line 967, in __get__
    val = self.func(instance)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/fastapi_code_generator/parser.py", line 175, in arguments
    return self.get_arguments(snake_case=False)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/fastapi_code_generator/parser.py", line 183, in get_arguments
    argument.argument for argument in self.get_argument_list(snake_case)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/fastapi_code_generator/parser.py", line 197, in get_argument_list
    if self.request:
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/functools.py", line 967, in __get__
    val = self.func(instance)
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/fastapi_code_generator/parser.py", line 113, in request
    type_hint=schema.ref_object_name,
  File "/Users/victor/megad-heated-floor-thermostat/.venv/lib/python3.8/site-packages/datamodel_code_generator/parser/jsonschema.py", line 115, in ref_object_name
    return self.ref.rsplit('/', 1)[-1]  # type: ignore
AttributeError: 'NoneType' object has no attribute 'rsplit'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
koxudaxicommented, Nov 4, 2020

@synclpz I have released a fixed version as 0.0.14

1reaction
koxudaxicommented, Oct 30, 2020

@Baukebrenninkmeijer Thank you for posting the comment. I will work on it this weekend.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP GET with request body - Stack Overflow
HTTP/1.1 specifies that servers SHOULD ignore the body, but RFC 2119 specifies that implementers are allowed to ignore "SHOULD" clauses if they have...
Read more >
Accepting Raw Request Body Content in ASP.NET Core API ...
The RawRequestBodyFormatter simply adds support for the additional content types it supports.
Read more >
Request-body incorrectly parsed · Issue #600 · mock-server ...
For some reason it seems that MockServer is ignoring request's Content-Type header and assumes that body is a string.
Read more >
HTTP/1.1: Method Definitions
This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is...
Read more >
Anatomy of an HTTP Transaction | Node.js
We'll assume that you know, in a general sense, how HTTP requests work, ... When receiving a POST or PUT request, the request...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found