标签: apiblueprint

API蓝图中的响应描述和POST参数

我正在尝试API Blueprint并发现了一些我不太清楚的事情.

1.如何记录POST体参数?

+ Parameters,但它只是文件的查询参数.如果我现在要描述POST API,我无法记录POST参数(application/x-www-form-urlencoded).JSON也是如此(参见#3).

2.有没有办法在响应中添加描述?

我试过了

+ Response 403
If the request request is made with HTTP instead of HTTPS.
Run Code Online (Sandbox Code Playgroud)

但这只是将文本添加为​​身体反应.

3.描述我的回答的不同领域

如果我返回JSON,我想分别描述每个字段,它的类型和目的.有没有办法做到这一点?

谢谢!

apiblueprint

9
推荐指数
1
解决办法
7013
查看次数

为一对多关系公开RESTful端点

考虑两个资源之间的以下关系

  • 学院有很多院系
  • 学院属于学院

显然,一个学院不是一流的资源.

现在我需要端点来执行以下操作.

  • 在这所大学这个农场建立一个新的教师队伍.在两个操作中执行此操作的一种可能方法.
    • POST /faculties/
    • PUT /college/1/faculties
  • 从这所大学中删除一名教员.再两次操作
    • GET /college/1/faculties:相关院系列表.每个都会包含一个自我网址/faculties/1.
    • DELETE /college/1/faculties/1:网址看起来更好,但如何公开这个网址?
  • 在该学院下添加一个或多个院系.
    • PUT /college/1/faculties 接受这所大学院系的完整列表.
  • 完全删除该特定部门.
    • DELETE /sectors/1:看起来不错,但需要照顾缓存/faculties/1/sectors.

在这种情况下,什么是更好的方法?我已经阅读了关于公开会员资源的内容,但是通过这种方法,如果一所大学有10个院系,则需要10个单独的http电话才能从会员资格中获取所有这些资源.

而且,这只是完整关系树的一小部分.为了进一步扩展,系统说

  • 学院有很多部门
  • 部门有很多实验室等等.

此外,在RESTful架构中,客户端永远不应该填充URL.

有什么建议吗?

rest restful-architecture apiblueprint

9
推荐指数
1
解决办法
7998
查看次数

如何在Apiary.io中显示嵌套属性定义

我的数据结构定义如下:

# Data Structures

## PlayerRank (object)
Represents the minimum amount of data the the client needs to send to give rank information about a particular Player in a particular Played Game.
+ playerId (number, required) - NemeStats unique identifier for the Player.
+ gameRank (number, required) - The corresponding rank of the Player in this Played Game. A rank of 1 means the Player got first place, 2 means second place, and so on.
+ pointsScored (number, optional) - …
Run Code Online (Sandbox Code Playgroud)

apiary.io apiblueprint apiary

9
推荐指数
1
解决办法
2292
查看次数

表示输入参数是Apiary中的日期/时间的正确格式是什么?

我正在编辑我正在处理的项目的一些Apiary文档,并且需要表示我的一个API调用的参数是一个日期时间字符串.蜂房似乎在扼杀这个参数的格式,所以我想知道在Apiary中记录这个参数的建议方法是什么.

为了演示,我从Apiary获取了标准的默认文档并修改了Choice文档以获取类似的datetime对象:

## Choice [/questions/{question_id}/choices/{choice_id}/{datetime}]

+ Parameters
    + question_id: 1 (required, number) - ID of the Question in form of an integer
    + choice_id: 1 (required, number) - ID of the Choice in form of an integer
    + datetime: 2015-05-05T12:30:00 (optional, date) - The date/time (ISO8601 format) associated with this choice
Run Code Online (Sandbox Code Playgroud)

最终结果如下:

datetime
05-05T12:30:00 (optional, date) - The date/time (ISO8601 format) that all returned events should be greater than or equal to Example: 2015.
Run Code Online (Sandbox Code Playgroud)

这显然是错误的,甚至写下示例值.破折号(-)是一个特殊的角色,在这里引起悲伤.这样做的推荐方法是什么?

apiary.io apiblueprint apiary

9
推荐指数
1
解决办法
3524
查看次数

如何在apiary.io上格式化POST请求?

感谢您的时间我有一个POST请求,我想在蓝图养蜂场中记录,标题是这样的:

text/html的

_method:POST

数据[用户] [用户名]:

数据[用户] [口令]:

数据[用户] [记住]:0

http://d.pr/i/uRFx

我有类似的东西,但我不知道如何完成它:

## login [/users/login/{username}{password}{remember}{ident}]
Login with a user and password

+ Parameters

    + username (required, string, `myname`) ... the username format should follow CakePHP: data[User][username].
    + password (required, string, `whatever`) ... the password format should follow CakePHP: data[User][password]
    + remember (required, number, `0`) ... the remember format should follow CakePHP: data[User][remember]
    + ident (optional, number, `0`) ... the ident format should follow CakePHP: data[User][ident]

### make login [POST]

+ login …
Run Code Online (Sandbox Code Playgroud)

apiary.io apiblueprint

8
推荐指数
1
解决办法
1万
查看次数

我可以提供多个示例回复吗?

我正在编写API的规范,其中响应中包含的字段各不相同.我希望能够提供多个示例来展示这一点.我的用例是:

  1. 其中一个API调用具有一个include参数,允许用户指定要包含在响应中的一些其他字段
  2. 对于某些API调用,响应中包含的字段取决于与用户API密钥关联的权限

我希望能做的是这样的:

+ Response 200 (application/json)

    {
      "id": 1, 
      "name": "Joe Bloggs",
      "email": "joe@example.com"
    }

+ Response 200 (application/json)

  If `include=telephone` was specified:

    {
      "id": 1, 
      "name": "Joe Bloggs",
      "email": "joe@example.com",
      "telephone": "0123456789"
    }

+ Response 200 (application/json)

  If the API key has access to address data:

    {
      "id": 1, 
      "name": "Joe Bloggs",
      "email": "joe@example.com",
      "address": [{
          "address1": "101 My street",
          "address2": "My area"
      }]
    }
Run Code Online (Sandbox Code Playgroud)

据我所知,尽管您可以提供多个响应,但只有在响应代码或内容类型不同时才能这样做.有没有办法做到这一点?

apiblueprint

8
推荐指数
1
解决办法
2364
查看次数

如何为json请求对象指定可选元素

在API蓝图中,我希望为POST消息指定一个可选的json元素.例子;

    ### Add a new User [POST]
    To add a User send a JSON .....

    + Request (application/json)

    {
         "name": "A name",
         "age": 30
    }
Run Code Online (Sandbox Code Playgroud)

如何向API的读者表明API调用中的年龄是可选的,但仍然显示它是一个整数?

〜科林

json apiblueprint

7
推荐指数
1
解决办法
4194
查看次数

API Blueprint vs Swagger的独特目的是什么?

我正在尝试以云原生方式开发应用程序.我正在尝试API应用程序的第一个设计.

我应该使用哪种API文档工具?哪一个更适合API第一合同?而哪一个适合哪里?

rest swagger apiblueprint

7
推荐指数
1
解决办法
5822
查看次数

在API Blueprint/MSON中使用模式

我正在研究API Blueprint中新数据结构语法的可能性,尤其是MSON.是否可以附加或更确切地指定类似图案(正则表达式)的东西?没有找到关于这个主题的任何内容.

apiary.io apiblueprint apiary aglio mson

6
推荐指数
1
解决办法
617
查看次数

在Apiary.io上的API Blueprint中使用通用命名类型

如何在API Blueprint定义中使用通用命名类型

我试着这样:

FORMAT: 1A HOST: http://test.com/

# API Blueprint testing.

## Resource [/resources]
### Action [GET]

+ Response 200 (application/json)

    + Attributes
        + decorated_person (Address Decorator(Person))


# Data Structures

## Person (object)
+ first_name
+ last_name

## Address Decorator (*T*)
+ address
Run Code Online (Sandbox Code Playgroud)

但是Apiary Editor给我的错误:

基本类型'Address Decorator(Person)'未在文档中定义

apiary.io apiblueprint

6
推荐指数
1
解决办法
500
查看次数