lib/open_api/config.rb in zero-rails_openapi-1.3.0 vs lib/open_api/config.rb in zero-rails_openapi-1.3.1

- old
+ new

@@ -1,7 +1,11 @@ +require 'open_api/config_dsl' + module OpenApi module Config + include ConfigDSL + # [REQUIRED] The location where .json doc file will be output. cattr_accessor :file_output_path do 'public/open_api' end @@ -47,48 +51,52 @@ end cattr_accessor :jbuilder_templates do { index: ( - <<-FILE -json.partial! 'api/base', total: @data.count - -json.data do - # @data = @data.page(@_page).per(@_rows) if @_page || @_rows - # json.array! @data do |datum| - json.array! @data.page(@_page).per(@_rows) do |datum| - json.(datum, *datum.show_attrs) if datum.present? - end -end + <<~FILE + # *** Generated by ZRO *** + json.partial! 'api/base', total: @data.size + + json.data do + # @data = @data.page(@_page).per(@_rows) if @_page || @_rows + # json.array! @data do |datum| + json.array! @data.page(@_page).per(@_rows) do |datum| + json.(datum, *datum.show_attrs) if datum.present? + end + end FILE ), show: ( - <<-FILE -json.partial! 'api/base', total: 1 - -json.data do - json.array! [ @data ] do |datum| - json.(datum, *datum.show_attrs) if datum.present? - end -end + <<~FILE + # *** Generated by ZRO *** + json.partial! 'api/base', total: 1 + + json.data do + json.array! [ @data ] do |datum| + json.(datum, *datum.show_attrs) if datum.present? + end + end FILE ), success: ( - <<-FILE -json.partial! 'api/success' + <<~FILE + # *** Generated by ZRO *** + json.partial! 'api/success' FILE ), success_or_not: ( - <<-FILE -unless @status - # @_code, @_msg = @error_info.present? ? @error_info : ApiError.action_failed.info -end - -json.partial! 'api/base', total: 0 -json.data '' + <<~FILE + # *** Generated by ZRO *** + unless @status + # @_code, @_msg = @error_info.present? ? @error_info : ApiError.action_failed.info + end + + json.partial! 'api/base', total: 0 + json.data '' FILE ), } end