apiaryio 0.14.1 → 0.16.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
  SHA256:
3
- metadata.gz: ecb88a84bcbd64fc778b76064828f9ee365b0e7037a5d354807821999aba8301
4
- data.tar.gz: a4dd2fa6c417a193a6966f6fe9c25cb3c8af44312243b537947b0d97b7a3a619
3
+ metadata.gz: '0285a16e62857c93d0102d3b35bf5c4b413ae412f13972ab12af5b8201ee3dcb'
4
+ data.tar.gz: 4d45af225fb2df5579cbd9d0cc8262e286c45a0281451fe14555703fe54c420e
5
5
  SHA512:
6
- metadata.gz: 4f4fc4b653ca1ab334fd6713ecb1cb4c5cd5da2afef220d1d753419efe2782012146ec4ceac3df8251fefc10af88a323e9e6fe9c9ecb7dd1c86e57a95840898b
7
- data.tar.gz: 94d0ea2e1d38dfeb4b0b46e348a2912149b8071613f94f0273e95a183d5f1ca65b521fee013556e23e111f0d5ca18fd28aed460e6a0e6ff5904524b247316676
6
+ metadata.gz: 6a7e045cae664b7357e965f80fe126e9ffa213869284e23fd806768a78b5217eb8734d1cdaefe53ceda3bd574db9b8e4cdf76c6b54793654b132618ecfb2e5dd
7
+ data.tar.gz: e70b4ae7a5dc7e0d93dc97a57f7ca7f7a8df7821534bc93dd2fc0e5fe769b090f878a01fd825051599400f93e783907d69066eb0ab13a29bd0f72bae4f2b9ecd
data/.circleci/config.yml CHANGED
@@ -7,6 +7,7 @@ workflows:
7
7
  - test-2.5
8
8
  - test-2.6
9
9
  - test-2.7
10
+ - test-3.0
10
11
  jobs:
11
12
  test-2.4: &test-template
12
13
  docker:
@@ -45,3 +46,7 @@ jobs:
45
46
  <<: *test-template
46
47
  docker:
47
48
  - image: circleci/ruby:2.7-browsers
49
+ test-3.0:
50
+ <<: *test-template
51
+ docker:
52
+ - image: circleci/ruby:3.0-browsers
data/.editorconfig ADDED
@@ -0,0 +1,15 @@
1
+ ; EditorConfig file: http://EditorConfig.org
2
+ ; Install the "EditorConfig" plugin into your editor to use
3
+
4
+ root = true
5
+
6
+ [*]
7
+ charset = utf-8
8
+ insert_final_newline = true
9
+ indent_style = space
10
+ indent_size = 2
11
+ trim_trailing_whitespace = true
12
+
13
+ [README.md]
14
+ trim_trailing_whitespace = false
15
+ insert_final_newline = false
@@ -8,8 +8,8 @@ jobs:
8
8
  steps:
9
9
  - name: Checkout
10
10
  uses: actions/checkout@v2
11
- - name: Login to docker
12
- uses: azure/docker-login@v1
11
+ - name: Login to Docker Hub
12
+ uses: docker/login-action@v1
13
13
  with:
14
14
  username: ${{ secrets.DOCKER_USERNAME }}
15
15
  password: ${{ secrets.DOCKER_PASSWORD }}
@@ -22,3 +22,13 @@ jobs:
22
22
  docker tag apiaryio/client apiaryio/client:${{ steps.version.outputs.VERSION }}
23
23
  docker push apiaryio/client
24
24
  docker push apiaryio/client:${{ steps.version.outputs.VERSION }}
25
+ - name: Publish to RubyGems
26
+ run: |
27
+ mkdir -p $HOME/.gem
28
+ touch $HOME/.gem/credentials
29
+ chmod 0600 $HOME/.gem/credentials
30
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
31
+ gem build *.gemspec
32
+ gem push *.gem
33
+ env:
34
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
@@ -11,7 +11,7 @@ jobs:
11
11
  strategy:
12
12
  matrix:
13
13
  os: ["windows-latest", "ubuntu-latest"]
