RAML相同的方法重载文档

时间:2016-03-21 21:59:26

标签: rest raml

我的rest API中有2个PUT方法,具有相同的入口点。

方法#1:PUT / videos / {videoId},其类型为multipart / form-data,将取代视频。

方法#2:PUT / videos / {videoId}?title = newTitle& description = newDescription将更新视频的标题和说明。

当我尝试将其记录如下时,我得到“已经声明的方法:'put'”

put:
  description: replace a video with a new video
  body:
    multipart/form-data:
      formParameters:
          file: 
            description: a video file to replace the current video file
            required: true
            type: file
  responses:
    200:
        body:
          application/json:
            schema: !include video.schema
            example: !include video.example
        description: Returns the video object.
put:
  description: update video's fields
  queryParameters:
    title:
      description: video's title
      required: false
      type: string
    description:
      description: video's description
      required: false
      type: string
  responses:
    200:
      body:
        application/json:
          schema: !include video.schema
          example: !include video.example

您对如何记录此案件有任何建议吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

在执行PUT请求时,发送数据以更改查询参数不是一个好习惯。而不是我改变你的第二个PUT为PATCH与Content-Type:application / json作为正文的类型,并作为该有效负载的内容我发送

{ title: "newTitle", description: "newDescription" }

有了这个,您的API将实现您想要的所有内容(就我从您的问题中得到的结果)。

请注意,我在PATCH中为PATCH更改了这个原因并不是强制要求您使用数据发送孔json。如果您的API实现支持,您可能稍后只发送一个PATCH来更改描述。在PUT请求中,您应该发送孔json。

相关问题