diff --git a/Gemfile b/Gemfile index 84aedd473c25..57f124acb06d 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/app/models/domain.rb b/app/models/domain.rb index 63e0e0b4b626..c892410d1e4a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -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"' diff --git a/app/models/operatingsystem.rb b/app/models/operatingsystem.rb index 0d97e87e2907..c8e898db0aaf 100644 --- a/app/models/operatingsystem.rb +++ b/app/models/operatingsystem.rb @@ -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' diff --git a/app/models/realm.rb b/app/models/realm.rb index 214149c03777..2a6f3756da1a 100644 --- a/app/models/realm.rb +++ b/app/models/realm.rb @@ -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' diff --git a/app/models/smart_proxy.rb b/app/models/smart_proxy.rb index 1d1ae8077b06..f13b111d69dc 100644 --- a/app/models/smart_proxy.rb +++ b/app/models/smart_proxy.rb @@ -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] diff --git a/app/models/ssh_key.rb b/app/models/ssh_key.rb index 13dc8293cadd..51b0a3cedb7e 100644 --- a/app/models/ssh_key.rb +++ b/app/models/ssh_key.rb @@ -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' diff --git a/app/models/taxonomy.rb b/app/models/taxonomy.rb index 855c667b70a6..30c4d634f324 100644 --- a/app/models/taxonomy.rb +++ b/app/models/taxonomy.rb @@ -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 } diff --git a/app/models/template.rb b/app/models/template.rb index e845635df9a7..ceba4cd2abb4 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index f6f174f1699e..b067fb046432 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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' diff --git a/config/initializers/apipie.rb b/config/initializers/apipie.rb index b089ddbefca2..41e992f8f655 100644 --- a/config/initializers/apipie.rb +++ b/config/initializers/apipie.rb @@ -27,6 +27,8 @@ trans end config.help_layout = 'apipie_dsl/apipie_dsls/help.html.erb' + config.default_model_description = ->(model) { _("A class representing %s object") % model.model_name.singular.humanize(capitalize: false) } + config.reload_dsl = false end Apipie.configure do |config|