richhollis / swagger-docs

Generates swagger-ui json files for Rails APIs with a simple DSL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Renders same model for two different apis

kartikv11 opened this issue · comments

Swagger gem in rails for RESTful apis renders same model for 2 different apis if same model name is used to describe two different schemas under 2 different APIs in Swagger

I'm using ActiveSupport::Concern. And after that just include this module to another "model" module or to controller.

module Swagger
  module Models
    module Option
      extend ActiveSupport::Concern

      included do
        swagger_model :Option do
          description 'Option data'

          property :id, :integer, :required, 'Option ID'
          property :title, :string, :required, 'Option title'
          property :option_type, :string, :required, 'Type of the option'
          property :popularity, :boolean, :required, ''
        end
      end
    end
  end
end