Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
adrianschneider94 opened this issue May 6, 2021 · 1 comment · Fixed by #415
Closed

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

adrianschneider94 opened this issue May 6, 2021 · 1 comment · Fixed by #415
Labels
🐞bug Something isn't working
Milestone

Comments

@adrianschneider94
Copy link

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'
@adrianschneider94 adrianschneider94 added the 🐞bug Something isn't working label May 6, 2021
@dbanty
Copy link
Collaborator

dbanty commented May 6, 2021

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 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞bug Something isn't working
Projects
None yet
2 participants