14
- ruby: ["2.7.x", "2.6.x", "2.5.x", "2.4.x"]
14
+ ruby: ["3.0.x", "2.7.x", "2.6.x", "2.5.x"]
15
15
  steps:
16
16
  - uses: actions/checkout@v2
17
17
  - name: Set up Ruby
data/.gitignore CHANGED
@@ -37,9 +37,11 @@ Gemfile.lock
37
37
 
38
38
  # testing
39
39
  spec/fixtures/test.html
40
+ rules.json
41
+ functions.js
40
42
 
41
43
  # idea ide
42
44
  /.idea
43
45
 
44
46
  # netbeans IDE
45
- /nbproject
47
+ /nbproject
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
- # Chaneglog
1
+ # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 0.15.0
4
+ * fix: change domain from docs.<subdomain>.apiary.io to <subdomain>.docs.apiary.io
5
+ * fix(security): [CVE-2020-10663](https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/) and [CVE-2020-8184](https://nvd.nist.gov/vuln/detail/CVE-2020-8184)
6
+ ## 0.14.1
7
+ * fix: [update rack to 2.1.4](https://github.com/advisories/GHSA-j6w9-fv6q-3q52)
4
8
 
5
9
  ## 0.14.0
6
10
 
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.4-alpine
1
+ FROM ruby:2.7-alpine
2
2
  RUN apk add --update build-base && rm /var/cache/apk/*
3
3
  RUN gem install apiaryio
4
4
  ENTRYPOINT ["apiary"]
data/README.md CHANGED
@@ -8,12 +8,12 @@ Apiary CLI Client
8
8
  ## Description
9
9
 
10
10
  The Apiary CLI Client gem is a command line tool for developing and previewing
11
- [API Blueprint](http://apiblueprint.org) documents locally. It can also be
11
+ [API Blueprint](https://apiblueprint.org) documents locally. It can also be
12
12
  used for pushing updated documents to and fetching existing documents from
13
- [Apiary](http://apiary.io).
13
+ [Apiary](https://apiary.io).
14
14
 
15
15
 
16
- Please see the `apiary help` command and the [full documentation](http://client.apiary.io) for an in-depth look in how to use this tool.
16
+ Please see the `apiary help` command and the [full documentation](https://client.apiary.io) for an in-depth look in how to use this tool.
17
17
 
18
18
  For instructions on making your own changes, see [Hacking Apiary CLI Client](#hacking-apiary-cli-client), below.
19
19
 
@@ -45,7 +45,7 @@ docker build -t "apiaryio/client" .
45
45
  *Required only for publish and fetch commands.*
46
46
 
47
47
 
48
- 1. Make sure you are a registered user of [Apiary](http://apiary.io).
48
+ 1. Make sure you are a registered user of [Apiary](https://apiary.io).
49
49
  2. Retrieve API key (token) on [this page](https://login.apiary.io/tokens).
50
50
  3. Export it as an environment variable:
51
51
 
@@ -57,10 +57,11 @@ export APIARY_API_KEY=<your_token>
57
57
  ```
58
58
  $ apiary help
59
59
  Commands:
60
- apiary fetch --api-name=API_NAME # Fetch API Description Document from API_NAME.apiary.io
60
+ apiary archive # Archive All Your API Description Documents from apiary.io to local files named following [api-project-subdomain.apib] pattern.
61
+ apiary fetch --api-name=API_NAME # Fetch API Description Document from API_NAME.docs.apiary.io
61
62
  apiary help [COMMAND] # Describe available commands or one specific command
62
63
  apiary preview # Show API documentation in browser or write it to file
63
- apiary publish --api-name=API_NAME # Publish API Description Document on docs.API_NAME.apiary.io (API Description must exist on apiary.io)
64
+ apiary publish --api-name=API_NAME # Publish API Description Document on API_NAME.docs.apiary.io (API Description must exist on apiary.io)
64
65
  apiary styleguide # Check API Description Document against styleguide rules (Apiary.io pro plan is required - https://apiary.io/plans )
65
66
  apiary version # Show version
66
67
 
@@ -68,6 +69,18 @@ Commands:
68
69
 
69
70
  ### Details
70
71
 
72
+ #### archive
73
+
74
+ ```
75
+ $ apiary help archive
76
+ Usage:
77
+ apiary archive
78
+
79
+ Options:
80
+
81
+ Archive All Your API Description Documents from apiary.io to local files named following [api-project-subdomain.apib] pattern.
82
+ ```
83
+
71
84
  #### fetch
72
85
 
73
86
  ```
@@ -79,7 +92,7 @@ Options:
79
92
  --api-name=API_NAME
80
93
  [--output=FILE] # Write API Description Document into specified file
81
94
 
82
- Fetch API Description Document from API_NAME.apiary.io
95
+ Fetch API Description Document from API_NAME.docs.apiary.io
83
96
  ```
84
97
 
85
98
  #### preview
@@ -117,7 +130,7 @@ Options:
117
130
  # Default: true
118
131
  --api-name=API_NAME
119
132
 
120
- Publish API Description Document on docs.API_NAME.apiary.io (API Description must exist on apiary.io)
133
+ Publish API Description Document on API_NAME.docs.apiary.io (API Description must exist on apiary.io)
121
134
  ```
122
135
 
123
136
  #### styleguide
@@ -192,9 +205,17 @@ Use `bundle install` to install your changes locally, for manual and ad-hock tes
192
205
 
193
206
  Only gem owners `gem owner apiaryio` can publish new gem into [RubyGems](https://rubygems.org/gems/apiaryio).
194
207
 
195
- ```sh
196
- $ rake release
197
- ```
208
+ 1. bump version in `lib/apiary/version.rb`
209
+ 2. update `CHANGELOG.md`
210
+ 3. prepare Github Release with text in `CHANGELOG`
211
+ 4. make gem release:
212
+
213
+ ```sh
214
+ $ git tag $VERSION
215
+ $ git push --tags
216
+ ```
217
+
218
+ - if release is stuck you need use `$ rake release --trace` to get OTP prompt.
198
219
 
199
220
 
200
221
  ## License
data/apiary.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
 
15
15
  gem.description = 'Apiary.io CLI'
16
16
  gem.summary = 'Apiary.io CLI'
17
- gem.homepage = 'http://apiary.io'
17
+ gem.homepage = 'https://apiary.io'
18
18
  gem.license = 'MIT'
19
19
 
20
20
  gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
@@ -24,13 +24,13 @@ Gem::Specification.new do |gem|
24
24
  gem.require_paths = ['lib']
25
25
 
26
26
  gem.add_runtime_dependency 'rest-client', '~> 2.0'
27
- gem.add_runtime_dependency 'rack', '>= 2.1.4'
27
+ gem.add_runtime_dependency 'rack', '>= 2.2.3'
28
28
  gem.add_runtime_dependency 'thor', '~> 0.20.3'
29
- gem.add_runtime_dependency 'json', '~> 2.1'
29
+ gem.add_runtime_dependency 'json', '>= 2.3.0'
30
30
  gem.add_runtime_dependency 'launchy', '~> 2.4'
31
31
  gem.add_runtime_dependency 'listen', '~> 3.0'
32
32
 
33
- gem.add_development_dependency 'bundler', '~> 2.0'
33
+ gem.add_development_dependency 'bundler', '>= 2.2.11'
34
34
  gem.add_development_dependency 'rake', '>= 12.3.3'
35
35
  gem.add_development_dependency 'rspec', '~> 3.4'
36
36
  gem.add_development_dependency 'webmock', '>= 2.2.0'
@@ -1,8 +1,8 @@
1
- Feature: Publish apiary.apib on docs.API_NAME.apiary.io
1
+ Feature: Publish apiary.apib on API_NAME.docs.apiary.io
2
2
 
3
3
  # This is integration testing you have to set APIARY_API_KEY
4
4
  @needs_apiary_api_key
5
- Scenario: Publish apiary.apib on docs.API_NAME.apiary.io
5
+ Scenario: Publish apiary.apib on API_NAME.docs.apiary.io
6
6
 
7
7
  # expected to fail
8
8
  When I run `apiary publish --path=apiary.apib --api-name 1111apiaryclienttest`
@@ -1,4 +1,4 @@
1
- Feature: Styleguide apiary.apib on docs.API_NAME.apiary.io
1
+ Feature: Styleguide apiary.apib on API_NAME.docs.apiary.io
2
2
 
3
3
  # This is integration testing you have to set APIARY_API_KEY
4
4
  @needs_apiary_api_key
data/lib/apiary/cli.rb CHANGED
@@ -2,13 +2,23 @@
2
2
 
3
3
  require 'thor'
4
4
  require 'apiary/command/fetch'
5
+ require 'apiary/command/archive'
5
6
  require 'apiary/command/preview'
6
7
  require 'apiary/command/publish'
7
8
  require 'apiary/command/styleguide'
8
9
 
9
10
  module Apiary
10
11
  class CLI < Thor
11
- desc 'fetch', 'Fetch API Description Document from API_NAME.apiary.io'
12
+
13
+ desc 'archive', 'Archive All Your API Description Documents from apiary.io to local files named following [api-project-subdomain.apib] pattern.'
14
+ method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host', hide: true
15
+
16
+ def archive
17
+ cmd = Apiary::Command::Archive.new options
18
+ cmd.execute
19
+ end
20
+
21
+ desc 'fetch', 'Fetch API Description Document from API_NAME.docs.apiary.io'
12
22
  method_option :api_name, type: :string, required: true
13
23
  method_option :api_host, type: :string, banner: 'HOST', desc: 'Specify apiary host', hide: true
14
24
  method_option :output, type: :string, banner: 'FILE', desc: 'Write API Description Document into specified file'
@@ -34,7 +44,7 @@ module Apiary
34
44
  cmd.execute
35
45
  end
36
46
 
37
- desc 'publish', 'Publish API Description Document on docs.API_NAME.apiary.io (API Description must exist on apiary.io)'
47
+ desc 'publish', 'Publish API Description Document on API_NAME.docs.apiary.io (API Description must exist on apiary.io)'
38
48
  method_option :message, type: :string, banner: 'COMMIT_MESSAGE', desc: 'Publish with custom commit message'
39
49
  method_option :path, type: :string, desc: 'Specify path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file'
40
50
  method_option :json, type: :boolean, desc: 'Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing'
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+
6
+ require 'apiary/agent'
7
+
8
+ module Apiary::Command
9
+ # Retrieve blueprint from apiary
10
+ class Archive
11
+ def initialize(opts)
12
+ @options = OpenStruct.new(opts)
13
+ @options.api_host ||= 'api.apiary.io'
14
+ @options.api_key ||= ENV['APIARY_API_KEY']
15
+ @options.proxy ||= ENV['http_proxy']
16
+ @options.headers ||= {
17
+ accept: 'application/json',
18
+ content_type: 'application/json',
19
+ authorization: "Bearer #{@options.api_key}",
20
+ user_agent: Apiary.user_agent
21
+ }
22
+ end
23
+
24
+ def execute
25
+ response = apilist_from_apiary
26
+
27
+ return unless response.instance_of? String
28
+
29
+ puts response
30
+ end
31
+
32
+ def apilist_from_apiary
33
+ unless @options.api_key
34
+ abort 'API key must be provided through environment variable APIARY_API_KEY. Please go to https://login.apiary.io/tokens to obtain it.'
35
+ end
36
+
37
+ response = query_apiary
38
+
39
+ response['apis'].each do |api|
40
+ puts api['apiSubdomain']
41
+ @options = OpenStruct.new
42
+ @options.api_host ||= 'api.apiary.io'
43
+ @options.api_name ||= api['apiSubdomain']
44
+ @options.api_key ||= ENV['APIARY_API_KEY']
45
+ @options.proxy ||= ENV['http_proxy']
46
+ @options.output ||= api['apiSubdomain'] + '.apib'
47
+ @options.headers ||= {
48
+ accept: 'text/html',
49
+ content_type: 'text/plain',
50
+ authentication: "Token #{@options.api_key}",
51
+ user_agent: Apiary.user_agent
52
+ }
53
+ cmd = Apiary::Command::Fetch.new(@options)
54
+ cmd.execute
55
+ end
56
+ end
57
+
58
+ def query_apiary
59
+ url = "https://#{@options.api_host}/me/apis"
60
+ RestClient.proxy = @options.proxy
61
+
62
+ begin
63
+ response = RestClient.get url, @options.headers
64
+ rescue RestClient::Exception => e
65
+ abort "Apiary service responded with an error: #{e.message}"
66
+ end
67
+ JSON.parse response.body
68
+ end
69
+
70
+ end
71
+ end
@@ -32,7 +32,7 @@ module Apiary::Command
32
32
 
33
33
  def fetch_from_apiary
34
34
  unless @options.api_name
35
- abort 'Please provide an api-name option (subdomain part from your http://docs.<api-name>.apiary.io/)'
35
+ abort 'Please provide an api-name option (subdomain part from your https://<api-name>.docs.apiary.io/)'
36
36
  end
37
37
 
38
38
  unless @options.api_key
@@ -42,7 +42,7 @@ module Apiary::Command
42
42
 
43
43
  def publish_on_apiary
44
44
  unless @options.api_name
45
- abort 'Please provide an api-name option (subdomain part from your http://docs.<api-name>.apiary.io/)'
45
+ abort 'Please provide an api-name option (subdomain part from your https://<api-name>.docs.apiary.io/)'
46
46
  end
47
47
 
48
48
  unless @options.api_key
@@ -1,3 +1,3 @@
1
1
  module Apiary
2
- VERSION = '0.14.1'.freeze
2
+ VERSION = '0.16.0'.freeze
3
3
  end
@@ -4,7 +4,7 @@ describe Apiary::Command::Fetch do
4
4
  it 'pass command without params' do
5
5
  opts = {}
6
6
  command = Apiary::Command::Fetch.new(opts)
7
- expect { command.fetch_from_apiary }.to raise_error('Please provide an api-name option (subdomain part from your http://docs.<api-name>.apiary.io/)')
7
+ expect { command.fetch_from_apiary }.to raise_error('Please provide an api-name option (subdomain part from your https://<api-name>.docs.apiary.io/)')
8
8
  end
9
9
 
10
10
  it 'pass command only with api_name', api_key: true do
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.14.1
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apiary Ltd.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-06 00:00:00.000000000 Z
11
+ date: 2021-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.4
33
+ version: 2.2.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.1.4
40
+ version: 2.2.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '2.1'
61
+ version: 2.3.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '2.1'
68
+ version: 2.3.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: launchy
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '2.0'
103
+ version: 2.2.11
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '2.0'
110
+ version: 2.2.11
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -201,6 +201,7 @@ extensions: []
201
201
  extra_rdoc_files: []
202
202
  files:
203
203
  - ".circleci/config.yml"
204
+ - ".editorconfig"
204
205
  - ".github/workflows/release.yml"
205
206
  - ".github/workflows/test.yml"
206
207
  - ".gitignore"
@@ -228,6 +229,7 @@ files:
228
229
  - lib/apiary.rb
229
230
  - lib/apiary/agent.rb
230
231
  - lib/apiary/cli.rb
232
+ - lib/apiary/command/archive.rb
231
233
  - lib/apiary/command/fetch.rb
232
234
  - lib/apiary/command/preview.rb
233
235
  - lib/apiary/command/publish.rb
@@ -256,11 +258,11 @@ files:
256
258
  - spec/spec_helper.rb
257
259
  - spec/support/aruba.rb
258
260
  - spec/support/webmock.rb
259
- homepage: http://apiary.io
261
+ homepage: https://apiary.io
260
262
  licenses:
261
263
  - MIT
262
264
  metadata: {}
263
- post_install_message:
265
+ post_install_message:
264
266
  rdoc_options: []
265
267
  require_paths:
266
268
  - lib
@@ -275,8 +277,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
277
  - !ruby/object:Gem::Version
276
278
  version: '0'
277
279
  requirements: []
278
- rubygems_version: 3.0.3
279
- signing_key:
280
+ rubygems_version: 3.1.2
281
+ signing_key:
280
282
  specification_version: 4
281
283
  summary: Apiary.io CLI
282
284
  test_files: