Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add versions to YAML Swagger objects?

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
...
like image 575
ChelloFera Avatar asked Sep 14 '25 23:09

ChelloFera


1 Answers

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
like image 123
Helen Avatar answered Sep 17 '25 20:09

Helen