Skip to content
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

Library does not hadle option regex group #58

Closed
luiscoms opened this issue Jul 20, 2022 · 1 comment
Closed

Library does not hadle option regex group #58

luiscoms opened this issue Jul 20, 2022 · 1 comment

Comments

@luiscoms
Copy link

Describe the bug
My api have an optional group on route, and it braaks on start when I use tornado-swagger library

To Reproduce
Steps to reproduce the behavior:

My api is configured as above

    handlers = [
        url(r'/(?:status)?', StatusHandler),
        # other handlers
    ]
    setup_swagger(handlers)

    app = Application(handlers)

When I run, the following error occurs:

File "/project/path/venv/lib/python3.8/site-packages/tornado_swagger/setup.py", line 58, in setup_swagger
    swagger_schema = generate_doc_from_endpoints(
  File "/project/path/venv/lib/python3.8/site-packages/tornado_swagger/_builders.py", line 276, in generate_doc_from_endpoints
    return doc_builders[api_definition_version].generate_doc(
  File "/project/path/venv/lib/python3.8/site-packages/tornado_swagger/_builders.py", line 240, in generate_doc
    "paths": _extract_paths(routes),
  File "/project/path/venv/lib/python3.8/site-packages/tornado_swagger/_builders.py", line 124, in _extract_paths
    paths[_format_handler_path(route, method_name)].update({method_name: method_description})
  File "/project/path/venv/lib/python3.8/site-packages/tornado_swagger/_builders.py", line 94, in _format_handler_path
    route_pattern = route_pattern.replace(entity, "{%s}" % parameters[i], 1)
IndexError: list index out of range

It is because there is no parameter

Captura de tela de 2022-07-20 18-23-16

Expected behavior

The aplications should show urls like this

Captura de tela de 2022-07-20 17-23-15

Additional context

For now, I am duplicating entry, but It sims not correct for me

    handlers = [
        url(r'/', StatusHandler),
        url(r'/status', StatusHandler),
        # other handlers
    ]
    setup_swagger(handlers)

    app = Application(handlers)
@mrk-andreev
Copy link
Owner

Issue with IndexError was fixed in 1.4.4. Actual behavior is ignore paths like this.

I think that use optionals in path does not cover rest api url convention best practices. Unfortunately I have no plant for support every regexp in path. Furthermore tornado does not recognize this regexp, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants