Commit 051c1387 authored by Marcel Stör's avatar Marcel Stör Committed by Shinya Maeda

Apply 2 suggestion(s) to 1 file(s)

parent 687a7cc9
...@@ -10,8 +10,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w ...@@ -10,8 +10,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> - Using this API you can manipulate GitLab [Release](../../user/project/releases/index.md) entries. > - Using this API you can manipulate GitLab [Release](../../user/project/releases/index.md) entries.
> - For manipulating links as a release asset, see [Release Links API](links.md). > - For manipulating links as a release asset, see [Release Links API](links.md).
> - Release Evidences were [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/26019) in GitLab 12.5. > - Release Evidences were [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/26019) in GitLab 12.5.
> - `description_html` became and opt-in field [in GitLab 13.12 for performance reason](https://gitlab.com/gitlab-org/gitlab/-/issues/299447). > - `description_html` became an opt-in field [with GitLab 13.12 for performance reasons](https://gitlab.com/gitlab-org/gitlab/-/issues/299447).
Please pass `render_html` option if you need. Please pass the `include_html_description` query string parameter if you need it.
## List Releases ## List Releases
...@@ -26,7 +26,7 @@ GET /projects/:id/releases ...@@ -26,7 +26,7 @@ GET /projects/:id/releases
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](../README.md#namespaced-path-encoding). | | `id` | integer/string | yes | The ID or [URL-encoded path of the project](../README.md#namespaced-path-encoding). |
| `order_by` | string | no | The field to use as order. Either `released_at` (default) or `created_at`. | | `order_by` | string | no | The field to use as order. Either `released_at` (default) or `created_at`. |
| `sort` | string | no | The direction of the order. Either `desc` (default) for descending order or `asc` for ascending order. | | `sort` | string | no | The direction of the order. Either `desc` (default) for descending order or `asc` for ascending order. |
| `render_html` | boolean | no | If `true`, a response includes HTML rendered Markdown of the release description. | | `include_html_description` | boolean | no | If `true`, a response includes HTML rendered Markdown of the release description. |
Example request: Example request:
...@@ -230,7 +230,7 @@ GET /projects/:id/releases/:tag_name ...@@ -230,7 +230,7 @@ GET /projects/:id/releases/:tag_name
| ------------- | -------------- | -------- | ----------------------------------------------------------------------------------- | | ------------- | -------------- | -------- | ----------------------------------------------------------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](../README.md#namespaced-path-encoding). | | `id` | integer/string | yes | The ID or [URL-encoded path of the project](../README.md#namespaced-path-encoding). |
| `tag_name` | string | yes | The Git tag the release is associated with. | | `tag_name` | string | yes | The Git tag the release is associated with. |
| `render_html` | boolean | no | If `true`, a response includes HTML rendered Markdown of the release description. | | `include_html_description` | boolean | no | If `true`, a response includes HTML rendered Markdown of the release description. |
Example request: Example request:
......
...@@ -8,7 +8,7 @@ module API ...@@ -8,7 +8,7 @@ module API
expose :name expose :name
expose :tag, as: :tag_name, if: ->(_, _) { can_download_code? } expose :tag, as: :tag_name, if: ->(_, _) { can_download_code? }
expose :description expose :description
expose :description_html, if: -> (_, options) { options[:render_html] } do |entity| expose :description_html, if: -> (_, options) { options[:include_html_description] } do |entity|
MarkupHelper.markdown_field(entity, :description, current_user: options[:current_user]) MarkupHelper.markdown_field(entity, :description, current_user: options[:current_user])
end end
expose :created_at expose :created_at
......
...@@ -29,7 +29,7 @@ module API ...@@ -29,7 +29,7 @@ module API
desc: 'Return releases ordered by `released_at` or `created_at`.' desc: 'Return releases ordered by `released_at` or `created_at`.'
optional :sort, type: String, values: %w[asc desc], default: 'desc', optional :sort, type: String, values: %w[asc desc], default: 'desc',
desc: 'Return releases sorted in `asc` or `desc` order.' desc: 'Return releases sorted in `asc` or `desc` order.'
optional :render_html, type: Boolean, optional :include_html_description, type: Boolean,
desc: 'If `true`, a response includes HTML rendered markdown of the release description.' desc: 'If `true`, a response includes HTML rendered markdown of the release description.'
end end
get ':id/releases' do get ':id/releases' do
...@@ -46,7 +46,7 @@ module API ...@@ -46,7 +46,7 @@ module API
cache_context: -> (_) { "user:{#{current_user&.id}}" }, cache_context: -> (_) { "user:{#{current_user&.id}}" },
expires_in: 5.minutes, expires_in: 5.minutes,
current_user: current_user, current_user: current_user,
render_html: params[:render_html] include_html_description: params[:include_html_description]
end end
desc 'Get a single project release' do desc 'Get a single project release' do
...@@ -56,13 +56,13 @@ module API ...@@ -56,13 +56,13 @@ module API
end end
params do params do
requires :tag_name, type: String, desc: 'The name of the tag', as: :tag requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
optional :render_html, type: Boolean, optional :include_html_description, type: Boolean,
desc: 'If `true`, a response includes HTML rendered markdown of the release description.' desc: 'If `true`, a response includes HTML rendered markdown of the release description.'
end end
get ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMENTS do get ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMENTS do
authorize_download_code! authorize_download_code!
present release, with: Entities::Release, current_user: current_user, render_html: params[:render_html] present release, with: Entities::Release, current_user: current_user, include_html_description: params[:include_html_description]
end end
desc 'Create a new release' do desc 'Create a new release' do
......
...@@ -8,8 +8,8 @@ RSpec.describe API::Entities::Release do ...@@ -8,8 +8,8 @@ RSpec.describe API::Entities::Release do
let(:release) { create(:release, project: project) } let(:release) { create(:release, project: project) }
let(:evidence) { release.evidences.first } let(:evidence) { release.evidences.first }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:entity) { described_class.new(release, current_user: user, render_html: render_html).as_json } let(:entity) { described_class.new(release, current_user: user, include_html_description: include_html_description).as_json }
let(:render_html) { false } let(:include_html_description) { false }
before do before do
::Releases::CreateEvidenceService.new(release).execute ::Releases::CreateEvidenceService.new(release).execute
...@@ -59,8 +59,8 @@ RSpec.describe API::Entities::Release do ...@@ -59,8 +59,8 @@ RSpec.describe API::Entities::Release do
expect(description_html).to be_nil expect(description_html).to be_nil
end end
context 'when render_html option is true' do context 'when include_html_description option is true' do
let(:render_html) { true } let(:include_html_description) { true }
it 'renders special references if current user has access' do it 'renders special references if current user has access' do
project.add_reporter(user) project.add_reporter(user)
......
...@@ -114,9 +114,9 @@ RSpec.describe API::Releases do ...@@ -114,9 +114,9 @@ RSpec.describe API::Releases do
expect(json_response.second['tag_path']).to eq("/#{release_1.project.full_path}/-/tags/#{release_1.tag}") expect(json_response.second['tag_path']).to eq("/#{release_1.project.full_path}/-/tags/#{release_1.tag}")
end end
context 'when render_html option is true' do context 'when include_html_description option is true' do
it 'includes description_html field' do it 'includes description_html field' do
get api("/projects/#{project.id}/releases", maintainer), params: { render_html: true } get api("/projects/#{project.id}/releases", maintainer), params: { include_html_description: true }
expect(json_response.map { |h| h['description_html'] }) expect(json_response.map { |h| h['description_html'] })
.to contain_exactly(instance_of(String), instance_of(String)) .to contain_exactly(instance_of(String), instance_of(String))
...@@ -424,9 +424,9 @@ RSpec.describe API::Releases do ...@@ -424,9 +424,9 @@ RSpec.describe API::Releases do
end end
end end
context 'when render_html option is true' do context 'when include_html_description option is true' do
it 'includes description_html field' do it 'includes description_html field' do
get api("/projects/#{project.id}/releases/v0.1", maintainer), params: { render_html: true } get api("/projects/#{project.id}/releases/v0.1", maintainer), params: { include_html_description: true }
expect(json_response['description_html']).to be_instance_of(String) expect(json_response['description_html']).to be_instance_of(String)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment