-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Apipie::ParamDescription to be marked as deprecated
- Loading branch information
1 parent
9696598
commit 22d0357
Showing
12 changed files
with
219 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<% if deprecation.present? %> | ||
<strong><%= t('apipie.deprecation_details') %></strong> | ||
<ul> | ||
<% if deprecation[:deprecated_in].present? %> | ||
<li><%= t('apipie.deprecation.attributes.deprecated_in') %>: <%= deprecation[:deprecated_in] %></li> | ||
<% end %> | ||
<% if deprecation[:sunset_at].present? %> | ||
<li><%= t('apipie.deprecation.attributes.sunset_at') %>: <%= deprecation[:sunset_at] %></li> | ||
<% end %> | ||
<% if deprecation[:info].present? %> | ||
<li><%= t('apipie.deprecation.attributes.info') %>: <%= deprecation[:info] %></li> | ||
<% end %> | ||
</ul> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module Apipie | ||
class ParamDescription | ||
# Data transfer object, used when param description is deprecated | ||
class Deprecation | ||
attr_reader :info, :deprecated_in, :sunset_at | ||
|
||
def initialize(info: nil, deprecated_in: nil, sunset_at: nil) | ||
@info = info | ||
@deprecated_in = deprecated_in | ||
@sunset_at = sunset_at | ||
end | ||
|
||
def to_json(*_args) | ||
{ | ||
info: @info, | ||
deprecated_in: @deprecated_in, | ||
sunset_at: @sunset_at | ||
} | ||
end | ||
end | ||
end | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require "spec_helper" | ||
|
||
describe Apipie::ParamDescription::Deprecation do | ||
let(:info) { nil } | ||
let(:deprecated_in) { nil } | ||
let(:sunset_at) { nil } | ||
|
||
let(:deprecation) do | ||
described_class.new( | ||
info: info, | ||
deprecated_in: deprecated_in, | ||
sunset_at: sunset_at | ||
) | ||
end | ||
|
||
describe '#to_json' do | ||
subject { deprecation.to_json } | ||
|
||
it { is_expected.to eq({ info: nil, deprecated_in: nil, sunset_at: nil }) } | ||
|
||
context 'when attributes are given' do | ||
let(:info) { 'info' } | ||
let(:deprecated_in) { '2.3' } | ||
let(:sunset_at) { '3.0' } | ||
|
||
it 'returns the correct attributes' do | ||
expect(subject).to eq({ info: info, deprecated_in: deprecated_in, sunset_at: sunset_at }) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters