Ejemplo n.º 1
0
 def test_api(self):
     doc = Doc()
     api = Api()
     api.title = "first api"
     api.method = "GET"
     api.url = "/test1/<id>/"
     api.description = "this is the **first** api"
     doc.add_api(api)
     html = doc.build()
     self.assertIn('first api', html)
     self.assertIn('<div class="endpoint get">', html)
     self.assertIn('/test1/&lt;id&gt;/', html)
     self.assertNotIn('<id>', html)
     self.assertIn('<strong>first</strong>', html)
Ejemplo n.º 2
0
3. 方便维护
<br><br><br>
"""
doc.add_note(note)

note = Note(title='小结一下')
note.content = f"""
##### 编写文档对于每一个普通的开发人员来说,可能算是一种 “负担”
##### 但是在**前后端分离**大势所趋的今天
##### 能够编写一份**可读性高**、**方便传阅交流**的接口文档已成为每一位**后端开发者**的必备技能
##### 如果能有个工具来**自动**干这件事那就更棒了!
"""
doc.add_note(note)

api = Api(method='GET')
api.title = 'OpenAPI'
api.url = '/从 swagger2 /到 openapi3'
api.response_description = f"""
{img('2to3.png', 800)}
参考: https://stuff.rdme.io/swagger2to3

#### OpenAPI3 规范简要解读
```
# OpenAPI 规范版本号
openapi: 3.0.3

# API 元数据信息
info:

# 服务器连接信息
servers: