如何从openapi中的另一个路径引用某个路径中的已定义操作

时间:2020-10-22 21:59:35

标签: openapi

我正在定义此结构:

openapi.yaml

paths:
  /my-path/my-resource:
    $ref: './api/my-resource.yaml#/my-operations'
  /another-path/another-resource: 
    $ref: './api/my-resource.yaml#/my-operations/get'

my-resource.yaml

my-operations:
    get:
      tags:
        - my-api
      operationId: getMyResource
      responses:
         ...
         [omitted]
         ...
    post:  
      tags:
        - my-api
      operationId: postMyResource
      responses:
         ...
         [omitted]
         ...

现在,我想引用“ / my-path / my-resource”中之前定义的“ / another-path / another-resource” get的操作。会是这样的:

  /another-path/another-resource: 
    $ref: '#/paths/my-path~1my-resource/get'

  /another-path/another-resource:
    $ref: '#/paths/my-path~1my-resource#/get'

  /another-path/another-resource:
    $ref: './api/my-resource.yaml#/my-operations/get'

  /another-path/another-resource:
    $ref: './api/my-resource.yaml#/my-operations#/get'

但是我这样做是因为什么都不起作用,我该怎么办?

非常感谢您。

0 个答案:

没有答案