Commit 5362256e by liyijie

Add resource not exist protection

parent bc05441b
......@@ -10,6 +10,7 @@ class SimpleControllerGenerator < Rails::Generators::NamedBase
def setup
@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?
end
def create_controller_files
......
......@@ -4,9 +4,11 @@ require 'swagger_helper'
type: :object, properties: {
<%= singular_name %>: {
type: :object, properties: {
<% if resource_class&.columns_hash.present? -%>
<% resource_class.columns_hash.except('id', 'created_at', 'updated_at').values.each do |column| -%>
<%= column.name %>: { type: :<%= column.type %>, description: '' },
<% 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