swagger-blocks icon indicating copy to clipboard operation
swagger-blocks copied to clipboard

Support overriding keys inline

Open Evilbits opened this issue 4 years ago • 1 comments

In order to clean up my documentation I have used parameter referencing as much as possible. However it seems that there's no easy way of overriding attributes that are set in the parameter when it's defined.

An example is that I create the following id parameter and reference it throughout my documentation - but I would like to be more specific in the description. This however seems to go for all keys and not just description.

# Swagger definition
swagger_root do
  # ...
  parameter :id do
    key :in, :path
    key :name, :id
    key :description, 'ID of resource to fetch.'
    key :required, true
    key :type, :integer
  end
  # ...
end

# In controller
swagger_path '/cats/{id}' do
  operation :get do
    # ...
    parameter :id do
      key :description, 'ID of Cat record to fetch'
    end
  end
end

Is there any way to achieve the desired effect?

Evilbits avatar Apr 23 '20 07:04 Evilbits

Same issue here

  # I want to reference this schema in Country, but the id in Country schema is not shown
  swagger_schema :CountryBase do
      property :type do
        key :type, :string
      end
      property :attributes do
        property :code do
          key :type, :string
        end
        property :name do
          key :type, :string
        end
        property :phone do
          key :type, :string
        end
        property :deleted do
          key :type, :boolean
        end
      end
    end

  # Country does not show id
    swagger_schema :Country do
      property :id do
        key :type, :integer
        key :format, :int64
      end
      key :'$ref', :CountryBase
    end

ptarud avatar Jun 05 '20 20:06 ptarud