在API蓝图中记录互斥查询参数(Documenting Mutually Exclusive Query Parameters in API Blueprint)

编程入门 行业动态 更新时间:2024-10-25 14:22:45
在API蓝图中记录互斥查询参数(Documenting Mutually Exclusive Query Parameters in API Blueprint)

我正在记录一个公共API,它有一个名为/findGuild的方法,它接受一个必需的key参数和一个以下参数:

byPlayer byName

必须有byPlayer或byName ; 我的问题是: 我如何表明byPlayer和byName是互斥的,但一个是强制性的?


现在,我的.apib有以下资源:

### GET /findGuild{?byName,byPlayer,key} + Parameters + byName: `YourGuild` (string, optional) - Search for the Guild by its name. + byPlayer: (string, optional) - Search for Guild by a player. Does not seem to work. + key: `ffffffff-ffff-ffff-ffff-ffffffffffff` (string, required) - The user's API key. + Response 200 (application/json) + Attributes (object) + guild (string) - The guild id or null. + success (boolean) - Should be true. + Body { "guild": "ffffffffffffffffffffffff", "success": true }

I'm documenting a public API that has a method named /findGuild that takes a mandatory key parameter and one of the following parameters:

byPlayer byName

It must have either byPlayer or byName; My question is: How do I indicate that byPlayer and byName are mutually exclusive, but one is mandatory?


Right now, I have the following in my .apib for this Resource:

### GET /findGuild{?byName,byPlayer,key} + Parameters + byName: `YourGuild` (string, optional) - Search for the Guild by its name. + byPlayer: (string, optional) - Search for Guild by a player. Does not seem to work. + key: `ffffffff-ffff-ffff-ffff-ffffffffffff` (string, required) - The user's API key. + Response 200 (application/json) + Attributes (object) + guild (string) - The guild id or null. + success (boolean) - Should be true. + Body { "guild": "ffffffffffffffffffffffff", "success": true }

最满意答案

我担心(但不完全确定)API Blueprint目前无法表达这种关系。

我可以肯定地说,根据公共路线图 ,URI参数将被替换为MSON对象 ,它支持您要求的场景 。

希望能帮助到你!

I am afraid (but not totally sure) API Blueprint is not capable of expressing this kind of relationship at the moment.

What I can surely tell you is that, according to public roadmap, URI Parameters will be replaced with an MSON object, which supports the scenario you're asking for.

Hope it helps!

更多推荐

本文发布于:2023-04-27 23:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329205.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图中   参数   互斥   Documenting   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!