Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastApi integration #13

Closed
Trinkes opened this issue May 5, 2021 · 3 comments
Closed

FastApi integration #13

Trinkes opened this issue May 5, 2021 · 3 comments

Comments

@Trinkes
Copy link

Trinkes commented May 5, 2021

Hello,
I'm currently using python's library FastAPI to make the endpoints and generate its Redoc documentation, is there any way to integrate your project using FastApi library?

@wll8
Copy link
Owner

wll8 commented May 6, 2021

You may need to slightly modify the source code of fastapi, similar to the following form:

html = f"""
<!DOCTYPE html>
<html>
<head>
<title>{title}</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
"""
if with_google_fonts:
    html += """
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
"""
html += f"""
<link rel="shortcut icon" href="{redoc_favicon_url}">
<style>
  body {{
    margin: 0;
    padding: 0;
  }}
</style>
</head>
<body>
- <redoc spec-url="{openapi_url}"></redoc>
- <script src="{redoc_js_url}"> </script>
+ <div id="redoc-container"></div>
+ <script src="//cdn.jsdelivr.net/npm/redoc@2.0.0-rc.48/bundles/redoc.standalone.min.js"> </script>
+ <script src="//cdn.jsdelivr.net/gh/wll8/redoc-try@1.3.4/dist/try.js"></script>
+ <script>
+   initTry({openapi_url})
+ </script>
</body>
</html>
"""

@Trinkes
Copy link
Author

Trinkes commented May 6, 2021

For future references, to make it work, I had to change your code:
initTry({openapi_url})
to
initTry(\"{openapi_url}\")
Other than that, it worked like a charm, thank you very much! 👌

@wll8
Copy link
Owner

wll8 commented May 6, 2021

Hahahaha, I'm very sorry, I gave the untested reference code. I am very happy to be able to help you!

@Trinkes Trinkes closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants