Skip to content

Commit

Permalink
docs: update how to specify servers with FastAPI (#3874)
Browse files Browse the repository at this point in the history
  • Loading branch information
minaelee authored Jun 18, 2024
1 parent f459d03 commit 15439dd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fern/pages/api-definition/openapi/server-frameworks/fastapi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ from fastapi import FastAPI

FastAPI(
openapi_url="/openapi.json", # <-- this is the file and URL needed to access the OpenAPI spec, `docs_url` and `redoc_url` are convenient wrappers that display the file in a UI!
docs_url="/openapi", # <-- this is the URL to access the Swagger UI, which will point to your OpenAPI spec
docs_url="/docs", # <-- this is the URL to access the Swagger UI, which will point to your OpenAPI spec
redoc_url="/redoc" # <-- this is the URL to access the ReDoc UI, which will point to your OpenAPI spec
)
```
Expand All @@ -35,13 +35,13 @@ FastAPI(
Fern will automatically generate clients that point to the servers you configure within your OpenAPI spec, so it's important to specify the servers that your API will be hosted on.

```python {5}
from fastapi import FastAPI, Server
from fastapi import FastAPI

...

my_production_server = Server(url="http://prod.test.com")

app = FastAPI(servers=[my_production_server])
app = FastAPI(servers=[{"url": "http://prod.test.com", "description": "Production server"}])
# This creates the following server object in your OpenAPI spec:
# "servers":[{"url":"http://prod.test.com","description":"Production server"}],
```

## OpenAPI extensions
Expand Down

0 comments on commit 15439dd

Please sign in to comment.