Commit f1409d6f by liyijie

support column_hash not respond_to

parent 9ee8dc7b
......@@ -12,7 +12,7 @@ class SimpleControllerGenerator < Rails::Generators::NamedBase
def setup
return if options["auth-only"]
@routes = RSpec::Rails::Swagger::RouteParser.new(controller_path.sub(/^\//, '')).routes
p "Warning!! Resource is not exist, CHECK & regenerate after you have configurate the model and routes already" if resource_class&.columns_hash.blank?
p "Warning!! Resource is not exist, CHECK & regenerate after you have configurate the model and routes already" if resource_class.blank?
end
def create_controller_files
......
......@@ -5,8 +5,8 @@ RSpec.describe '<%= controller_path %>', type: :request, capture_examples: true,
type: :object, properties: {
<%= resource_singular %>: {
type: :object, properties: {
<%- if resource_class&.columns_hash.present? -%>
<%- resource_class.columns_hash.except('id', 'created_at', 'updated_at').values.each do |column| -%>
<%- if resource_class.respond_to?(:columns_hash) && resource_class&.columns_hash.present? -%>
<%- resource_class.respond_to?(:columns_hash) && resource_class.columns_hash.except('id', 'created_at', 'updated_at').values.each do |column| -%>
<%= column.name %>: { type: :<%= column.type %>, description: '<%= column&.comment %>' },
<%- end -%>
<%- end -%>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment