Skip to content

AttributeError: 'int' object has no attribute 'replace' #414

Closed

Description

@adrianschneider94

I'm trying to convert the following API:
https://start.camunda.com/openapi.json

However, I'm getting the error AttributeError: 'int' object has no attribute 'replace',
Stacktrace:

Traceback (most recent call last):
  File "/usr/local/bin/openapi-python-client", line 8, in <module>
    sys.exit(app())
  File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 497, in wrapper
    return callback(**use_params)  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/cli.py", line 140, in generate
    errors = create_new_client(
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/__init__.py", line 296, in create_new_client
    project = _get_project_for_url_or_path(
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/__init__.py", line 269, in _get_project_for_url_or_path
    openapi = GeneratorData.from_dict(data_dict, config=config)
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/parser/openapi.py", line 333, in from_dict
    endpoint_collections_by_tag, schemas = EndpointCollection.from_data(
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/parser/openapi.py", line 45, in from_data
    endpoint, schemas = Endpoint.from_data(
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/parser/openapi.py", line 283, in from_data
    result, schemas = Endpoint._add_parameters(endpoint=endpoint, data=data, schemas=schemas, config=config)
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/parser/openapi.py", line 217, in _add_parameters
    prop, schemas = property_from_data(
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/parser/properties/__init__.py", line 539, in property_from_data
    return _property_from_data(
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/parser/properties/__init__.py", line 462, in _property_from_data
    return _string_based_property(name=name, required=required, data=data), schemas
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/parser/properties/__init__.py", line 266, in _string_based_property
    default=convert("str", data.default),
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/parser/properties/converter.py", line 33, in convert
    return _CONVERTERS[type_string](value)
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/parser/properties/converter.py", line 62, in _convert_string
    return f"{utils.remove_string_escapes(value)!r}"
  File "/usr/local/lib/python3.9/site-packages/openapi_python_client/utils.py", line 55, in remove_string_escapes
    return value.replace('"', r"\"")
AttributeError: 'int' object has no attribute 'replace'

Activity

  1. dbanty commented on May 6, 2021

    @dbanty
    Collaborator

    Hey @adrianschneider94 thanks for reporting the issue! Looks like that exception is happening because there is a value of type "string" with a default that is a JSON number. I'll fix that so it doesn't crash anymore 😅. Unfortunately after fixing it locally there is a lot of your schema that doesn't get generated, looks like that's mostly because we don't support recursive models yet (see #338). Guess we'll keep bumping that one up in priority 😁

  2. added this to the Next milestone on May 6, 2021
  3. added a commit that references this issue on May 6, 2021
    125d3e0
  4. added a commit that references this issue on May 12, 2021
    fddf68a
  5. added a commit that references this issue on May 14, 2021
    79d10fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions