Giter Site home page Giter Site logo

apiaryio / apiary-client Goto Github PK

View Code? Open in Web Editor NEW
205.0 27.0 75.0 456 KB

Apiary CLI client

Home Page: https://help.apiary.io/tools/apiary-cli/

License: MIT License

Ruby 91.15% HTML 3.23% Gherkin 4.99% API Blueprint 0.05% JavaScript 0.34% Dockerfile 0.25%
apiary

apiary-client's Introduction

Apiary CLI Client

Apiary CLI client, apiary.

Build Status Build status

Description

The Apiary CLI Client gem is a command line tool for developing and previewing API Blueprint documents locally. It can also be used for pushing updated documents to and fetching existing documents from Apiary.

Please see the apiary help command and the full documentation for an in-depth look in how to use this tool.

For instructions on making your own changes, see Hacking Apiary CLI Client, below.

Installation

Install as a Ruby gem

gem install apiaryio

Using Docker - alternative if you don't install ruby or installation not work for you

Download image:

docker pull apiaryio/client

Run instead apiary just docker run apiaryio/client

Build from source code:

docker build -t "apiaryio/client" .

Setup Apiary credentials

Required only for publish and fetch commands.

  1. Make sure you are a registered user of Apiary.
  2. Retrieve API key (token) on this page.
  3. Export it as an environment variable:
export APIARY_API_KEY=<your_token>

Command-line Usage

$ apiary help
Commands:
  apiary archive                      # Archive All Your API Description Documents from apiary.io to local files named following [api-project-subdomain.apib] pattern.
  apiary fetch --api-name=API_NAME    # Fetch API Description Document from API_NAME.docs.apiary.io
  apiary help [COMMAND]               # Describe available commands or one specific command
  apiary preview                      # Show API documentation in browser or write it to file
  apiary publish --api-name=API_NAME  # Publish API Description Document on API_NAME.docs.apiary.io (API Description must exist on apiary.io)
  apiary styleguide                   # Check API Description Document against styleguide rules (Apiary.io pro plan is required - https://apiary.io/plans )
  apiary version                      # Show version

Details

archive

$ apiary help archive
Usage:
  apiary archive

Options:
  [--exclude-team-projects], [--no-exclude-team-projects]  # Skip team projects

Archive All Your API Description Documents from apiary.io to local files named following [api-project-subdomain.apib] pattern.

fetch

$ apiary help fetch
Usage:
  apiary fetch --api-name=API_NAME

Options:
  --api-name=API_NAME  
  [--output=FILE]      # Write API Description Document into specified file

Fetch API Description Document from API_NAME.docs.apiary.io

preview

$ apiary help preview
Usage:
  apiary preview

Options:
  [--browser=BROWSER]        # Show API documentation in specified browser (full command is needed - e.g. `--browser='open -a safari'` in case of osx)
  [--output=FILE]            # Write generated HTML into specified file
  [--path=PATH]              # Specify path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file
  [--json], [--no-json]      # Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing
  [--server], [--no-server]  # Start standalone web server on port 8080
  [--port=PORT]              # Set port for --server option
  [--host=HOST]              # Set host for --server option
  [--watch], [--no-watch]    # Reload API documentation when API Description Document has changed

Show API documentation in browser or write it to file

publish

$ apiary help publish
Usage:
  apiary publish --api-name=API_NAME

Options:
  [--message=COMMIT_MESSAGE]  # Publish with custom commit message
  [--path=PATH]               # Specify path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file
  [--json], [--no-json]       # Specify that Swagger API Description Document is in json format. Document will be converted to yaml before processing
  [--push], [--no-push]       # Push API Description to the GitHub when API Project is associated with GitHub repository in Apiary
                              # Default: true
  --api-name=API_NAME         

Publish API Description Document on API_NAME.docs.apiary.io (API Description must exist on apiary.io)

styleguide

$ apiary help styleguide
Usage:
  apiary styleguide

Options:
  [--fetch], [--no-fetch]              # Fetch styleguide rules and functions from apiary.io
  [--push], [--no-push]                # Push styleguide rules and functions to apiary.io
  [--add=ADD]                          # Path to API Description Document. When given a directory, it will look for `apiary.apib` and `swagger.yaml` file
  [--functions=FUNCTIONS]              # Path to to the file with functions definitions
  [--rules=RULES]                      # Path to to the file with rules definitions - `functions.js` and `rules.json` are loaded if not specified
  [--full-report], [--no-full-report]  # Get passed assertions ass well. Only failed assertions are included to the result by default
  [--json], [--no-json]                # Outputs all in json

