有问题的规范:
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
我知道我需要让我的服务器用fileid
来响应fileid
请求。服务器存储视频。
来自服务器的响应,应该是用户可以在browser/Postman中播放的视频,还是应该是视频的字节数组?
即应作出以下答复:
或
另外,content#video/mp4
/ content#video/mpeg
是什么意思?我是否需要在我的响应中将content-type
设置为这2项中的一项?
我的Content-Disposition
应该是什么?
发布于 2022-07-15 04:39:38
答案是第一个例子中的视频,或者更准确地说,是一个字节流,它对应于请求的内容类型video/mp4
或video/mpeg
,其中包含一个Content-Disposition
头。
如果响应是JSON块,如第二个示例所示,响应内容类型将是application/json
(或等效的),并且它将显式列出响应对象模式,即响应中将有一个filename
、fileType
等。
发布于 2022-07-15 07:29:25
OpenAPI规范说:
关于内容配置头,请参见获得更多的文档。
https://stackoverflow.com/questions/72902293
复制相似问题