嵌套的$ ref似乎在开放API Yaml中不起作用

时间:2019-04-15 12:10:15

标签: openapi-generator

如何解决以下远程引用的情况。基本上,我试图将API规范拆分为多个文件。 使用openapi-generator-cli-3.3.0.jar

以下所有4个yaml文件都位于同一目录中。

Main.yaml

openapi:3.0.0
info:
 ---
 ---
servers:
 ---
paths:
 /User
   /get
     tags:
       - User
     summary: some summary 
     responses:
      '200':
        description: some desc
        content:
          application/json
             schema:
               $ref: './schemas.yaml#/components/schemas/UserModel'

schemas.YAML file

        components:
          schemas:
            ErrorModel:
              type: object
              properties:
                errorCategory:
                  type: string
                  example: "xxxxx"

            ErrorModelList:
              type: object
              properties:
                errorModelList:
                  type: array
                  items:
                    $ref: '#components/schemas/ErrorModel'

 responses.YAML file

        responses:
           $ref: './500.yaml'

500.YAML file

        description: some desc
        content:
          application/json
             schema:
               $ref: './schemas.yaml#/components/schemas/ErrorModelList' 

如果我在500.yaml中使用type: string删除'$ ref'标签,则它可以正常工作。但这不是我想要的

ERROR: - Could not find components/scheas/ErrorListModel in contents ./500.yaml

0 个答案:

没有答案