Check API Description Document against styleguide rules (Apiary.io pro plan is required - https://apiary.io/plans )

version

$ apiary help version
Usage:
  apiary version

Options:
  [--{:aliases=>"-v"}={:ALIASES=>"-V"}]  

Show version

Hacking Apiary CLI Client

Build

  1. If needed, install bundler:

    $ gem install bundler
  2. Clone the repo:

    $ git clone [email protected]:apiaryio/apiary-client.git
    $ cd apiary-client
  3. Install dependencies:

    $ bundle install

Test

Inside the apiary-client repository directory run:

$ bundle exec rspec spec
$ bundle exec cucumber

Release

Use bundle install to install your changes locally, for manual and ad-hock testing.

Only gem owners gem owner apiaryio can publish new gem into RubyGems.

  1. bump version in lib/apiary/version.rb

  2. update CHANGELOG.md

  3. prepare Github Release with text in CHANGELOG

  4. make gem release:

    $ git tag $VERSION
    $ git push --tags    
  • if release is stuck you need use $ rake release --trace to get OTP prompt.

License

Copyright 2012-17 (c) Apiary Ltd.

Released under MIT license. See LICENSE file for further details.

apiary-client's People

Contributors

abtris avatar almad avatar balupton avatar bootstraponline avatar custompro98 avatar edenvicary avatar eparreno avatar fgblomqvist avatar fosrias avatar freaz avatar honzajavorek avatar ilya-mim avatar iomoss-automata avatar jackub avatar jrep avatar kuba-kubula avatar kylef avatar matthewrudy avatar mojowill avatar opichals avatar peterstrapp-msm avatar pimpin avatar pksunkara avatar smizell avatar tinexw avatar w-vi avatar zdne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apiary-client's Issues

Preview shows old UI

I am using the beta version (3 column layout). There's no command to view my docs locally with this new layout.

Broken in windows, suggestions

A few issues prevent this from working in windows:

  • Hardcoded path to /tmp/. Instead:
require `tmpdir'
path = "#{Dir.tmpdir}/path/to/file"

could be used.

  • Hardcoded browser open string system("open file"). This could be replaced with OS sniffing to support a switch to start /b instead, or a gem dependency to launchy along with Launchy.open('tmpfile')

Also ran into an issue trying to read from/launch the preview file before the write block completed, but that may be due to other changes I'd made.

Will try to put together a pull request later, but unsure how the --browser switch strings in the command line ought to be handled without making the user specify the full path via config or ENV variables.

preview --output generates a broken HTML

Using

 preview --path ResourceModel.md --output ResourceModel.html

To generate a html results in an HTML where the GET and POST links are not clickable. In contrast, using the "--server" option results in a working result

apiary preview --path ResourceModel.md --server

Request timeout | Server broke connection

I'm having trouble with publishing my docs.
After executing this command
APIARY_API_KEY="mykey" apiary publish --path=API_DOCS.md --api-name='mydomain'
I get one of this errors
Apiary service responded with an error: Request Timeout
or
Apiary service responded with an error: Server broke connection

The internet connection is good, I tried execute the command many times during the day so I don't think that apiary server is down.

My file is large ~ 2.5 Mb. Could it be the reason? If yes how can I solve this?

libsnowcrash.so not found

Just installed this on a clean ubuntu 14.04 VM, and getting this error:

could not open library '/var/lib/gems/1.9.1/gems/redsnow-0.2.1/ext/snowcrash/build/out/Release/lib.target/libsnowcrash.so': /var/lib/gems/1.9.1/gems/redsnow-0.2.1/ext/snowcrash/build/out/Release/lib.target/libsnowcrash.so: cannot open shared object file: No such file or directory (LoadError)

I notice that the snowcrash library was recently updated. Could it be related? If not, any other ideas?

Preview --output Table of Contents Missing

I'm generating the docs locally with "preview --output", but it doesn't have the Table of Contents pane that is present on apiary hosting. I think the ToC is crucial to any documentation so I'd like to request this feature.

I also noticed the "preview --output option" is not shown in your readme.

Cheers,
Steven

Change API host

apiary preview --path
successfully creates a standalone version of the documentation. The only issue: The host in examples is set to apiary.io. Any chance to change that to what is provided by the mockdown entry "host"?

I would like to have my host in the examples, not apiary.io
curl --include
"http://apiary.io/api/v1/sites/"

Creating a new API at Apiary

An attempt to create a new API from a local apiary.apib file fails with

zdenek$ apiary publish --api-name=mynewapi123
Apiary service responded with an error: 404 Resource Not Found

Please provide the means to create a new API or at least, provide a clear information that API has to be first created manually at Apiary.

apiary publish

Be able to "apiary publish ".

This will create new API version in Apiary from arbitrary valid blueprint file.

Problems with fetch team api

apiary fetch –-api-name myapi // works

but when trying to fetch the team doc, it failed with 403 forbidden:

apiary fetch –-api-name teamapi1 // fails with 403

Ability to generate without the layout

Would be nice if we could get just the stuff in the left column.

Use case for this is to add an apiary blueprint plugin for docpad which we already use to generate our apiary blueprint file from CSON files (we render them to JSON and apply other abstractions).

Having this would allow us to use docpad to render the apiary blueprint as well.

Publish fails with exception `RestClient::InternalServerError`

I've been calling apiary publish for a while now, but it recently stopped working.

The command I use is:

apiary publish --api-name <redacted>

It now gives the following stack trace:

/Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!': 500 Internal Server Error (RestClient::InternalServerError)
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:230:in `process_result'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `block in transmit'
    from /Users/jeff/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/net/http.rb:627:in `start'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/rest-client-1.6.7/lib/restclient.rb:72:in `post'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/apiaryio-0.0.8/lib/apiary/command/publish.rb:60:in `query_apiary'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/apiaryio-0.0.8/lib/apiary/command/publish.rb:41:in `publish_on_apiary'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/apiaryio-0.0.8/lib/apiary/command/publish.rb:29:in `execute'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/apiaryio-0.0.8/lib/apiary/command/runner.rb:8:in `run'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/apiaryio-0.0.8/lib/apiary/cli.rb:16:in `run'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/apiaryio-0.0.8/lib/apiary/cli.rb:10:in `initialize'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/apiaryio-0.0.8/bin/apiary:5:in `new'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/gems/apiaryio-0.0.8/bin/apiary:5:in `<top (required)>'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/bin/apiary:19:in `load'
    from /Users/jeff/.rvm/gems/ruby-1.9.2-p136/bin/apiary:19:in `<main>'

As you can tell from the stack trace, this is with Ruby version 1.9.2-p136 and Apiary gem version 0.0.8.

Installation on Mac tries to overwrite something called `rake`

$ sudo gem install apiaryio
Password:
Fetching: rest-client-1.7.3.gem (100%)
Successfully installed rest-client-1.7.3
Fetching: rack-1.5.5.gem (100%)
Successfully installed rack-1.5.5
Fetching: rake-10.3.2.gem (100%)
rake's executable "rake" conflicts with /usr/bin/rake
Overwrite the executable? [yN]  N
ERROR:  Error installing apiaryio:
    "rake" from rake conflicts with /usr/bin/rake

Introducing redsnow broke apiary-client for Windows users

apiary-client does not install properly on Windows since we added redsnow/snowcrash into the gem.

(reported by: internal conversation)

Possible solutions:

  1. remove redsnow features for all installations of apiary-client
  2. remove redsnow features from Windows installations of apiary-client
  3. make redsnow installable on Windows

Hotfix solution for Windows users:

Downgrade to version 0.2.0 of apiary-client.

Feature request: Live preview with hot-reload

Is there a hidden configuration file that wasn't mentioned in the documentation? Currently live-reload is not working for me and I'm not sure where I should change those Babel settings.

apiary-console

I'm starting the preview server using apiary preview --path="src/api.apib" --server --port 8080

Apiary preview with `--server` showing nothing

What

I run apiary preview --server and go to localhost:8080. I see a blue-grey bar, but no content.

screen shot 2016-02-02 at 11 21 34 am

#### Further diagnostic
$ apiary preview --output tmp.html
$ open tmp.html
// Opens, I can see the output fine. 

$ apiary preview 
// Opens, I can see the output fine.

Reproduce

$ apiary preview --server

System

OSX 10.10.5, Chrome 48.

Apiary help inconsistent

arael-2:apis almad$ apiary help
Commands:
  apiary fetch --api-name=API_NAME    # Fetch apiary.apib from API_NAME.apiary.io
  apiary help [COMMAND]               # Describe available commands or one specific command
  apiary preview                      # Show API documentation in default browser
  apiary publish --api-name=API_NAME  # Publish apiary.apib on docs.API_NAME.apiary.io
  apiary version                      # Show version

This doesn't document full capabilities, nor is the thing declared in README.

Preview is not working

Hi,
I'm trying execute preview:

$ apiary preview
/var/lib/gems/1.9.1/gems/apiaryio-0.0.8/lib/apiary/command/preview.rb:81: warning: Insecure world writable dir /home/erik/Applications in PATH, mode 040777
Couldn't get a file descriptor referring to the console

other try:

$ apiary preview --path ./apiary.apib
/var/lib/gems/1.9.1/gems/apiaryio-0.0.8/lib/apiary/command/preview.rb:81: warning: Insecure world writable dir /home/erik/Applications in PATH, mode 040777
Couldn't get a file descriptor referring to the console

same result,..

I have the file apiary.apib in the current directory that I'm executing apiary preview.

Please Help, Regards.

Fetching an .apib file?

Hello!

Super stoked about Apiary - but I seem to be having some issues fetching the .apib file.

When I run apiary fetch --api-name { my api name }, it shows the content in the terminal, but it does not create a local file with the data.

Am I misunderstanding something?

Jsonp Response type not working

I tried using response type "application/javascript" for jsonp under multiple response for a single resource, but it doesn't seem to work with dredd though:

  • Response 200 (application/json; charset=utf-8)
    {
    ...
    }
  • Response 200 (application/javascript; charset=utf-8)
    {
    ...
    }

Is this currently supported?

Rack version too restrictive

the apiaryio gem depends on rack (~> 1.4.1)

But rails 4.0.2 (specifically actionpack 4.0.2) depends on rack (~> 1.5.2)

As such I can't add gem "apiaryio" and get the latest version.

Would it be possible to loosen the rack constraint, perhaps >= 1.4.0, < 1.6.0?

Add validation as a stand-alone command.

I understand that the blueprint is validated with redsnow before it's published. However, it would be nice to have the blueprint validated as a separate command so you could validate without publishing. This is especially useful if you're using apiaryio to put the blueprint under version control and want to validate your changes before committing.

Check apiary.apib files

Hi,

doing "apiary publish --api-name XXXX" I realized that when apiary.apib is not well formed, the command doesn´t throws any error but the file is not loaded into "apiary.io".
Is there any way to check that apiary.apib files are well done (using apiaryio gem)?

Regards.

Validate command line arguments

We're not validating command line arguments. For instance

$apiary preview -v

displays version, instead of display any sort of argument error message

Bug with unicode characters

I've simply exported apiary key, then:

apiary fetch --api-name=XXXX --output=apiary.apib

then

apiary preview

and got this error

I've opened apiary.apib file but it its encoding was fine except I had some Polish characters in sample Json responses. After changing all national characters ą to a, ś to s etc. no error appeared connected to file encoding.

When I had for example in sample json response:
"state": "śląskie",
I had this encoding error and after changing it into:
"state": "slaskie",

Preview Mock Server samples always use http://jsapi.apiary.io/ as hostname

I set HOST: http://localhost at the top of my blueprint but it seems to be ignored in the sample code. The host for the endpoint is set correctly at the top of the Example view, but it seems the host is ignored in all samples (cURL, PHP, Javascript) and is instead set to http://jsapi.apiary.io/previews/null/reference/...

Am I doing something wrong in my blueprint or is this a bug? I'm using apiary cli version 0.3.2.

Thanks.

Tab character in blueprint document crashes parser

apiary gem 0.0.8 crashes with error 400 if there's a tab character in the markdown.

% apiary preview --path doc/api-internal-blueprint.md 
/Library/Ruby/Gems/1.8/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!': 400 Bad Request (RestClient::BadRequest)

Blueprints won't load

Suddenly, some of my blueprints can't apiary publish, even though snowcrash and the app.apiary.io site like 'em just fine. I can't tell if this is a apiary-client issue or an app.apiary.io one.

Sample:

> apiary publish --path _site/api/luna/config-visitor-prioritization-data/blueprint.apib --api-name akamaiopen2lunaconfigvisitorprioritizationdatadev
Apiary service responded with an error: Blueprint you are trying to publish is not valid. Please validate with your snowcrash.

Yet:

> snowcrash -l _site/api/luna/config-visitor-prioritization-data/blueprint.apib

OK.

Versions:

> apiary version
0.2.4
> snowcrash -v
v0.16.1

Gist: https://gist.github.com/jrep/b462c73a1838cf99790d#file-blueprint-apib

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.