Sha256: 1c539acc5232a3b06bd3aab64983cb84f84926a03fd146e5c28b1497d112f54f

Contents?: true

Size: 701 Bytes

Versions: 15

Compression:

Stored size: 701 Bytes

Contents

# frozen_string_literal: true

# :reek:InstanceVariableAssumption
# :reek:NilCheck

module SwaggerDocsGenerator
  module Actions
    # Write parameter type :body
    class Body < Parameter
      def to_hash
        {
          in:               :body,
          name:             @name.nil? ? 'body' : @name,
          description:      @description.nil? ? '' : @description,
          required:         @required.nil? ? true : @required,
          schema: { '$ref': @schema.nil? ? '' : format_name }
        }
      end

      private

      def schema(text)
        @schema = text
      end

      def format_name
        "#/definitions/#{@schema.tr(' ', '_').camelize}"
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
swagger_docs_generator-0.5.1 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.5.0.pre.42 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.4.0 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.6 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.6.pre.34 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.5 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.5.pre.31 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.4.pre.26 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.4 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.4.pre.23 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.3 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.2 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.1 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.0.pre.19 lib/swagger_docs_generator/parser/actions/parameters/body.rb
swagger_docs_generator-0.3.0.pre.18 lib/swagger_docs_generator/parser/actions/parameters/body.rb