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

Fix #446 Fixing full_description translation #808

Merged
merged 4 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions lib/apipie/error_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def initialize(code_or_options, desc=nil, options={})
end
end

def to_json
def to_json(lang)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the param should have a default? I wonder if this cannot break people's applications...

{
:code => code,
:description => description,
:description => Apipe.app.translate(description, lang),
mathieujobin marked this conversation as resolved.
Show resolved Hide resolved
:metadata => metadata
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/apipie/method_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def to_json(lang=nil)
:apis => method_apis_to_json(lang),
:formats => formats,
:full_description => Apipie.app.translate(@full_description, lang),
:errors => errors.map(&:to_json),
:errors => errors.map{ |error| error.to_json(lang) }.flatten,
:params => params_ordered.map{ |param| param.to_json(lang) }.flatten,
:returns => @returns.map{ |return_item| return_item.to_json(lang) }.flatten,
:examples => @examples,
Expand Down
4 changes: 2 additions & 2 deletions lib/apipie/resource_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def initialize(controller, resource_name, dsl_data = nil, version = nil, &block)

def update_from_dsl_data(dsl_data)
@_name = dsl_data[:resource_name] if dsl_data[:resource_name]
@_full_description = Apipie.markup_to_html(dsl_data[:description])
@_full_description = dsl_data[:description]
@_short_description = dsl_data[:short_description]
@_path = dsl_data[:path] || ""
@_formats = dsl_data[:formats]
Expand Down Expand Up @@ -110,7 +110,7 @@ def to_json(method_name = nil, lang = nil)
:api_url => api_url,
:name => @_name,
:short_description => Apipie.app.translate(@_short_description, lang),
:full_description => Apipie.app.translate(@_full_description, lang),
:full_description => Apipie.markup_to_html(Apipie.app.translate(@_full_description, lang)),
:version => _version,
:formats => @_formats,
:metadata => @_metadata,
Expand Down
2 changes: 1 addition & 1 deletion lib/apipie/response_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def additional_properties
def to_json(lang=nil)
{
:code => code,
:description => description,
:description => Apipie.app.translate(description, lang),
:is_array => is_array?,
:returns_object => params_ordered.map{ |param| param.to_json(lang).tap{|h| h.delete(:validations) }}.flatten,
:additional_properties => additional_properties,
Expand Down