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/<id>/', html) self.assertNotIn('<id>', html) self.assertIn('<strong>first</strong>', html)
security: - BasicAuth - APIKey ``` {img2('demo_security.png')} {img2('demo_security2.png')} <br><br> 参考: https://www.jianshu.com/p/5365ef83252a """ doc.add_api(api) api = Api(method='POST') api.title = 'Swagger' api.url = '/OpenAPI 是规范/Swagger 是实现规范的工具' api.description = f""" #### 各主流工具 1. `OpenAPI`: 根据规范编写出 `yaml` 或 `json` 文件,然后使用 `Swagger`、`ReDoc` 等渲染出成品文档 <br><br> {img('swagger_logo.png', 200)} <br> 2. `RAML`: 根据规范编写出 `raml` 文件,然后使用 `raml2html` 等渲染出成品文档 <br><br> {img('raml_logo.png', 200)} <br> 3. `API Blueprint`: 根据规范编写出 `markdown` 文件,然后使用 `Aglio`、`snowboard` 等渲染出成品文档 <br><br> {img('apiblueprint_logo.png', 200)} <br> #### Swagger-UI ```html <!DOCTYPE html> <html> <head> <title>Swagger</title> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="//unpkg.com/swagger-ui-dist@3/swagger-ui.css" /> </head>