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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 873f63f23317c10660a702e11bc1c489f8708d2a
4
- data.tar.gz: 120fd21dde799a164288915e51ccabb95cc98b78
3
+ metadata.gz: 8af3f62bd027d03f2d329d2201de1aa7e5069ab6
4
+ data.tar.gz: aa1e12782606fadee2d1f19c24cd443f1dfb68fa
5
5
  SHA512:
6
- metadata.gz: f6211eed03bb1e8cae4a0d0b50e244073e20a9a08d7008688356788cc2d2eb4c6e6bbe0c0e5955386b7bee804293c46429436131816f7bbbd94d94f4f1d593a1
7
- data.tar.gz: 8ce67899902657078debff5e25f0f4de0ddd18cc23a0edf1b1cb0286a9ba8a37080ad7e666e32298c061d9238a3598a225d2c18708630ca8d4ddf32a16c97c2c
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: 30
10
+ Max: 33
11
11
 
12
12
  Metrics/PerceivedComplexity:
13
- Max: 10
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
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 rake test
164
- $ bundle exec rake features
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-15 (c) Apiary Ltd.
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: api_description_source(@source_path)
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,
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Apiary
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
@@ -27,6 +27,7 @@ describe Apiary::CLI do
27
27
  )
28
28
  ).each do |cmd|
29
29
  it "includes help #{cmd}in README.md" do
30
+ puts cmd
30
31
  helptext = open("|ruby bin/apiary help #{cmd}", &:read)
31
32
 
32
33
  expect(helptext).to include("apiary #{cmd.strip}")
@@ -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
@@ -0,0 +1,8 @@
1
+ {
2
+ "swagger": "2.0",
3
+ "info": {
4
+ "version": "1.0.0",
5
+ "title": "Minimal",
6
+ "description": "Minimal Swagger"
7
+ }
8
+ }
@@ -1,4 +1,5 @@
1
- swagger: "2.0"
1
+ ---
2
+ swagger: '2.0'
2
3
  info:
3
4
  version: 1.0.0
4
5
  title: Minimal
@@ -1,4 +1,5 @@
1
- swagger: "2.0"
1
+ ---
2
+ swagger: '2.0'
2
3
  info:
3
4
  version: 1.0.0
4
5
  title: Minimal
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.5.2
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-08-17 00:00:00.000000000 Z
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: '2.0'
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: '2.0'
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