Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature Request: Option to Use Stoplight.io as OpenAPI Viewer#14385

Unanswered
terapias-pro asked this question inQuestions
Discussion options

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 toPydantic.
  • I already checked if it is not related to FastAPI but toSwagger UI.
  • I already checked if it is not related to FastAPI but toReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

suggestion:app=FastAPI(docs_viewer="stoplight")

Description

Hi,

I'd like to suggest a new feature:
the option to use Stoplight.io (https://github.com/stoplightio) as an alternative OpenAPI viewer alongside Swagger UI and ReDoc.

Stoplight offers a more modern and user-friendly interface for API exploration, including features such as improved navigation, schema visualization, and endpoint interaction and sample code generation in multiple program language.

Having a configuration option like:

Would the FastAPI team consider supporting this as a built-in alternative or sharing guidelines on how to integrate Stoplight as the docs viewer?

Thanks in advance, and keep up the great work!

Operating System

macOS

Operating System Details

26.1 Tahoe

FastAPI Version

0.104.1

Pydantic Version

2.5.2

Python Version

3.9.6

Additional Context

No response

You must be logged in to vote

Replies: 3 comments 1 reply

Comment options

Hi@terapias-pro,

This is a great suggestion. Stoplight Elements definitely offers a cleaner UI for many use cases.

While waiting to see if this gets added natively, you can actually implement this today without any changes to FastAPI internals. You just need to disable the default docs and serve the Elements web component via a custom HTML response.

fromfastapiimportFastAPIfromfastapi.responsesimportHTMLResponse# Disable default docs to free up the /docs routeapp=FastAPI(docs_url=None,redoc_url=None)@app.get("/docs",include_in_schema=False)asyncdefstoplight_elements():returnHTMLResponse("""<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">    <title>API Docs</title>    <script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>    <link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">  </head>  <body>    <elements-api      apiDescriptionUrl="/openapi.json"      router="hash"      layout="sidebar"    />  </body></html>""")@app.get("/")defread_root():return {"Hello":"World"}

If you find this breakdown helpful for your debugging, please mark this response as the answer so others with similar credit-tracking needs can find it easily!

You must be logged in to vote
0 replies

This comment was marked as disruptive content.

@YuriiMotov
Comment options

@terapias-pro, please, stop posting LLM-generated answers here!

Comment options

We already have PR to add such support:#5168

As for me, the Stoplight's UI is quite raw. I'm not sure it's good idea to add such support to FastAPI.

I think theapproach suggested byJunjieAraoXiong us simple enough. You can use any documentation system you want

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
questionQuestion or problem
4 participants
@terapias-pro@YuriiMotov@engripaye@JunjieAraoXiong

[8]ページ先頭

©2009-2025 Movatter.jp