Skip to content

Commit 2f54fcd

Browse files
peter scholzLeFnord
peter scholz
authored andcommitted
issue#566: removes markdown (#567)
- updates README - updates UPGRADING - adds changelog entry - cleans up gemfile
1 parent a6cb8ba commit 2f54fcd

14 files changed

+33
-408
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#### Features
44

5+
* [#567](https://github.com/ruby-grape/grape-swagger/pull/567): Issue#566: removes markdown - [@LeFnord](https://github.com/LeFnord).
6+
57
* Your contribution here.
68

79
#### Fixes

Gemfile

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@ gem ENV['MODEL_PARSER'] if ENV.key?('MODEL_PARSER')
1515

1616
group :development, :test do
1717
gem 'bundler'
18-
gem 'kramdown'
1918
gem 'pry', platforms: [:mri]
2019
gem 'pry-byebug', platforms: [:mri]
2120
gem 'rack'
2221
gem 'rack-cors'
2322
gem 'rack-test'
2423
gem 'rake'
2524
gem 'rdoc'
26-
gem 'redcarpet', '< 3.4', platforms: [:mri]
27-
gem 'rouge', platforms: [:mri]
2825
gem 'rspec', '~> 3.0'
2926
gem 'rubocop', '~> 0.40'
30-
gem 'shoulda'
27+
# gem 'shoulda'
3128
end
3229
group :test do
3330
gem 'grape-entity'

README.md

+7-84
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* [Routes Configuration](#routes)
1717
* [Using Grape Entities](#grape-entity)
1818
* [Securing the Swagger UI](#oauth)
19-
* [Markdown](#md_usage)
19+
* [Markdown (deprecated)](#md_usage)
2020
* [Example](#example)
2121
* [Rake Tasks](#rake)
2222

@@ -196,7 +196,6 @@ end
196196
* [add_base_path](#add_base_path)
197197
* [add_version](#add_version)
198198
* [doc_version](#doc_version)
199-
* [markdown](#markdown)
200199
* [endpoint_auth_wrapper](#endpoint_auth_wrapper)
201200
* [swagger_endpoint_guard](#swagger_endpoint_guard)
202201
* [token_owner](#token_owner)
@@ -268,18 +267,8 @@ add_swagger_documentation \
268267
```
269268
270269
<a name="markdown" />
271-
#### markdown:
272-
Allow markdown in `detail`, default is `false`. (disabled) See [below](#md_usage) for details.
273-
274-
```ruby
275-
add_swagger_documentation \
276-
markdown: GrapeSwagger::Markdown::KramdownAdapter.new
277-
```
278-
or alternative
279-
```ruby
280-
add_swagger_documentation \
281-
markdown: GrapeSwagger::Markdown::RedcarpetAdapter.new
282-
```
270+
#### markdown: (deprecated)
271+
OAPI accepts GFM for descriptions
283272
284273
<a name="endpoint_auth_wrapper" />
285274
#### endpoint_auth_wrapper:
@@ -1087,77 +1076,11 @@ The lambda is checking whether the user is authenticated (if not, the token_owne
10871076
role - only admins can see this endpoint.
10881077
10891078
<a name="md_usage" />
1090-
## Markdown in Detail
1091-
1092-
The grape-swagger gem allows you to add an explanation in markdown in the detail field. Which would result in proper formatted markdown in Swagger UI.
1093-
Grape-swagger uses adapters for several markdown formatters. It includes adapters for [kramdown](http://kramdown.rubyforge.org) (kramdown [syntax](http://kramdown.rubyforge.org/syntax.html)) and [redcarpet](https://github.com/vmg/redcarpet).
1094-
The adapters are packed in the GrapeSwagger::Markdown modules. We do not include the markdown gems in our gemfile, so be sure to include or install the depended gems.
1095-
1096-
To use it, add a new instance of the adapter to the markdown options of `add_swagger_documentation`, such as:
1097-
```ruby
1098-
add_swagger_documentation \
1099-
markdown: GrapeSwagger::Markdown::KramdownAdapter.new(options)
1100-
```
1101-
and write your route details in GFM, examples could be find in [details spec](blob/master/spec/swagger_v2/api_swagger_v2_detail_spec.rb)
1102-
1103-
1104-
#### Kramdown
1105-
If you want to use kramdown as markdown formatter, you need to add kramdown to your gemfile.
1106-
1107-
```ruby
1108-
gem 'kramdown'
1109-
```
1110-
1111-
Configure your api documentation route with:
1112-
```ruby
1113-
add_swagger_documentation \
1114-
markdown: GrapeSwagger::Markdown::KramdownAdapter.new(options)
1115-
```
1116-
1079+
## Markdown in Detail (deprecated)
11171080
1118-
#### Redcarpet
1119-
As alternative you can use [redcarpet](https://github.com/vmg/redcarpet) as formatter, you need to include redcarpet in your gemspec. If you also want to use [rouge](https://github.com/jneen/rouge) as syntax highlighter you also need to include it.
1120-
1121-
```ruby
1122-
gem 'redcarpet'
1123-
gem 'rouge'
1124-
```
1125-
1126-
Configure your api documentation route with:
1127-
1128-
```ruby
1129-
add_swagger_documentation(
1130-
markdown: GrapeSwagger::Markdown::RedcarpetAdapter.new(render_options: { highlighter: :rouge })
1131-
)
1132-
```
1133-
1134-
Alternatively you can disable rouge by adding `:none` as highlighter option. You can add redcarpet extensions and render options trough the `extenstions:` and `render_options:` parameters.
1135-
1136-
1137-
#### Custom markdown formatter
1138-
1139-
You can also add your custom adapter for your favourite markdown formatter, as long it responds to the method `markdown(text)` and it formats the given text.
1140-
1141-
1142-
```ruby
1143-
module API
1144-
1145-
class FancyAdapter
1146-
attr_reader :adapter
1147-
1148-
def initialize(options)
1149-
require 'superbmarkdownformatter'
1150-
@adapter = SuperbMarkdownFormatter.new options
1151-
end
1152-
1153-
def markdown(text)
1154-
@adapter.render_supreme(text)
1155-
end
1156-
end
1157-
1158-
add_swagger_documentation markdown: FancyAdapter.new(no_links: true)
1159-
end
1160-
```
1081+
Usage of option `markdown` won't no longer be supported,
1082+
cause OAPI accepts [GFM](https://help.github.com/articles/github-flavored-markdown) and plain text.
1083+
(see: [description of `Info`](https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/2.0.md#info-object))
11611084

11621085

11631086
<a="example" />

UPGRADING.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Upgrading Grape-swagger
22

3+
### Upgrading to >= 0.26.0
4+
5+
Usage of option `markdown` won't no longer be supported,
6+
cause OAPI accepts [GFM](https://help.github.com/articles/github-flavored-markdown) and plain text.
7+
(see: [description of `Info`](https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/2.0.md#info-object))
8+
39
### Upgrading to >= 0.25.2
410

511
Avoids ambiguous documentation of array parameters,

lib/grape-swagger.rb

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
require 'grape-swagger/doc_methods'
88
require 'grape-swagger/model_parsers'
99

10-
require 'grape-swagger/markdown/kramdown_adapter'
11-
require 'grape-swagger/markdown/redcarpet_adapter'
12-
1310
module GrapeSwagger
1411
class << self
1512
def model_parsers

lib/grape-swagger/doc_methods.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def mount_path
2727
end
2828

2929
def setup(options)
30+
# FIXME: move out after next minor is released
31+
GrapeSwagger::Errors::SwaggerSpecDeprecated.tell!(options[:markdown]) if options.key?(:markdown)
32+
3033
options = defaults.merge(options)
3134

3235
# options could be set on #add_swagger_documentation call,
@@ -93,7 +96,6 @@ def defaults
9396
base_path: nil,
9497
add_base_path: false,
9598
add_version: true,
96-
markdown: false,
9799
hide_documentation_path: true,
98100
format: :json,
99101
authorizations: nil,

lib/grape-swagger/endpoint.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ def path_item(routes, options)
105105
def method_object(route, options, path)
106106
method = {}
107107
method[:summary] = summary_object(route)
108-
method[:description] = description_object(route, options[:markdown])
108+
method[:description] = description_object(route)
109109
method[:produces] = produces_object(route, options[:produces] || options[:format])
110110
method[:consumes] = consumes_object(route, options[:format])
111111
method[:parameters] = params_object(route)
112112
method[:security] = security_object(route)
113-
method[:responses] = response_object(route, options[:markdown])
113+
method[:responses] = response_object(route)
114114
method[:tags] = route.options.fetch(:tags, tag_object(route))
115115
method[:operationId] = GrapeSwagger::DocMethods::OperationId.build(route, path)
116116
method.delete_if { |_, value| value.blank? }
@@ -130,10 +130,9 @@ def summary_object(route)
130130
summary
131131
end
132132

133-
def description_object(route, markdown)
133+
def description_object(route)
134134
description = route.description if route.description.present?
135135
description = route.options[:detail] if route.options.key?(:detail)
136-
description = markdown.markdown(description.to_s).chomp if markdown
137136

138137
description
139138
end
@@ -178,7 +177,7 @@ def params_object(route)
178177
parameters
179178
end
180179

181-
def response_object(route, markdown)
180+
def response_object(route)
182181
codes = (route.http_codes || route.options[:failure] || [])
183182

184183
codes = apply_success_codes(route) + codes
@@ -199,7 +198,7 @@ def response_object(route, markdown)
199198
next unless !response_model.start_with?('Swagger_doc') &&
200199
((@definitions[response_model] && value[:code].to_s.start_with?('2')) || value[:model])
201200

202-
@definitions[response_model][:description] = description_object(route, markdown)
201+
@definitions[response_model][:description] = description_object(route)
203202
# TODO: proof that the definition exist, if model isn't specified
204203
reference = { '$ref' => "#/definitions/#{response_model}" }
205204
memo[value[:code]][:schema] = if route.options[:is_array]

lib/grape-swagger/errors.rb

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
module GrapeSwagger
22
module Errors
3-
class MarkdownDependencyMissingError < StandardError
4-
def initialize(missing_gem)
5-
super("Missing required dependency: #{missing_gem}")
6-
end
7-
end
8-
93
class UnregisteredParser < StandardError; end
104
class SwaggerSpec < StandardError; end
5+
class SwaggerSpecDeprecated < SwaggerSpec
6+
class << self
7+
def tell!(what)
8+
warn "[GrapeSwagger] usage of #{what} is deprecated"
9+
end
10+
end
11+
end
1112
end
1213
end

lib/grape-swagger/markdown/kramdown_adapter.rb

-37
This file was deleted.

lib/grape-swagger/markdown/redcarpet_adapter.rb

-92
This file was deleted.

0 commit comments

Comments
 (0)