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

drf spectcular-side car doesnot work in custom html #1208

Open
meenumathew opened this issue Mar 21, 2024 · 1 comment
Open

drf spectcular-side car doesnot work in custom html #1208

meenumathew opened this issue Mar 21, 2024 · 1 comment

Comments

@meenumathew
Copy link

I've recently integrated drfspectcular-sidecar into my Django project to manage internal documentation, utilizing cloud services like S3 bucket for hosting. After completing the integration, I added drf-spectcular-sidecar to the installed apps section of my Django settings and ran the collectstatic command. This process generated a swagger-ui-dist folder containing several necessary files:

favicon-32x32.png
oauth2-redirect.html
swagger-ui-bundle.js
swagger-ui-bundle.js.LICENSE.txt
swagger-ui-bundle.js.map
swagger-ui-standalone-preset.js
swagger-ui-standalone-preset.js.map
swagger-ui.css
swagger-ui.css.map
However, upon attempting to display Swagger UI documentation using a custom HTML file hosted on an S3 bucket, nothing appears. Here's the code snippet I've utilized:

<title>Swagger UI Documentation</title>
<!-- Swagger UI Container -->
<div id="swagger-ui"></div>

<!-- Include Swagger UI JavaScript -->
<script src="swagger-ui-dist/swagger-ui-bundle.js"></script>
<script src="swagger-ui-dist/swagger-ui-standalone-preset.js"></script>
I would appreciate any guidance or insights on resolving this issue and ensuring proper integration of Swagger UI with Django REST Framework Spectacular in this context. Additionally, if there are any suggestions for automating the endpoint documentation update process in standalone central location like s3 bucket, they would be highly valuable. Thank you for your assistance.
@tfranzel
Copy link
Owner

Hi,

this is the proper way to use sidecar: https://github.com/tfranzel/drf-spectacular?tab=readme-ov-file#self-contained-ui-installation

So you are writing your own html (which is not necessary to use sidecar), do some unspecified modification, and then open an issue because it is not working? Why are you doing this? Maybe you modifications are faulty? No way to tell since you have not shown what is actually not working.

We use django's static() method to resolve asset locations. If your django is setup correctly, this all should work out of the box and point to s3, if you have something like django-storagesS3Boto3Storage.

html for ref: tfranzel/drf-spectacular-sidecar#9

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