Skip to content

Commit

Permalink
Merge pull request #85 from bullet-train-co/small_fixes
Browse files Browse the repository at this point in the history
Small fixes and version bump
  • Loading branch information
newstler authored Mar 22, 2024
2 parents 2639f03 + 0a715de commit 6de6178
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Jbuilder::Schema

Easily Generate JSON Schemas from Jbuilder Templates for OpenAPI 3.1
Easily Generate OpenAPI 3.1 Schemas from Jbuilder Templates

## Quick Start

Expand Down Expand Up @@ -325,9 +325,9 @@ The `title_name` and `description_name` parameters can accept either a single st

```ruby
Jbuilder::Schema.configure do |config|
config.components_path = "components/schemas" # could be "definitions/schemas"
config.title_name = "title" # could be "label"
config.description_name = ["api_description", "description"] # could be "heading"
config.components_path = "components/schemas" # could be "definitions/schemas"
config.title_name = "title" # could be "label", or an array to support fallbacks, like
config.description_name = %w[api_description description] # could be just string as well like "heading"
end
```

Expand Down
6 changes: 4 additions & 2 deletions lib/jbuilder/schema/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def translate(keys)
translation = I18n.t(key, scope: @scope ||= object&.class&.name&.underscore&.pluralize, default: nil)
return translation if translation.present?
end
I18n.t(keys.first, scope: @scope ||= object&.class&.name&.underscore&.pluralize)
# FIXME: This produces `addresses/countries` for namespaced models.
# Should be probably `addresses.countries`
I18n.t(keys.first, scope: @scope ||= object&.class&.model_name&.collection)
end

def title_keys
Expand Down Expand Up @@ -209,7 +211,7 @@ def _set_title_and_description(key, value)
overrides = @schema_overrides&.dig(key)&.to_h || {}
return unless overrides.any? || @configuration.object

value[:title] ||= overrides[:title] if overrides&.key?(:title)
value[:title] ||= overrides[:title] if overrides.key?(:title)
value[:description] ||= overrides[:description] || @configuration.translate_description(key)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/jbuilder/schema/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# We can't use the standard `Jbuilder::Schema::VERSION =` because
# `Jbuilder` isn't a regular module namespace, but a class …which also loads Active Support.
# So we use trickery, and assign the proper version once `jbuilder/schema.rb` is loaded.
JBUILDER_SCHEMA_VERSION = "2.6.8"
JBUILDER_SCHEMA_VERSION = "2.6.9"

0 comments on commit 6de6178

Please sign in to comment.