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.

[BUG] Swagger `Try it out` missing parameters when using `include_router` with a url variable in the prefix

See original GitHub issue

Describe the bug When a router is added to an app using include_router, and the prefix parameter contains a url variable (e.g. ‘/{account}/devices’), the variable is not included as a parameter in the swagger documentation.

To Reproduce Steps to reproduce the behavior:

  1. Create a router using APIRouter()
  2. Add the router to the app using app.include_router with a prefix.
  3. Add a url variable to the prefix
app.include_router(
    device_router,
    prefix="/{account}/devices"
)
  1. Launch the application and browse to /docs
  2. Expand the path and click the Try it out button

Expected behavior When browsing the swagger docs on http://localhost:8080/docs, I want to be able to use the Try it out feature.

Screenshots image

Environment:

  • OS: [e.g. Linux / macOS]

  • FastAPI Version: 0.38.1

  • Python version: 3.7

Additional context

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
dmontagucommented, Oct 28, 2019

Yeah this sounds like a bug in the openapi schema generation. Probably worth a check to see if updating to 0.42 fixes it.

0reactions
tiangolocommented, Apr 10, 2020

Thanks for the help here everyone! 👏 🙇

I assume you solved your problem, so thanks for reporting back and closing the issue 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Describing Parameters - Swagger
Query parameters can be primitive values, arrays and objects. OpenAPI 3.0 provides several ways to serialize objects and arrays in the query string....
Read more >
Configuration - Swagger Documentation
The swagger-config.yaml in the project root directory, if it exists, is baked into ... Enables overriding configuration parameters via URL search params.
Read more >
Parameter Serialization - Swagger
Parameter Serialization · style defines how multiple values are delimited. Possible styles depend on the parameter location – path, query, header or cookie....
Read more >
Paths and Operations - Swagger
You can use curly braces {} to mark parts of an URL as path parameters: ... The API client needs to provide appropriate...
Read more >
OpenAPI Specification - Version 2.0 - Swagger
The list can use the Reference Object to link to parameters that are defined at the Swagger Object's parameters. There can be one...
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