apiaryio 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +9 -3
- data/README.md +5 -3
- data/apiary.gemspec +2 -1
- data/lib/apiary/cli.rb +2 -0
- data/lib/apiary/command/preview.rb +12 -1
- data/lib/apiary/command/publish.rb +7 -0
- data/lib/apiary/helpers.rb +6 -0
- data/lib/apiary/version.rb +1 -1
- data/spec/apiary/cli_spec.rb +1 -0
- data/spec/apiary/helpers_spec.rb +8 -0
- data/spec/fixtures/api_blueprint_and_swagger/swagger.json +8 -0
- data/spec/fixtures/api_blueprint_and_swagger/swagger.yaml +2 -1
- data/spec/fixtures/only_swagger/swagger.yaml +2 -1
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8af3f62bd027d03f2d329d2201de1aa7e5069ab6
|
4
|
+
data.tar.gz: aa1e12782606fadee2d1f19c24cd443f1dfb68fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48692656ed1c1e6fad3ae9c0efb8d97952abdd2551f4f854151ba834fdf307ea0a42b9e9fa95777366dd2d56b554c36f8027cf6377d51e5b3cdaea86123e9df8
|
7
|
+
data.tar.gz: ec49c50223316719535052378fac4229675b5a616077d3e7e251b37a3f2bd4fc3c5a8a6bd41a836d2d1b3086478f9c20a79d90fc9952a336e9e1f9608268ea19
|
data/.rubocop_todo.yml
CHANGED
@@ -7,10 +7,13 @@ Lint/UnusedBlockArgument:
|
|
7
7
|
- 'lib/apiary/command/preview.rb'
|
8
8
|
|
9
9
|
Metrics/AbcSize:
|
10
|
-
Max:
|
10
|
+
Max: 33
|
11
11
|
|
12
12
|
Metrics/PerceivedComplexity:
|
13
|
-
Max:
|
13
|
+
Max: 12
|
14
|
+
|
15
|
+
Metrics/CyclomaticComplexity:
|
16
|
+
Max: 9
|
14
17
|
|
15
18
|
Metrics/LineLength:
|
16
19
|
Max: 180
|
@@ -20,7 +23,7 @@ Metrics/LineLength:
|
|
20
23
|
- 'spec/apiary/command/*'
|
21
24
|
|
22
25
|
Metrics/MethodLength:
|
23
|
-
Max:
|
26
|
+
Max: 33
|
24
27
|
|
25
28
|
Style/ClassAndModuleChildren:
|
26
29
|
Enabled: false
|
@@ -31,6 +34,9 @@ Style/ClassVars:
|
|
31
34
|
Style/Documentation:
|
32
35
|
Enabled: false
|
33
36
|
|
37
|
+
Lint/HandleExceptions:
|
38
|
+
Enabled: false
|
39
|
+
|
34
40
|
Style/RegexpLiteral:
|
35
41
|
Enabled: false
|
36
42
|
EnforcedStyle: slashes
|
data/README.md
CHANGED
@@ -93,6 +93,7 @@ Options:
|
|
93
93
|
[--browser=BROWSER] # Show API documentation in specified browser (full command is needed - e.g. `--browser='open -a safari'` in case of osx)
|
94
94
|
[--output=FILE] # Write generated HTML into specified file
|
95
95
|
[--path=PATH] # Specify path to API Description Document. When given a directory, it will look for apiary.apib or swagger.yaml file
|
96
|
+
[--json], [--no-json] # Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing
|
96
97
|
[--api-host=HOST] # Specify apiary host
|
97
98
|
[--server], [--no-server] # Start standalone web server on port 8080
|
98
99
|
[--port=PORT] # Set port for --server option
|
@@ -111,6 +112,7 @@ Usage:
|
|
111
112
|
Options:
|
112
113
|
[--message=COMMIT_MESSAGE] # Publish with custom commit message
|
113
114
|
[--path=PATH] # Specify path to API Description Document. When given a directory, it will look for apiary.apib or swagger.yaml file
|
115
|
+
[--json], [--no-json] # Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing
|
114
116
|
[--api-host=HOST] # Specify apiary host
|
115
117
|
[--push], [--no-push] # Push API Description to the GitHub when API Project is associated with GitHub repository in Apiary
|
116
118
|
# Default: true
|
@@ -160,8 +162,8 @@ Show version
|
|
160
162
|
Inside the `apiary-client` repository directory run:
|
161
163
|
|
162
164
|
```sh
|
163
|
-
$ bundle exec
|
164
|
-
$ bundle exec
|
165
|
+
$ bundle exec rspec spec
|
166
|
+
$ bundle exec cucumber
|
165
167
|
```
|
166
168
|
|
167
169
|
|
@@ -178,7 +180,7 @@ $ rake release
|
|
178
180
|
|
179
181
|
## License
|
180
182
|
|
181
|
-
Copyright 2012-
|
183
|
+
Copyright 2012-16 (c) Apiary Ltd.
|
182
184
|
|
183
185
|
Released under MIT license.
|
184
186
|
See [LICENSE](https://raw.githubusercontent.com/apiaryio/apiary-client/master/LICENSE) file for further details.
|
data/apiary.gemspec
CHANGED
@@ -26,11 +26,12 @@ Gem::Specification.new do |gem|
|
|
26
26
|
gem.add_runtime_dependency 'thor', '~> 0.19.1'
|
27
27
|
gem.add_runtime_dependency 'json', '~> 1.8'
|
28
28
|
gem.add_runtime_dependency 'launchy', '~> 2.4'
|
29
|
+
gem.add_runtime_dependency 'public_suffix', '~> 1.4.6'
|
29
30
|
|
30
31
|
gem.add_development_dependency 'bundler', '~> 1.12'
|
31
32
|
gem.add_development_dependency 'rake', '~> 10.0'
|
32
33
|
gem.add_development_dependency 'rspec', '~> 3.4'
|
33
|
-
gem.add_development_dependency 'webmock', '~> 2.0'
|
34
|
+
gem.add_development_dependency 'webmock', '~> 2.2.0'
|
34
35
|
gem.add_development_dependency 'yard', '~> 0.8'
|
35
36
|
gem.add_development_dependency 'aruba', '~> 0.14'
|
36
37
|
gem.add_development_dependency 'cucumber', '~> 2.0'
|
data/lib/apiary/cli.rb
CHANGED
@@ -20,6 +20,7 @@ module Apiary
|
|
20
20
|
method_option :browser, type: :string, desc: 'Show API documentation in specified browser (full command is needed - e.g. `--browser=\'open -a safari\'` in case of osx)'
|
21
21
|
method_option :output, type: :string, banner: 'FILE', desc: 'Write generated HTML into specified file'
|
22
22
|
method_option :path, type: :string, desc: 'Specify path to API Description Document. When given a directory, it will look for apiary.apib or swagger.yaml file'
|
23
|
+
method_option :json, type: :boolean, desc: 'Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing'
|
23
24
|
method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host'
|
24
25
|
method_option :server, type: :boolean, desc: 'Start standalone web server on port 8080'
|
25
26
|
method_option :port, type: :numeric, banner: 'PORT', desc: 'Set port for --server option'
|
@@ -33,6 +34,7 @@ module Apiary
|
|
33
34
|
desc 'publish', 'Publish API Description Document on docs.API_NAME.apiary.io (API Description must exist on apiary.io)'
|
34
35
|
method_option :message, type: :string, banner: 'COMMIT_MESSAGE', desc: 'Publish with custom commit message'
|
35
36
|
method_option :path, type: :string, desc: 'Specify path to API Description Document. When given a directory, it will look for apiary.apib or swagger.yaml file'
|
37
|
+
method_option :json, type: :boolean, desc: 'Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing'
|
36
38
|
method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host'
|
37
39
|
method_option :push, type: :boolean, default: true, desc: 'Push API Description to the GitHub when API Project is associated with GitHub repository in Apiary'
|
38
40
|
method_option :api_name, type: :string, required: true
|
@@ -28,6 +28,7 @@ module Apiary::Command
|
|
28
28
|
@options.port ||= 8080
|
29
29
|
@options.proxy ||= ENV['http_proxy']
|
30
30
|
@options.server ||= false
|
31
|
+
@options.json ||= false
|
31
32
|
@options.host ||= '127.0.0.1'
|
32
33
|
@options.headers ||= {
|
33
34
|
accept: 'text/html',
|
@@ -90,10 +91,20 @@ module Apiary::Command
|
|
90
91
|
|
91
92
|
def generate
|
92
93
|
template = load_preview_template
|
94
|
+
source = api_description_source(@source_path)
|
95
|
+
|
96
|
+
return if source.nil?
|
97
|
+
|
98
|
+
begin
|
99
|
+
JSON.parse(source)
|
100
|
+
abort('Did you forget the --json flag') unless @options.json
|
101
|
+
rescue; end
|
102
|
+
|
103
|
+
source = convert_from_json(source) if @options.json
|
93
104
|
|
94
105
|
data = {
|
95
106
|
title: File.basename(@source_path, '.*'),
|
96
|
-
source:
|
107
|
+
source: source
|
97
108
|
}
|
98
109
|
|
99
110
|
template.result(binding)
|
@@ -17,6 +17,7 @@ module Apiary::Command
|
|
17
17
|
def initialize(opts)
|
18
18
|
@options = OpenStruct.new(opts)
|
19
19
|
@options.path ||= '.'
|
20
|
+
@options.json ||= false
|
20
21
|
@options.api_host ||= 'api.apiary.io'
|
21
22
|
@options.api_name ||= false
|
22
23
|
@options.api_key ||= ENV['APIARY_API_KEY']
|
@@ -58,6 +59,12 @@ module Apiary::Command
|
|
58
59
|
|
59
60
|
return if source.nil?
|
60
61
|
|
62
|
+
begin
|
63
|
+
JSON.parse(source)
|
64
|
+
abort('Did you forget the --json flag?') unless @options.json
|
65
|
+
rescue; end
|
66
|
+
|
67
|
+
source = convert_from_json(source) if @options.json
|
61
68
|
data = {
|
62
69
|
code: source,
|
63
70
|
messageToSave: @options.message,
|
data/lib/apiary/helpers.rb
CHANGED
@@ -17,6 +17,12 @@ module Apiary
|
|
17
17
|
source
|
18
18
|
end
|
19
19
|
|
20
|
+
def convert_from_json(add)
|
21
|
+
JSON.parse(add).to_yaml
|
22
|
+
rescue JSON::ParserError => e
|
23
|
+
abort "Unable to convert input document to yaml: #{e.message.lines.first}"
|
24
|
+
end
|
25
|
+
|
20
26
|
protected
|
21
27
|
|
22
28
|
def choose_one(path)
|
data/lib/apiary/version.rb
CHANGED
data/spec/apiary/cli_spec.rb
CHANGED
data/spec/apiary/helpers_spec.rb
CHANGED
@@ -64,4 +64,12 @@ describe Apiary::Helpers do
|
|
64
64
|
expect(file1).to eq(file2)
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
describe '#convert_from_json' do
|
69
|
+
it 'converts swagger in yaml to swagger to json' do
|
70
|
+
yaml_source = api_description_source('spec/fixtures/api_blueprint_and_swagger/swagger.yaml')
|
71
|
+
json_source = api_description_source('spec/fixtures/api_blueprint_and_swagger/swagger.json')
|
72
|
+
expect(yaml_source).to eq(convert_from_json(json_source))
|
73
|
+
end
|
74
|
+
end
|
67
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiaryio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Apiary Ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: public_suffix
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.4.6
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.4.6
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: bundler
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +142,14 @@ dependencies:
|
|
128
142
|
requirements:
|
129
143
|
- - ~>
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
145
|
+
version: 2.2.0
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - ~>
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
152
|
+
version: 2.2.0
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: yard
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -235,6 +249,7 @@ files:
|
|
235
249
|
- spec/apiary/command/publish_spec.rb
|
236
250
|
- spec/apiary/helpers_spec.rb
|
237
251
|
- spec/fixtures/api_blueprint_and_swagger/apiary.apib
|
252
|
+
- spec/fixtures/api_blueprint_and_swagger/swagger.json
|
238
253
|
- spec/fixtures/api_blueprint_and_swagger/swagger.yaml
|
239
254
|
- spec/fixtures/apiary-invalid.apib
|
240
255
|
- spec/fixtures/apiary.apib
|
@@ -283,6 +298,7 @@ test_files:
|
|
283
298
|
- spec/apiary/command/publish_spec.rb
|
284
299
|
- spec/apiary/helpers_spec.rb
|
285
300
|
- spec/fixtures/api_blueprint_and_swagger/apiary.apib
|
301
|
+
- spec/fixtures/api_blueprint_and_swagger/swagger.json
|
286
302
|
- spec/fixtures/api_blueprint_and_swagger/swagger.yaml
|
287
303
|
- spec/fixtures/apiary-invalid.apib
|
288
304
|
- spec/fixtures/apiary.apib
|