department-of-veterans-affairs/vets-api

Name: vets-api

Owner: Department of Veterans Affairs

Description: API for vets.gov

Created: 2016-07-01 17:33:19.0

Updated: 2018-05-24 15:45:48.0

Pushed: 2018-05-24 15:52:29.0

Homepage: null

Size: 71377

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Vets.gov API Build Status

This project provides common APIs for applications that live on vets.gov.

Base setup

See the native setup instructions if you can't use docker

To start, fetch this code:

git clone https://github.com/department-of-veterans-affairs/vets-api.git

  1. Install Docker for Mac. This will configure both docker and docker-compose.
  2. Setup localhost certificates / keys:
  3. Create a folder in your vets-api directory: mkdir config/certs
  4. Copy the certificate to config/certs/vetsgov-localhost.crt
  5. Copy the key to config/certs/vetsgov-localhost.key
  6. NOTE: using touch to create blank cert and key files no longer works. If you previously added certs in this manner replace them with the team repo certificate and key listed above.
Running the app

A Makefile provides shortcuts for interacting with the docker images. To run vets-api and its redis and postgres dependencies run the following command from within the repo you cloned in the above steps.

 up

You should then be able to navigate to http://localhost:3000/v0/status in your browser and start interacting with the API. Changes to the source in your local directory will be reflected automatically via a docker volume mount, just as they would be when running rails directly.

The Makefile has shortcuts for many common development tasks. You can still run manual docker-compose commands, but the following tasks have been aliased to speed developlment:

Running tests
Running linters
Running a rails interactive console
Running a bash shell

To emulate a local install's workflow where you can run rspec, rake, or rails commands directly within the vets-api docker instance you can use the make bash command.

ke bash
ting network "vetsapi_default" with the default driver
ting vetsapi_postgres_1 ... done
ting vetsapi_redis_1    ... done
en run any command as you would locally e.g.
@63aa89d76c17:/src/vets-api# rspec spec/requests/user_request_spec.rb:26
Configuration

Vets API is configured with Config. The default configuration is contained in settings.yml. To customize your setup, you can create a config/settings.local.yml file with configuration specific to your needs. For example, to configure Redis and PostgreSQL, place something like this in that file:

base_url: postgres://pg_host:9999/custom_db

s:
st: redis_host
rt: 9999

This is also where you will place any other customizations, such as API tokens or certificate paths.

Optional application configuration

The following features require additional configuration, click for details.

To mock one or more of the above services see Betamocks

Vets API will still run in a limited capacity without configuring any of these features, and will run the unit tests successfully.

Troubleshooting
make up fails with a message about missing gems
d not find %SOME_GEM_v0.0.1% in any of the sources
`bundle install` to install missing gems.

There is no need to run bundle install on your system to resolve this. A rebuild of the vets_api image will update the gems. The vets_api docker image installs gems when the image is built, rather than mounting them into a container when it is run. This means that any time gems are updated in the Gemfile or Gemfile.lock, it may be necessary to rebuild the vets_api image using the following command:

Deployment instructions

Jenkins deploys vets-api upon each merge to master:

http://jenkins.vetsgov-internal/job/department-of-veterans-affairs/job/vets-api/job/master/

Each deploy is available here:

https://dev-api.vets.gov/v0/status

API request key formatting

When sending HTTP requests use the X-Key-Inflection request header to specify which case your client wants to use. Valid cases are camel, dash, and snake. For example if you set X-Key-Inflection: camel then you can use camelCase keys in your JSON request body and you will get back data with camelCase keys in the response body. If the header is not provided then the server will expect snake_case keys in the request body and output snake_case in the response.

How to contribute

There are many ways to contribute to this project:

Bugs

If you spot a bug, let us know! File a GitHub Issue for this project. When filing an issue add the following:

For security related bugs unfit for public viewing, email us feedback@va.gov

Code Submissions

This project logs all work needed and work being actively worked on via GitHub Issues. Submissions related to these are especially appreciated, but patches and additions outside of these are also great.

If you are working on something related to an existing GitHub Issue that already has an assignee, talk with them first (we don't want to waste your time). If there is no assignee, assign yourself (if you have permissions) or post a comment stating that you're working on it.

To work on your code submission, follow GitHub Flow:

  1. Branch or Fork
  2. Commit changes
  3. Submit Pull Request
  4. Discuss via Pull Request
  5. Pull Request gets approved or denied by core team member

If you're from the community, it may take one to two weeks to review your pull request. Teams work in one to two week sprints, so they need time to need add it to their time line.

Contact

If you have a question or comment about this project, file a GitHub Issue with your question in the Title, any context in the Comment, and add the question Label.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.