swagger - 这个 OpenAPI/Swagger 规范是什么意思?

标签 swagger openapi swagger-2.0

有问题的规范:

openapi: '3.0.2'
info:
  title: Video Storage Server API
  version: '1.0'
servers:
  - url: http://localhost:8080
paths:
  /files/{fileid}:
    get:
      description: Download a video file by fileid. 
      parameters:
        - in: path
          name: fileid
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          headers:
            Content-Disposition:
              schema:
                type: string
          content:
            video/mp4:  # foo.mp4
              schema: 
                type: string
                format: binary
            video/mpeg: # bar.mpg 
              schema:
                type: string
                format: binary

我知道我需要让我的服务器响应带有 fileidget 请求。 服务器存储视频。

来自服务器的响应,应该是用户可以在浏览器/Postman 中播放的视频还是应该是视频的字节数组?

即响应应该是:

Possible result 1

Possible result 2

此外,content#video/mp4/content#video/mpeg 是什么意思?我是否需要在我的回复中将 content-type 设置为这两个之一?

我的 Content-Disposition 应该是什么?

最佳答案

答案是第一个示例中的视频,或者更准确地说是对应于请求的内容类型的字节流,video/mp4video/mpeg ,带有 Content-Disposition header 。

如果响应是像第二个示例中那样的 JSON block ,则响应内容类型将是 application/json(或等效的),并且它将显式列出响应对象模式,即将是响应中的 filenamefileType 等。

关于swagger - 这个 OpenAPI/Swagger 规范是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72902293/

相关文章:

java - 使用 Swagger 注释时响应中缺少 JSON 父/根元素

swagger-ui - 如何在 OpenAPI 3 中引用数组项示例?

Vim 错误格式和 Spectrum lint

java - 从 "allowableValues"中的数据库传递值?

node.js - 如何在 nodejs 中的 Swagger UI(swagger.json)中的 header 中表示自定义 token

java - 无法使用 Spring Boot 和 Jersey 2 提供静态内容

spring-boot - 带有不记名 token 的 Spring Boot swagger ui

asp.net - Web api 中的 Swagger 500 错误

openapi - 服务器属性在 OpenAPI 3.0 中有什么意义?

swagger-2.0 - 使用 swagger 2.0 记录 REST API 时如何保持实现和文档同步?