我想问一下RAML中是否支持POST参数.如果有 - 什么是语法.我粗略地浏览了规范0.8和规格1.0(实际上我很受欢迎0.8
,因为很多工具还不支持1.0
).我没有找到POST参数支持,但也许我只是错过了一些东西.
那么POST参数是什么意思?这些可以是两者之一(对不起,我不知道他们的正式名称,如果有的话):
HTTP普通参数,key=value
每个参数在一行中,如
name=John Doe
amount=5
这不是很方便(例如没有嵌套)
参数作为JSON对象,只是一个允许其所有语法的JSON(服务器端需要解析这个json); 如:
{"name":"John Doe","amount":"5"}
不同的服务器端API实现使用第一个或第二个.无论如何,RAML如何支持这些?
正如本参考中所示https://github.com/raml-org/raml-spec/wiki/Breaking-Changes:
对于raml 0.8:
body:
application/x-www-form-urlencoded:
formParameters:
name:
description: name on account
type: string
example: Naruto Uzumaki
gender:
enum: ["male", "female"]
Run Code Online (Sandbox Code Playgroud)
raml 1.0中的等价物是:
body:
application/x-www-form-urlencoded:
properties:
name:
description: name on account
type: string
example: Naruto Uzumaki
gender:
enum: ["male", "female"]
Run Code Online (Sandbox Code Playgroud)
所以它改变的是属性的formParameters属性.
@Pedro已经涵盖了选项2,所以这里是选项1.根据评论中的讨论,似乎使用的编码是
application/x-www-form-urlencoded
.
你需要使用formParameters
.
例:
post:
description: The POST operation adds an object to a specified bucket using HTML forms.
body:
application/x-www-form-urlencoded:
formParameters:
AWSAccessKeyId:
description: The AWS Access Key ID of the owner of the bucket who grants an Anonymous user access for a request that satisfies the set of constraints in the Policy.
type: string
acl:
description: Specifies an Amazon S3 access control list. If an invalid access control list is specified, an error is generated.
type: string
Run Code Online (Sandbox Code Playgroud)
参考:https://github.com/raml-org/raml-spec/blob/master/raml-0.8.md#web-forms
归档时间: |
|
查看次数: |
3029 次 |
最近记录: |