fern-api / fern

Input OpenAPI. Output SDKs and Docs.
https://buildwithfern.com
MIT License
2.45k stars 118 forks source link

docs: update how to specify servers with FastAPI #3874

Closed minaelee closed 2 weeks ago

minaelee commented 2 weeks ago

Existing example with:

from fastapi import FastAPI, Server

resulted in ImportError: cannot import name 'Server' from 'fastapi'.

Per https://github.com/tiangolo/fastapi/pull/1547 tried:

from fastapi.openapi.models import Server

This resulted in 'Server' object has no attribute 'get' exception (supposed to be fixed in PR https://github.com/tiangolo/fastapi/pull/5917 but not merged).

The working solution right now as described in https://github.com/tiangolo/fastapi/pull/1547 is to not use Server at all and pass a dictionary as shown in this commit.

Also see: https://fastapi.tiangolo.com/reference/fastapi/?h=docs_url#fastapi.FastAPI--example