Coder Social home page Coder Social logo

swaggerdoc's Introduction

Swaggerdoc

说明

这是一个简便的django app将swagger ui搬到项目中展示。开发人员只需将swagger文档放到项目指定目录,即可打开相应的URL查看swagger文档,非常适合使用Django开发的项目,在开发过程同时编写文档,并同步更新到项目中,团队其他人员也可以同时看到最新修改的文档。

用法

Django APP为swaggerdoc,像其他APP一样将该目录放到项目目录中。然后准备一些配置:

  1. 在项目setting中的INSTALLED_APPS列表写入'swaggerdoc', 主要便于Django自动查找'swaggerdoc'APP中的static和templates目录下面的文件。该APP没有models文件,如果不想写入INSTALLD_APPS,需要将静态文件目录包含swaggerdoc内的statictemplates目录。
  2. 在项目setting中设置DOC_DIR, 存放swagger文档的目录。也可以不设置,默认为项目目录下的docs文件夹。
  3. 设置STATICFIELS_DIRS,包含第2点的DOC_DIR。如设置为os.path.join(BASE_DIR, 'docs'),使得Django可以找到该目录下的swagger文档。
  4. 设置url patterns, 在项目的urls.py文件设置swagger文档访问路径,包含swaggerdoc.urls即可。如: url(r'^api/doc/', include('swaggerdoc.urls')

这样,启动项目服务器,即可打开浏览器访问{服务其地址}/api/doc就可以看到项目文档了。

效果图如下:

代码是一个完整的django工程,提供可运行的示例, 直接git clone试运行。

swaggerdoc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.