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.

[QUESTION] Documenting mounted routes?

See original GitHub issue

Description

As FastAPI is a subclass of Starlette, it is possible to mount any ASGI-compliant app using app.mount; specifically, I have mounted a Starlette endpoint and it works as expected. However, it does not show in the documentation on /docs – am I missing something, or it is something that needs to be implemented yet? Thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
dmig-alarstudioscommented, Nov 28, 2019

@tiangolo stumbled upon same problem recently, my case is slightly different - starlette.routing.Mount gets completely ignored by the docs generation routine:

from fastapi import FastAPI
from fastapi.routing import APIRoute
from starlette.routing import Mount
from starlette.responses import UJSONResponse
import handlers

routes = [
    Mount('/vars', routes=[
        APIRoute('/', handlers.get_vars, methods=['GET'], response_class=UJSONResponse),
        APIRoute('/', handlers.create_vars, methods=['POST'], status_code=204, response_class=UJSONResponse),
        APIRoute('/values', handlers.get_values, methods=['GET'], response_class=UJSONResponse),
        APIRoute('/values', handlers.save_values, methods=['POST'], response_class=UJSONResponse)
    ]),
    Mount('/labels', routes=[
        APIRoute('/records', handlers.save_label_records, methods=['POST'], response_class=UJSONResponse)
    ])
]

app = FastAPI(
    debug=config.get('DEBUG'),
    redoc_url=None, # disable redoc
    default_response_class=UJSONResponse,
    routes=routes
)

Any way to workaround this?

Another issue is that I have to specify response_class=UJSONResponse every time, but that’s not a big deal.

1reaction
berislavlopaccommented, May 12, 2019

Yes, I figured it out, which is why I closed the issue. I might be a neat approach to have the documentation functionality implemented as a mixin or something similar, so it could be reused on any ASGI app. 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Named routes in mounted rails engine - Stack Overflow
The right way. I believe the best solution is to call new_post_path on the Engine's routes proxy, which is available as a helper...
Read more >
Network Documentation Best Practices: What to Create & Why
Network Documentation Best Practices: What to Create & Why ; Useful, Routing protocol, Diagram ; Useful, Security view, Diagram ; Useful, Cloud ...
Read more >
How To Navigate Between Views with Vue Router
js is now listening to route changes and leveraging your src/router/index.js file. However, Vue Router has no way to display the mounted Home....
Read more >
Handbook M-39 - Management of Delivery Services
211 Selecting Period for Mail Counts and Route Inspections . ... must document the problem and request, through appropriate management.
Read more >
Express Tutorial Part 4: Routes and controllers - MDN Web Docs
Overview · "Routes" to forward the supported requests (and any information encoded in request URLs) to the appropriate controller functions.
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