Skip to content

Commit

Permalink
Fixes #36575 - Use apipie-dsl default model descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
archanaserver committed Oct 23, 2023
1 parent d8200ee commit 60e921d
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gem 'ancestry', '~> 4.0'
gem 'scoped_search', '>= 4.1.10', '< 5'
gem 'ldap_fluff', '>= 0.5.0', '< 1.0'
gem 'apipie-rails', '>= 0.8.0', '< 2'
gem 'apipie-dsl', '>= 2.2.6'
gem 'apipie-dsl', '>= 2.6.0'
# Pin rdoc to prevent updating bundled psych (https://github.com/ruby/rdoc/commit/ebe185c8775b2afe844eb3da6fa78adaa79e29a4)
# Rails 6.0 is incompatible with Psych 4, Rails 6.1 should work
gem 'rdoc', '< 6.4'
Expand Down
2 changes: 1 addition & 1 deletion app/models/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Domain < ApplicationRecord

set_crud_hooks :domain

apipie :class, desc: "A class representing #{model_name.human} object" do
apipie :class do
sections only: %w[all additional]
prop_group :basic_model_props, ApplicationRecord, meta: { example: 'example.com' }
property :fullname, String, desc: 'User name for this domain, e.g. "Primary domain for our company"'
Expand Down
2 changes: 1 addition & 1 deletion app/models/hostgroup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Hostgroup < ApplicationRecord
where(conditions)
}

apipie :class, "A class representing #{model_name.human} object" do
apipie :class do
prop_group :basic_model_props, ApplicationRecord, meta: { friendly_name: 'host group' }
property :architecture, 'Architecture', desc: 'Returns architecture to be used on hosts within this host group'
property :arch, 'Architecture', desc: 'Returns architecture to be used on hosts within this host group'
Expand Down
2 changes: 1 addition & 1 deletion app/models/operatingsystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Operatingsystem < ApplicationRecord

graphql_type '::Types::Operatingsystem'

apipie :class, desc: "A class representing #{model_name.human} object" do
apipie :class do
sections only: %w[all additional]
prop_group :basic_model_props, ApplicationRecord, meta: { friendly_name: 'operating system consisting', example: 'RedHat, Fedora, Debian' }
property :major, String, desc: 'Major version of the operating system'
Expand Down
2 changes: 1 addition & 1 deletion app/models/realm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Realm < ApplicationRecord
end
}

apipie :class, desc: "A class representing #{model_name.human} object" do
apipie :class do
sections only: %w[all additional]
prop_group :basic_model_props, ApplicationRecord, meta: { example: 'EXAMPLE.COM' }
property :realm_type, String, desc: 'Realm type, e.g. FreeIPA or Active Directory'
Expand Down
2 changes: 1 addition & 1 deletion app/models/smart_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def get_features
end
end

apipie :class, desc: "A class representing #{model_name.human} object" do
apipie :class do
name 'Smart Proxy'
refs 'SmartProxy'
sections only: %w[all additional]
Expand Down
2 changes: 1 addition & 1 deletion app/models/ssh_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SshKey < ApplicationRecord

delegate :login, to: :user, prefix: true

apipie :class, desc: "A class representing #{model_name.human} object" do
apipie :class do
sections only: %w[all additional]
prop_group :basic_model_props, ApplicationRecord, meta: { friendly_name: 'SSH key' }
property :user, 'User', desc: 'Returns the user object which is linked to the SSH key'
Expand Down
2 changes: 1 addition & 1 deletion app/models/subnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def model_name

set_crud_hooks :subnet

apipie :class, "A class representing #{model_name.human} object" do
apipie :class do
sections only: %w[all additional]
refs 'Subnet::Ipv4', 'Subnet::Ipv6'
prop_group :basic_model_props, ApplicationRecord
Expand Down
2 changes: 1 addition & 1 deletion app/models/taxonomy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def self.inherited(child)
scoped_search :on => :description, :complete_enabled => :false, :only_explicit => true
scoped_search :on => :id, :validator => ScopedSearch::Validators::INTEGER

apipie :class, desc: "A class representing #{model_name.human} object" do
apipie :class do
sections only: %w[all additional]
name_exl, title_exl = class_scope.model_name.human == 'Location' ? ['Europe', 'Europe/Prague'] : ['Red Hat', 'Red Hat/Engineering']
prop_group :basic_model_props, ApplicationRecord, meta: { example: name_exl }
Expand Down
2 changes: 1 addition & 1 deletion app/models/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Template < ApplicationRecord

attr_exportable :name, :description, :snippet, :template_inputs, :model => ->(template) { template.class.to_s }

apipie :class, desc: "A class representing #{model_name.human} object" do
apipie :class do
sections only: %w[all additional]
prop_group :basic_model_props, ApplicationRecord
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def as_json(options = {})

set_crud_hooks :user

apipie :class, desc: "A class representing #{model_name.human} object" do
apipie :class do
sections only: %w[all additional]
property :id, Integer, desc: 'Numerical ID of the User'
property :firstname, String, desc: 'Returns the user first name'
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/apipie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
trans
end
config.help_layout = 'apipie_dsl/apipie_dsls/help.html.erb'
config.default_class_description = ->(model) { _("A class representing %s object") % model.new.human }
config.reload_dsl = false
end

Apipie.configure do |config|
Expand Down

0 comments on commit 60e921d

Please sign in to comment.