簡體   English   中英

如何使用 drf-yasg 更改 django 應用程序頂部欄中的 swagger 徽標和文本?

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

我正在使用 drf-yasg。

我設法通過執行以下操作來覆蓋模板

在模板文件夾中

{% 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 %}

如何更改頂部欄徽標和文本? 從“Swagger - 由 SMARTBEAR 支持”到“智能計算器”

自定義swagger UI,需要重寫核心模板

rest_framework_swagger/index.html

參考: 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模板有logo等代碼

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM