我可以向 YAML Swagger 对象添加版本吗?

2024-04-09

我正在创建一个 API 定义,并且我想将规范模型拆分为不同的文档并使用 JSON 指针“$ref”来重用它们。 我需要找到一种在 YAML 文件中添加版本的方法。 例如:

***pj.yaml***
 pJType:
  verison: 1.0
  type: object
  properties:
    cnpj:
      type: integer

***afastamento.yaml***
oswagger: '2.0'
info:
  version: '1.0'
  title: AfastamentoService
consumes:
  - application/json
produces:
  - application/json
paths:
  '/{nis}':
    get:
      parameters:
        - in: path
          name: nis
          type: integer
          required: true

      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/pesquisarResponse'
definitions:
  pesquisarResponse:
    type: object
    properties:
      listaAfastamento:
        $ref: '#/definitions/listaAfastamentoType'
  ...
  empregadorType:
    type: object
    properties:
      personalidadeJuridica:
        type: string
      pessoaJuridica:
        $ref: pJ.yaml#/pessoaJuridicaType
...

您可以使用扩展属性(前缀为x-) 将任意数据添加到规范中:

# pj.yaml
pJType:
  x-version: 1.0

  type: object
  properties:
    cnpj:
      type: integer
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我可以向 YAML Swagger 对象添加版本吗? 的相关文章

随机推荐