Skip to content

Commit 8457852

Browse files
committed
Add readme
1 parent 6620492 commit 8457852

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

README.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,60 @@
1-
api
1+
oai
22
===
33

4-
A tool that makes APIs simple
4+
Creating Swagger files is hard. This makes it easier.
5+
6+
**Made by ReadMe!** Need great hosting for your API? [Check us out!](http://readme.io)
57

68
Installation
79
------------
810

9-
npm install api -g
11+
npm install oai -g
12+
13+
Usage
14+
-----
15+
16+
Go to a directory with your API, and type:
17+
18+
oai init
19+
20+
It will walk you through how to document your API with Open API Initiave.
21+
22+
Swagger Inline
23+
--------------
24+
25+
Rather than trying to juggle one gigantic repo, `oai` uses something called
26+
[swagger-inline](https://github.com/readmeio/swagger-inline). It lets you include
27+
a little swagger snippet in a comment above your code, and collects them all
28+
together into one Swagger file:
29+
30+
```javascript
31+
/*
32+
* @api [get] /pet/{petId}
33+
* description: "Returns all pets from the system that the user has access to"
34+
* parameters:
35+
* - (path) petId=hi* {String} The pet ID
36+
* - (query) limit {Integer:int32} The number of resources to return
37+
*/
38+
route.get("/pet/:petId", pet.show);
39+
```
40+
41+
You need to start with `@api [method] path`, but everything below it is a valid
42+
[Swagger Path Definition](http://swagger.io/specification/#pathItemObject).
43+
44+
You can also do **inline parameters**, which are shorthand for parameters. They
45+
aren't valid Swagger, however Swagger Inline knows how to compile them:
46+
47+
```
48+
- (in) name=default* {type:format} Description
49+
```
50+
51+
Host your Swagger file
52+
----------------------
53+
54+
Hosting Swagger files is hard! So, we have an online component that hosts your
55+
Swagger file for you. Just type the following to get a URL:
56+
57+
oai host
58+
59+
This will upload your Swagger file and give you a URL you can use.
1060

11-
This is under heavy work now... don't worry, it will be documented eventually!

0 commit comments

Comments
 (0)