Swagger error: additionalProperty: 3XX, 4XX, 5XX

Swagger error: additionalProperty: 3XX, 4XX, 5XX

我在 swagger 响应部分添加了一些错误代码: 201、3XX、400、401、4XX、5XX。

此外,根据 swagger2.0 文档,您可以: "The following range definitions are allowed: 1XX, 2XX, 3XX, 4XX, and 5XX. If a response range is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code."

但我仍然得到错误: "should NOT have additional properties. additionalProperty: 3XX, 4XX, 5XX"

有线索吗?

该引用来自 OpenAPI 3.0 规范,而非 2.0。

2.0 spec 不支持通配符响应代码。需要使用特定的编码,如200400404等,可以使用default响应匹配所有未涵盖的HTTP编码根据您的规格单独选择。