在 openapi v3 中创建通用路径和特定路径

Create a generic path along with a specific one in openapi v3

我正在为 node.js 服务器使用 express-openapi npm 模块。为此,我需要使用 openapi v3 创建一个通用的 url 像这样的 /ressources/{action} 它将包括所有类型的操作,除了一些我具体描述为 /ressources/action1 和 /ressources/action2 这里我是如何描述 url 路径中的通用参数的:

    action:
      name: action
      in: path
      required: true
      schema:
        type: string
        not:
          enum: ['action1', 'action2']

具体的url不带路径参数,另行说明。

问题是每当我启动服务器并调用 /ressources/action1 时,它都会调用通用 url。我认为通用操作路径参数枚举存在问题。在这种情况下,有人可以帮助弄清楚如何将我的请求与适当的 url 正确匹配吗?

我还尝试枚举所有通用的可能操作,如下所示:

    action:
      name: action
      in: path
      required: true
      schema:
        type: string
        enum: ['action3', 'action4', 'action5', 'action6']

但 action1 和 action2 始终匹配通用 url

两个定义都是正确的,并且根据OpenAPI Specification:

When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.

...

Path Templating Matching

Assuming the following paths, the concrete definition, /pets/mine, will be matched first if used:

/pets/{petId}
/pets/mine

服务器总是选择通用 URL 这一事实是一个错误(或未实现的功能?)。无论您使用的是什么服务器框架,您都应该提出问题。