Core API and message queue server of Triglav.
- Ruby >= 2.3.0
- MySQL >= 5.6
Copy config files and modify them if you want.
cp config/database.yml{.development,}
cp config/settings.yml{.development,}
cp config/secrets.yml{.development,}
cp db/seeds.rb{.development,}
./bin/rails db:create
./bin/rails db:apply # using ridgepole
./bin/rails db:seed
bundle exec foreman start
$ curl -H "Content-type: application/json" http://localhost:3000/api/v1/auth/token -X POST -d '{"username":"triglav_test", "password": "triglav_test", "authenticator":"local"}'
{"access_token":"xxxxxxxxxxxxxxxxxx","expires_at":1430458696}
$ curl -H "Content-type: application/json" -H "Authorization: xxxxxxxxxxxxxxxxxx" http://localhost:7800/api/v1/auth/me -X GET
Do migration with RAILS_ENV=test bundle exec rails db:create db:apply
, then
bundle exec rspec
You may generate API doc from requests spec as
AUTODOC=1 bundle exec rspec
You may run your tests with spring to make it faster to finish:
bundle exec spring binstubs rspec
bin/rspec
We use swagger to describe API specification. Write API doc on rails controllers, and serializers referring Swagger Documentation Specification v2.0.
swagger-ui is already bundled. You can start swagger-ui as
bundle exec rails s
and access to http://localhost:7800/apidocs. By the way, swagger-ui is a full javascript application, so serving this with nginx is also fine.
Authenticate with POST /auth/token
.
Click Try it out!
button, you will get an access token
Go to top bar of Swagger UI, and click Authorize
button.
Paste your access token to the value
field, then click Authorize.
Now, you should be able to hit any APIs.
To generate a static swagger.json, run
bundle exec rake swagger:generate
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.0/swagger-codegen-cli-2.2.0.jar -O bin/swagger-codegen-cli.jar
Generate ../triglav-client-ruby
bundle exec rails swagger:codegen-ruby
Generate ../triglav-client-java
bundle exec rails swagger:codegen-java
Generate both
bundle exec rails swagger:codegen
Edit VERSION
Release ../triglav-client-ruby
bundle exec rails release:client-ruby
Release ../triglav-client-java
bundle exec rails release:client-java
Release triglav
itself (tagging version)
bundle exec rails release:core
Release all
bundle exec rails release:all