Can I add versions to YAML Swagger objects?

ぃ、小莉子 提交于 2019-12-07 15:15:24

问题


I am creating a API definition, and a I wanto to split my canonical model to different documents and use the JSON pointer '$ref' to reuse them. I need to find a way to add version in the YAML files. For instance:

***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
...

回答1:


You can use the extension properties (prefixed with x-) to add arbitrary data to the spec:

# pj.yaml
pJType:
  x-version: 1.0

  type: object
  properties:
    cnpj:
      type: integer


来源:https://stackoverflow.com/questions/46077562/can-i-add-versions-to-yaml-swagger-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!