Skip to content

Commit af913ba

Browse files
Alan-ChaErikWittern
authored andcommitted
Fixed some problems with the documentation
Signed-off-by: Alan Cha <[email protected]>
1 parent 516f6fb commit af913ba

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ Turns APIs described by OpenAPI specifications (OAS) into GraphQL interfaces.
1212

1313
An example application exposing GitHub's public REST-like API via OASGraph can be found [here](https://oasgraph-github.mybluemix.net/) ([source code](https://github.ibm.com/apiharmony/oasgraph-oauth-github-example)).
1414

15+
1516
## Getting started
1617

1718
* [Quickstart guide](./docs/tutorials/quickstart.md): Learn how to quickly spin up GraphQL wrappers using the OASGraph CLI.
1819
* [Library tutorial](./docs/tutorials/watson.md): Learn how to use OASGraph as a library, and how to improve the resulting GraphQL wrappers using OAS `link` definitions.
1920
* [LoopBack tutorial](./docs/tutorials/loopback_tutorial.md): Learn how to use OASGraph to create GraphQL wrappers for APIs created with LoopBack 4.
2021

22+
2123
## Characteristics
2224

2325
* **Data-centric**
@@ -95,19 +97,30 @@ OASGraph.createGraphQlSchema(oas)
9597

9698
***
9799

98-
Alternatively, use the CLI tool.
100+
Alternatively, use the CLI tool, which will run OASGraph on a specified OAS and start a server to host the GraphQL interface.
99101

100-
```
101-
Usage: oasgraph <OAS JSON file path>
102+
You can specify a local file containing the OAS specification or a remote url such as `http://127.0.0.1:3000/openapi.json`. Additionally, you can specify an optional port number so you can have multiple GraphQL servers for testing in the same machine.
103+
104+
```sh
105+
oasgraph <OAS JSON file path or remote url> [port number]
102106
```
103107

104108
To create the CLI tool, run:
105-
```
109+
```sh
106110
npm link
107111
```
108112

109113
Please note that the CLI tool is mainly used for quick testing and does not offer all the features that `createGraphQlSchema(oas, options)` does.
110114

115+
***
116+
117+
OASgraph can also generate and save the GraphQL schema to the local file `schema.graphql`, which you can use later to inspect or change its content. Please note that the following command will not start the GraphQL server.
118+
119+
```sh
120+
oasgraph <OAS JSON file path or remote url> --save
121+
```
122+
123+
111124
## Options
112125
OASGraph allows to define an optional `options` object:
113126

@@ -187,13 +200,15 @@ OASGraph further provides `anyAuth` viewers (for queries and mutations), which a
187200
}
188201
```
189202

203+
190204
## Authorization
191205
OASGraph now supports OAuth 2.0!
192206

193207
Because OASGraph is a library, it cannot make the callbacks that OAuth requires by itself. Instead, the user must take care of the callback. After the user has obtained the OAuth token from the callback, simply pass the token, specifically the path of the token, to OASGraph through the `tokenJSONpath` [option](./README.md#options).
194208

195209
To see an example of how this would work, click [here](https://github.ibm.com/apiharmony/oasgraph-oauth-github-example)!
196210

211+
197212
## Testing
198213
To test OASGraph, run:
199214

@@ -203,7 +218,8 @@ npm test
203218

204219
This command will temporarily start and later shut down an example REST(-like) API.
205220

206-
### Research
221+
222+
## Research
207223
Our research paper, "Generating GraphQL-Wrappers for REST(-like) APIs", can be found [here](https://arxiv.org/abs/1809.08319). The paper describes the challenges of building OASGraph and an experiment in which we evaluated OASGraph against 959 publicly available OAS, provided by [APIs.guru](https://apis.guru/), and successfully created GraphQL interfaces for 89.5% of them.
208224

209225
To run the experiment, load APIs.guru specifications, found [here](https://github.com/APIs-guru/openapi-directory), into the `/tmp` folder:
@@ -245,5 +261,6 @@ OASGraph is written in [TypeScript](http://www.typescriptlang.org/). All source
245261

246262
* [StackOverflow discussion](https://stackoverflow.com/questions/38339442/json-schema-to-graphql-schema-converters) points to the above projects.
247263

264+
248265
## License
249266
[MIT](./LICENSE.md)

docs/tutorials/quickstart.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The purpose of this tutorial is to show how easy it is to use OASGraph.
44

5-
With just a single command line instruction, `oasgraph [path]`, you can get a GraphQL server running.
5+
With just a single command line instruction, `oasgraph <OAS JSON file path or remote url>`, you can get a GraphQL server running.
66

77
Please note that while the CLI tool will satisfy most needs, it does not offer the flexibility or functionality of OASGraph's intended usage, as an integrated library. See the [README.md](../../README.md) for more information.
88

@@ -34,30 +34,21 @@ OASGraph relies on the OpenAPI Specification (OAS) of an existing API to create
3434

3535
If you are using LoopBack, you can simply copy the URL location of the web-hosted OAS, which is usually http://127.0.0.1:3000/openapi.json.
3636

37-
# in the LoopBack project folder:
38-
3937
```sh
38+
# in the LoopBack project folder:
4039
npm start
4140
```
4241

4342
***
4443

45-
If you want to generate a GraphQL interface for another API, make sure that API is running and proceed in the same way.
44+
If you want to generate a GraphQL interface for another API, make sure that API is running and proceed in the same way or save the OAS.
4645

4746
### Start GraphQL server
4847

4948
Once OASGraph is installed and the OAS is obtained, you can create and start the GraphQL server. The created GraphQL server is then accessible by default at [http://127.0.0.1:3001/graphql](http://127.0.0.1:3001/graphql).
5049

51-
You can specify a local file containing the OAS specification or a remote url such as `http://127.0.0.1:3000/openapi.json` and an optional port number, this way you can have multiple GraphQL servers for testing in the same machine.
50+
You can specify a local file containing the OAS specification or a remote url such as `http://127.0.0.1:3000/openapi.json`. Additionally, you can specify an optional port number so you can have multiple GraphQL servers for testing in the same machine.
5251

5352
```sh
5453
oasgraph <OAS JSON file path or remote url> [port number]
5554
```
56-
57-
### Export a GraphQL schema
58-
59-
OASgraph can also generate and save the GraphQL schema to the local file `schema.graphql`, which you can use later to inspect or change its content in the editor of your choice. Please note that the following command will not start the GraphQL server.
60-
61-
```sh
62-
oasgraph <OAS JSON file path or remote url> --save
63-
```

0 commit comments

Comments
 (0)