This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using the SwaggerJekyll DOM directly in Rails
This is still some pretty hackish code, but I wanted to see how it would work. Needs many improvements before it is merged.
- Loading branch information
Jacob Harris
committed
Jul 29, 2016
1 parent
1021d6d
commit 867e073
Showing
7 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class PagesController < ApplicationController | ||
before_action :load_swagger | ||
|
||
private | ||
|
||
def load_swagger | ||
path = Rails.root.join('public', 'api', 'v0', 'swagger.json') | ||
@swagger = SwaggerJekyll::Specification.load_json(path) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<p>This website is home to the documentation for 18F micro-purchase API.</p> | ||
|
||
From ["Open Source Micro-purchasing: An experiment in federal acquisition"](https://18f.gsa.gov/2015/10/13/open-source-micropurchasing/): | ||
|
||
> 18F is an open-source team. We currently have hundreds of publicly available repositories, with dozens under active development. We've had numerous contributions from colleagues within government, and contributions from members of the public. But in the next few weeks, we are going to run an experiment: we want to contract for contributions. And we want to do it the 18F way. | ||
|
||
Part of contracting the 18F way is ensuring that all systems are built modularly and with APIs as capable as the human interface. The [micro-purchase platform](https://micropurchase.18f.gov) itself is no exception. This means that all data and transactions that are accessible via the web UI can be accessed by software using the API. | ||
|
||
This website is written with three types of audience-members in mind: | ||
|
||
- micro-purchase participants (e.g. vendors bidding on auctions) | ||
- the general public (e.g. journalists or anyone else who might want to track auctions via API) | ||
- 18F staff (the API contains admin functionality reserved for certain 18F staff members) | ||
|
||
### Support | ||
|
||
If you are having trouble with the API, there are several ways to get help: | ||
|
||
- File an [issue](https://github.com/18F/micropurchase/issues/new). | ||
- Email us at micropurchase@gsa.gov. | ||
|
||
If there's anything missing or incorrect in the API documentation, please file an [issue](https://github.com/18F/micropurchase-api-docs/issues/new). | ||
|
||
As with any 18F API, it is our goal that the micro-purchase API adhere to our [API Standards](https://github.com/18f/api-standards). Please hold us accountable to these standards. | ||
|
||
### Current Version | ||
|
||
API requests should always include a version in the URL and older versions will eventually be deprecated after new versions are introduced. | ||
|
||
The current version of the API is still in alpha. | ||
|
||
<h3>Requests</h3> | ||
|
||
All API access is over HTTPS and uses the <code>micropurchase.18f.gov<%= @swagger.base_path %></code> base URL. All data is sent and received using JSON. | ||
|
||
<h3>Parameters</h3> | ||
|
||
Some requests to view specific items (like a single auction) take the auction ID as a parameter in the request URL. | ||
|
||
For bidding, the amount to be bid is submitted as the body of a POST request. They should be encoded as JSON with the following content type in the request headers: | ||
|
||
<pre> | ||
<code> | ||
Content-Type: application/json | ||
</code> | ||
</pre> | ||
|
||
### Client Errors | ||
|
||
Errors will contain the appropriate HTTP status code as well as a JSON response containing an `error` key: | ||
|
||
<pre> | ||
<code> | ||
{ | ||
"error": "Bid amount too high" | ||
} | ||
</code> | ||
</pre> | ||
|
||
<h3>Authentication</h3> | ||
|
||
<p>Currently all authentication occurs via the GitHub API. Rather than having the micro-purchase platform generate and store API keys, GitHub Personal API Tokens act as the API key. If you have created an account on the micro-purchase platform, you are signed up to use the API. All you need to do is generate a [GitHub Personal API Token](https://github.com/blog/1509-personal-api-tokens) (with no scopes) and put it in the request headers:</p> | ||
|
||
<pre> | ||
<code> | ||
Api-Key: the-personal-api-token | ||
</code> | ||
</pre> | ||
|
||
Note that many routes do not require any authentication at all. These docs will note the authentication options for each route. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<div class="usa-grid"> | ||
<% @swagger.paths.each do |path| %> | ||
|
||
<h3><%= path.path %></h3> | ||
|
||
<% path.verbs.each do |v| %> | ||
<h4><%= v.verb %></h4> | ||
|
||
<p><%= v.description %></p> | ||
|
||
<% if v.sample_response %> | ||
<p>Example response:</p> | ||
|
||
|
||
<%= v.sample_response%> | ||
<% end %> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Code</th> | ||
<th>Meaning</th> | ||
<th>Return Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% v.responses.each do |response| %> | ||
<tr> | ||
<td><%= response.code %></td> | ||
<td><%= response.description %></td> | ||
<td><%= response.compact_type %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<% end %> | ||
<% end %> | ||
|
||
<h3>Definitions</h3> | ||
|
||
<% @swagger.definitions.each do |definition| %> | ||
<h4><%= definition.name %></h4> | ||
|
||
<dl> | ||
<% definition.properties.each do |property| %> | ||
<dt><code><%= property.name %></code>, <em><%= property.compact_type %></em></dt> | ||
<dd><strong><%= property.title %>:</strong> <%= property.description %></dd> | ||
<% end %> | ||
</dl> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>Hi There!</h1> | ||
|
||
<%= @swagger.base_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters