-
Notifications
You must be signed in to change notification settings - Fork 126
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 #115
Fixes #115
Changes from all commits
77ac944
a5195eb
d52bb88
92e75bf
93efa1c
02b4f7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,14 +80,19 @@ def rendered_markdown(string) | |
end | ||
|
||
def formatted_body(body, type) | ||
return body if body == " " | ||
return body if body == "[binary data]" # see https://github.com/zipmark/rspec_api_documentation/blob/560c3bdc7bd5581e7c223334390221ecfc910be8/lib/rspec_api_documentation/client_base.rb#L88-L96 | ||
if type =~ /json/ && body.present? | ||
JSON.pretty_generate(JSON.parse(body)) | ||
else | ||
body | ||
end | ||
rescue JSON::ParserError | ||
return body if body == " " | ||
raise JSON::ParserError | ||
rescue => e | ||
if Apitome.configuration.formatted_body_error_handler | ||
Apitome.configuration.formatted_body_error_handler.call(e, body, type) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✨ |
||
else | ||
raise | ||
end | ||
end | ||
|
||
def param_headers(params) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,22 +8,42 @@ | |
<div id="<%= "request-#{index}" %>"> | ||
<h3><%= t(:request, scope: :apitome) %></h3> | ||
<div class="request"> | ||
<% begin %> | ||
<%= render partial: 'apitome/docs/route', locals: {request: request, index: index} %> | ||
<%= render partial: 'apitome/docs/headers', locals: {request: request, index: index, headers: request['request_headers']} %> | ||
<%= render partial: 'apitome/docs/query', locals: {request: request, index: index} unless request['request_query_parameters'].empty? %> | ||
<%= render partial: 'apitome/docs/body', locals: {request: request, index: index, body: request['request_body'], type: request['request_content_type']} if request['request_body'] %> | ||
<%= render partial: 'apitome/docs/curl', locals: {request: request, index: index} if request['curl'] %> | ||
<% | ||
rescue => e | ||
if Apitome.configuration.example_error_handler | ||
Apitome.configuration.example_error_handler.call(e, "request", request) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✨ |
||
else | ||
raise | ||
end | ||
end | ||
%> | ||
</div> | ||
|
||
<h3><%= t(:response, scope: :apitome) %></h3> | ||
<div class="response"> | ||
<% begin %> | ||
<%- if Apitome.configuration.simulated_response %> | ||
<%= link_to('Simulated Response', simulated_path(example[:link])) if example[:link].present? %> | ||
<%- end %> | ||
<%= render partial: 'apitome/docs/response_fields', locals: {params: example['response_fields']} if example['response_fields'].size > 0 %> | ||
<%= render partial: 'apitome/docs/status', locals: {request: request, index: index} %> | ||
<%= render partial: 'apitome/docs/headers', locals: {request: request, index: index, headers: request['response_headers']} %> | ||
<%= render partial: 'apitome/docs/body', locals: {request: request, index: index, body: request['response_body'], type: request['response_content_type']} if request['response_body'] %> | ||
<% | ||
rescue => e | ||
if Apitome.configuration.example_error_handler | ||
Apitome.configuration.example_error_handler.call(e, "response", request) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✨ |
||
else | ||
raise | ||
end | ||
end | ||
%> | ||
</div> | ||
</div> | ||
<% end %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//= link apitome/application.css | ||
//= link apitome/application.js | ||
//= link apitome/highlight_themes/default.css | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🐞 fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor and 🐞 fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
"[binary data"]
change was related in our app to changing from - rack (2.0.8) to rack (2.1.1)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related to zipmark/rspec_api_documentation#458 zipmark/rspec_api_documentation#456