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
|
// 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'.
|
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
|
// e.g. DefaultController => defaults_controller.rb
|
||||||
return underscore(name) + "_controllers";
|
return underscore(name) + "s_controller";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
class InitTables < ActiveRecord::Migration
|
class InitTables < ActiveRecord::Migration
|
||||||
def change{{#models}}{{#model}}
|
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.string :{{name}}{{/isContainer}}{{^isContainer}}
|
||||||
t.{{datatype}} :{{{name}}}{{/isContainer}}{{/vars}}
|
t.{{datatype}} :{{{name}}}{{/isContainer}}{{/vars}}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
{{#models}}{{#model}}
|
{{#models}}{{#model}}
|
||||||
class {{classname}} < ApplicationRecord
|
class {{classname}} < ApplicationRecord
|
||||||
{{#requiredVars}}
|
{{#requiredVars}}
|
||||||
validate_presence_of :{{name}}
|
validates_presence_of :{{name}}
|
||||||
{{/requiredVars}}{{#vars}}{{#isListContainer}}
|
{{/requiredVars}}{{#vars}}{{#isListContainer}}
|
||||||
serialize :{{name}}, Array{{/isListContainer}}{{#isMapContainer}}
|
serialize :{{name}}, Array{{/isListContainer}}{{#isMapContainer}}
|
||||||
serialize :{{name}}, Hash{{/isMapContainer}}{{/vars}}
|
serialize :{{name}}, Hash{{/isMapContainer}}{{/vars}}
|
||||||
|
@ -23,8 +23,8 @@ limitations under the License.
|
|||||||
|
|
||||||
|
|
||||||
class Pet < ApplicationRecord
|
class Pet < ApplicationRecord
|
||||||
validate_presence_of :name
|
validates_presence_of :name
|
||||||
validate_presence_of :photo_urls
|
validates_presence_of :photo_urls
|
||||||
|
|
||||||
serialize :photo_urls, Array
|
serialize :photo_urls, Array
|
||||||
serialize :tags, Array
|
serialize :tags, Array
|
||||||
|
@ -23,7 +23,7 @@ limitations under the License.
|
|||||||
|
|
||||||
class InitTables < ActiveRecord::Migration
|
class InitTables < ActiveRecord::Migration
|
||||||
def change
|
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.integer :code
|
||||||
t.string :type
|
t.string :type
|
||||||
t.string :message
|
t.string :message
|
||||||
@ -31,14 +31,14 @@ class InitTables < ActiveRecord::Migration
|
|||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table :category, id: false do |t|
|
create_table "category".pluralize.to_sym, id: false do |t|
|
||||||
t.integer :id
|
t.integer :id
|
||||||
t.string :name
|
t.string :name
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table :order, id: false do |t|
|
create_table "order".pluralize.to_sym, id: false do |t|
|
||||||
t.integer :id
|
t.integer :id
|
||||||
t.integer :pet_id
|
t.integer :pet_id
|
||||||
t.integer :quantity
|
t.integer :quantity
|
||||||
@ -49,7 +49,7 @@ class InitTables < ActiveRecord::Migration
|
|||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table :pet, id: false do |t|
|
create_table "pet".pluralize.to_sym, id: false do |t|
|
||||||
t.integer :id
|
t.integer :id
|
||||||
t.string :category
|
t.string :category
|
||||||
t.string :name
|
t.string :name
|
||||||
@ -60,14 +60,14 @@ class InitTables < ActiveRecord::Migration
|
|||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table :tag, id: false do |t|
|
create_table "tag".pluralize.to_sym, id: false do |t|
|
||||||
t.integer :id
|
t.integer :id
|
||||||
t.string :name
|
t.string :name
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table :user, id: false do |t|
|
create_table "user".pluralize.to_sym, id: false do |t|
|
||||||
t.integer :id
|
t.integer :id
|
||||||
t.string :username
|
t.string :username
|
||||||
t.string :first_name
|
t.string :first_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user