Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36575 - Use apipie-dsl default model descriptions #9867

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1'
# 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
5 changes: 5 additions & 0 deletions config/initializers/apipie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
trans
end
config.help_layout = 'apipie_dsl/apipie_dsls/help.html.erb'
config.default_class_description = lambda do |model|
return nil unless model.respond_to?(:model_name)
_("A class representing %s object") % model.model_name.human
end
config.reload_dsl = false
end

Apipie.configure do |config|
Expand Down