开发者

Documenting POST parameters with WADL

Looking at the current version of the WADL proposal, I couldn't quite figure out how to document POST request parameters (with application/x-www-form-urlencoded encoding).

I've seen something like this in the wild:

<resource path="/path1">
<!-- default is mediaType="application/x-www-form-urlencoded" -->
    <method name="POST">
        <request>
            <name="param1" style="query"/>
        </request>
    </method>
</resource>

However, for a <param style="query"> used as a child of <request>, the spec describes it as:

Specifies a URI query parameter represented according to the rules for the query component media type specified by the queryType attribute.

The "URI 开发者_运维知识库query" bit threw me off since, to me, it suggests parameters being appended to the URI instead of being included in the body.

On the other hand, for a <param style="query"> used as a child of <representation>, the spec has:

Specifies a component of the representation as a name value pair formatted according to the rules of the media type. Typically used with media type 'application/x-www-form-urlencoded' or 'multipart/form-data'.

Do I have to use a <representation> element to explicitly document parameters that will be send in encoding as part of a POST body?

<resource path="/path1">
    <method name="POST">
        <request>
            <representation mediaType="application/x-www-form-urlencoded">
                <name="param1" style="query"/>
            </representation>
        </request>
    </method>
</resource>

This looks like an overkill. I'm assuming I should be able to use the former, even though the spec makes mention of "URI query".


Now I see that I actually should be using the latter form. Even if it looks like an overkill for simply documenting some POST parameters, it's better to explicitly document the fact that the parameters are part of the body == representation.

3rd party edit

The latter one does probably mean this one

<resource path="/path1">
    <method name="POST">
        <request>
            <representation mediaType="application/x-www-form-urlencoded">
                <name="param1" style="query"/>
            </representation>
        </request>
    </method>
</resource>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