forked from loafle/openapi-generator-original
validate(s)_presence_of
Migration should create pluralized table names Change controller filenames
This commit is contained in:
parent
b2e2643fd2
commit
2aadbee8ed
@ -281,8 +281,8 @@ public class Rails5ServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
||||
return underscore(name) + "_controllers";
|
||||
// e.g. DefaultController => defaults_controller.rb
|
||||
return underscore(name) + "s_controller";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
class InitTables < ActiveRecord::Migration
|
||||
def change{{#models}}{{#model}}
|
||||
create_table :{{classFilename}}, id: false do |t|{{#vars}}{{#isContainer}}
|
||||
create_table "{{classFilename}}".pluralize.to_sym, id: false do |t|{{#vars}}{{#isContainer}}
|
||||
t.string :{{name}}{{/isContainer}}{{^isContainer}}
|
||||
t.{{datatype}} :{{{name}}}{{/isContainer}}{{/vars}}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
{{#models}}{{#model}}
|
||||
class {{classname}} < ApplicationRecord
|
||||
{{#requiredVars}}
|
||||
validate_presence_of :{{name}}
|
||||
validates_presence_of :{{name}}
|
||||
{{/requiredVars}}{{#vars}}{{#isListContainer}}
|
||||
serialize :{{name}}, Array{{/isListContainer}}{{#isMapContainer}}
|
||||
serialize :{{name}}, Hash{{/isMapContainer}}{{/vars}}
|
||||
|
@ -23,8 +23,8 @@ limitations under the License.
|
||||
|
||||
|
||||
class Pet < ApplicationRecord
|
||||
validate_presence_of :name
|
||||
validate_presence_of :photo_urls
|
||||
validates_presence_of :name
|
||||
validates_presence_of :photo_urls
|
||||
|
||||
serialize :photo_urls, Array
|
||||
serialize :tags, Array
|
||||
|
@ -23,7 +23,7 @@ limitations under the License.
|
||||
|
||||
class InitTables < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :api_response, id: false do |t|
|
||||
create_table "api_response".pluralize.to_sym, id: false do |t|
|
||||
t.integer :code
|
||||
t.string :type
|
||||
t.string :message
|
||||
@ -31,14 +31,14 @@ class InitTables < ActiveRecord::Migration
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :category, id: false do |t|
|
||||
create_table "category".pluralize.to_sym, id: false do |t|
|
||||
t.integer :id
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :order, id: false do |t|
|
||||
create_table "order".pluralize.to_sym, id: false do |t|
|
||||
t.integer :id
|
||||
t.integer :pet_id
|
||||
t.integer :quantity
|
||||
@ -49,7 +49,7 @@ class InitTables < ActiveRecord::Migration
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :pet, id: false do |t|
|
||||
create_table "pet".pluralize.to_sym, id: false do |t|
|
||||
t.integer :id
|
||||
t.string :category
|
||||
t.string :name
|
||||
@ -60,14 +60,14 @@ class InitTables < ActiveRecord::Migration
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :tag, id: false do |t|
|
||||
create_table "tag".pluralize.to_sym, id: false do |t|
|
||||
t.integer :id
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :user, id: false do |t|
|
||||
create_table "user".pluralize.to_sym, id: false do |t|
|
||||
t.integer :id
|
||||
t.string :username
|
||||
t.string :first_name
|
||||
|
Loading…
x
Reference in New Issue
Block a user