Skip to content

Commit 94bf004

Browse files
committed
Update README
1 parent 92f6c6e commit 94bf004

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all build deps generate help test validate js
1+
.PHONY: all build deps generate help test validate
22
CHECK_FILES?=$$(go list ./... | grep -v /vendor/)
33

44

@@ -23,6 +23,3 @@ test: ## Test the go code.
2323

2424
validate: ## Check that the swagger spec is valid.
2525
swagger validate swagger.yml
26-
27-
js: ## Generate the node module.
28-
npm i

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,34 @@ You can use this command to generate the Go client:
2828

2929
You may first want to edit swagger.yml to add your field or endpoint definitions.
3030

31-
## Node Client
31+
## JS Client
3232

33-
In order to generate the Node client, you must install Java 8 and the swagger-codegen tool.
33+
Swagger's JS client can dynamically create a client from a spec either from a URL or spec object.
3434

35-
1. You will need java8 (or 7) to run the code-gen
35+
See [swagger-js](https://github.com/swagger-api/swagger-js)
3636

37-
```bash
38-
# install java 8 via homebrew
39-
brew cask install homebrew/cask-versions/java8
40-
```
4137

38+
### Usage
39+
```js
40+
<script src='browser/swagger-client.js' type='text/javascript'></script>
41+
<script>
42+
var swaggerClient = new SwaggerClient('https://open-api.netlify.com/swagger.json');
43+
</script>
44+
```
4245

43-
2. Then install swagger codegen
46+
You can also consume the swagger spec as an npm module:
4447

45-
```bash
46-
# install code-gen via homebrew
47-
brew install swagger-codegen
48-
```
48+
```console
49+
$ npm install @netlify/open-api
50+
# or
51+
$ yarn add @netlify/open-api
52+
```
4953

50-
3. Generate the library
54+
```js
55+
import spec from '@netlify/open-api' // import the spec object into your project
56+
```
5157

52-
```console
53-
$ make node
54-
```
55-
56-
The `swagger-codegen` generates an entire module in the `node` folder. You can publish new versions of the client from that folder with `npm publish`.
58+
The module also ships a copy of the original `yml` spec file at `@netlify/open-api/swagger.yml`.
5759

5860
## Explore API
5961

0 commit comments

Comments
 (0)