定义api,生成一个夸张的规范,并验证输入
pyramid_swagger_spec的Python项目详细描述
棱锥体swagger说明符
==
版本号:0.0.8
作者:marcel sander
概述
--
定义api,生成swagger规范,并验证输入
在你的配置中加入
`````python
config.include('cr金字塔招招摇过摆的说法’)
````
/>br/>
设置观点。它们在/{namespace}/{swagger和/{namespace}/{swagger.html将swagger规范返回为json。
`` python
从pyramd swagger中返回。swagger import创建swagger视图
创建swagger视图(config,namespace=“api”,title=“server api”,version=“0.1”)
```
要指定api调用:
```python
import pyramid\u swagger\u spec.swagger as sw
;如果使用遍历,则遍历层次结构必须与子路径匹配(即/api/echo必须返回一个echoressource实例)
不要从myproject传递上下文和名称属性
。ressources从myproject导入echoresource
。routes导入api-route
@api-route(path=/echo/{x}),request-method=”get”,name=”test”,context=echoresource,renderer='json',api=sw.api(
tag=”default”,
operation=“echo-test”,
summary=”echos输入“,
参数=[
sw.path_参数(“x”,sw.types.number),
sw.query_参数(“o”,sw.types.number)
],
响应={
200:sw.response(schema={
“status”:sw.property(sw.types.string)
}
返回{
'x':request.validated_params.path[“x”],
'o':request.validated_params.query[“o”],
'status':“ok”
}
`````
contribution
----
例如测试、输出验证等
==
版本号:0.0.8
作者:marcel sander
概述
--
定义api,生成swagger规范,并验证输入
在你的配置中加入
`````python
config.include('cr金字塔招招摇过摆的说法’)
````
/>br/>
设置观点。它们在/{namespace}/{swagger和/{namespace}/{swagger.html将swagger规范返回为json。
`` python
从pyramd swagger中返回。swagger import创建swagger视图
创建swagger视图(config,namespace=“api”,title=“server api”,version=“0.1”)
```
要指定api调用:
```python
import pyramid\u swagger\u spec.swagger as sw
;如果使用遍历,则遍历层次结构必须与子路径匹配(即/api/echo必须返回一个echoressource实例)
不要从myproject传递上下文和名称属性
。ressources从myproject导入echoresource
。routes导入api-route
@api-route(path=/echo/{x}),request-method=”get”,name=”test”,context=echoresource,renderer='json',api=sw.api(
tag=”default”,
operation=“echo-test”,
summary=”echos输入“,
参数=[
sw.path_参数(“x”,sw.types.number),
sw.query_参数(“o”,sw.types.number)
],
响应={
200:sw.response(schema={
“status”:sw.property(sw.types.string)
}
返回{
'x':request.validated_params.path[“x”],
'o':request.validated_params.query[“o”],
'status':“ok”
}
`````
contribution
----
例如测试、输出验证等