lib/apipie/swagger_generator.rb
#--------------------------------------------------------------------------
# Create swagger definitions for a ruby method
#--------------------------------------------------------------------------
Create swagger definitions for a ruby method
Create swagger definitions for a ruby method
def add_ruby_method(paths, ruby_method)
      if @only_method
        return unless ruby_method.method == @only_method
      else
        return if !ruby_method.show
      end
      for api in ruby_method.apis do
        path = swagger_path(api.path)
        paths[path] ||= {}
        methods = paths[path]
        @current_method = ruby_method
        @warnings_issued = false
        responses = swagger_responses_hash_for_method(ruby_method)
        if include_warning_tags?
          warning_tags = @warnings_issued ? ['warnings issued'] : []
        else
          warning_tags = []
        end
        op_id = swagger_op_id_for_path(api.http_method, api.path)
        include_op_id_in_computed_interface_id(op_id)
        method_key = api.http_method.downcase
        @current_http_method = method_key
        methods[method_key] = {
            tags: [tag_name_for_resource(ruby_method.resource)] + warning_tags + ruby_method.tag_list.tags,
            consumes: params_in_body? ? ['application/json'] : ['application/x-www-form-urlencoded', 'multipart/form-data'],
            operationId: op_id,
            summary: Apipie.app.translate(api.short_description, @current_lang),
            parameters: swagger_params_array_for_method(ruby_method, api.path),
            responses: responses,
            description: ruby_method.full_description
        }
        if methods[method_key][:summary].nil?
          methods[method_key].delete(:summary)
          warn_missing_method_summary
        end
      end
    end
def add_ruby_method ( paths , ruby_method ) if @only_method return unless ruby_method . method == @only_method else return if ! ruby_method . show end for api in ruby_method . apis do path = swagger_path ( api . path ) paths [ path ] ||= { } methods = paths [ path ] @current_method = ruby_method @warnings_issued = false responses = swagger_responses_hash_for_method ( ruby_method ) if include_warning_tags? warning_tags = @warnings_issued ? [ 'warnings issued' ] : [ ] else warning_tags = [ ] end op_id = swagger_op_id_for_path ( api . http_method , api . path ) include_op_id_in_computed_interface_id ( op_id ) method_key = api . http_method . downcase @current_http_method = method_key methods [ method_key ] = { tags : [ tag_name_for_resource ( ruby_method . resource ) ] + warning_tags + ruby_method . tag_list . tags , consumes : params_in_body? ? [ 'application/json' ] : [ 'application/x-www-form-urlencoded' , 'multipart/form-data' ] , operationId : op_id , summary : Apipie . app . translate ( api . short_description , @current_lang ) , parameters : swagger_params_array_for_method ( ruby_method , api . path ) , responses : responses , description : ruby_method . full_description } if methods [ method_key ] [ :summary ] . nil? methods [ method_key ] . delete ( :summary ) warn_missing_method_summary end end end
Create swagger definitions for a ruby method
Create swagger definitions for a ruby method
# controller: ruby_method.resource.controller.name,
paths
<not_specific>
ruby_method
<not_specific>