How to change swagger logo and text in the top bar in django app with drf-yasg?

Viewed 242

I am using drf-yasg.

I managed to override the template by doing the following

in the template folder

{% extends "drf-yasg/swagger-ui.html" %}

{% block extra_scripts %}
<script>
swaggerUiConfig.layout = "BaseLayout";
  // any other override you'd like to do
</script>
<p> Is this text rendering </p>
{% endblock %}

How can I change the top bar logo and text? from "Swagger - supported by SMARTBEAR" to "Smart Calculator"

1 Answers

To customize the swagger UI, you need to override the core template

rest_framework_swagger/index.html

Ref : https://django-rest-swagger.readthedocs.io/en/latest/customization/

https://github.com/marcgibbons/django-rest-swagger/blob/master/rest_framework_swagger/templates/rest_framework_swagger/index.html

index.html template has logo and other code

<a href="#" class="link">
     <!-- change here -->
     <img src="{% static 'rest_framework_swagger/logo_small.png' %}" alt="Swagger Logo">
     <span>MY SWAG</span>
 </a>
Related