Skip to content

OpenAPI servers not being returned according how the docs say they should be #12246

@Kludex

Description

@Kludex

Discussed in #12226

Originally posted by mzealey September 19, 2024

First Check

  • I added a very descriptive title here.
  • I used the GitHub search to find a similar question and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from fastapi import FastAPI

app = FastAPI()

# you can add a test endpoint here or not - same bug either way

Description

$ curl localhost:8$ curl localhost:8000/openapi.json
{"openapi":"3.1.0","info":{"title":"FastAPI","version":"0.1.0"},"paths":{}}

According to the documentation of the servers parameter in FastAPI:

If the servers list is not provided, or is an empty list, the default value would be a dict with a url value of /.

(assuming that root_path_in_servers = True (the default))

Clearly this is not happening.

Operating System

Linux

Operating System Details

No response

FastAPI Version

0.110.3 (but according to github code seems to be in latest also)

Pydantic Version

2.5.3

Python Version

Python 3.10.12

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion or problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions