以下是有效的吗?
获取image/{id}/{palette}。{file_extension}
我希望能够做这样的事情:
示例:
GET image/1/falsecolor.jpg
GET image/4/alternative.png
GET image/9/falsecolor.tiff
基本上,调色板定义了图像的颜色(调色板),并且扩展名是更适合您的应用程序的文件格式(使用一种文件格式,网络最佳的移动交易,带有另一种文件的网络等),所有我尝试过的OpenAPI Linters做验证它,我在OpenAPI的文档中找不到任何东西,它说这不是一个有效的方法,但是当我将其上传到Postman中时,它却无法识别,加载了调色板和文件扩展名,变量而不是API属性,据说Postman符合OpenAPI/兼容,因此我想知道这实际上是不合格的路径参数。
Is the following valid?
GET image/{id}/{palette}.{file_extension}
I want to be able to do something like this:
example:
GET image/1/falsecolor.jpg
GET image/4/alternative.png
GET image/9/falsecolor.tiff
Basically, the palette defines how is the image is colored (color palette) and the extension is the file format better suited for your application (mobile deals best with one file format, web with another, etc), all OpenAPI linters I tried do validate it, there is nothing that I can find in the documentation for the OpenAPI that says that this is not a valid approach, but when I uploaded this to Postman, it borked beyond recognition, loading the palette and the file extension both as collection variables instead of API properties, and Postman is supposedly OpenAPI compliant/compatible, so I am wondering if this is actually a non-compliant path parameter.
发布评论
评论(2)
是的,部分路径参数在OpenAPI中有效。
但是,他们可以导致模棱两可的解析如果参数值包含分隔符值。例如,给定路径模板
/{palette}。{file_extension}
和请求url/false.color.color.jpg
,服务器应该假设什么值?Palette
=“ false”
file_extension =
“ color.jpg”
palette
=“ false.color”
file_extension
=“ jpg”
一些工具(尤其是/{foo}/{bar} ,但不
/{foo} .json
>或/{foo} - {bar}
)。Yes, partial path parameters are valid in OpenAPI.
However, they can result in ambiguous parsing if the parameter value contains the separator character. For example, given the path template
/{palette}.{file_extension}
and the request URL/false.color.jpg
, what values should the server assume?palette
="false"
file_extension
="color.jpg"
palette
="false.color"
file_extension
="jpg"
Some tools (notably AWS API Gateway) choose not to support partial path parameters and require that path parameters occupy the entire path segment (that is,
/{foo}/{bar}
but not/{foo}.json
or/{foo}-{bar}
).Postman发送了一个证实行为的答案,这是他们实施的当前限制。
他们还说,这是他们将来想改变的事情,目前没有ETA。
我要感谢所有花时间回答这个问题的人,这有助于很多。
Postman has sent an answer confirming the behavior, it is a current limitation in their implementation.
They also said this is something they want to change in the future, just no ETA on that for the moment.
I'd like to thank everyone that put their time to answer this question, it helped alot.