You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
-
# Swagger Snippet
2
-
**Generates code snippets for given Swagger / Open API specification files.**
1
+
# OpenAPI Snippet
2
+
**Generates code snippets from Open API (previously Swagger) documents.**
3
3
4
-
This package takes as input a Swagger 2.0 / OpenAPI v3.0.x specification. It translates the specification into an [HTTP Archive 1.2 request object](http://www.softwareishard.com/blog/har-12-spec/#request). It uses the [HTTP Snippet](https://github.com/Mashape/httpsnippet) library to generate code snippets for every API endpoint (URL path + HTTP method) defined in the specification in various languages & tools (`cURL`, `Node`, `Python`, `Ruby`, `Java`, `Go`, `C#`...).
4
+
This package takes as input an OpenAPI v2.0 or v3.0.x document. It translates the document into an [HTTP Archive 1.2 request object](http://www.softwareishard.com/blog/har-12-spec/#request). It uses the [HTTP Snippet](https://github.com/Mashape/httpsnippet) library to generate code snippets for every API endpoint (URL path + HTTP method) defined in the specification in various languages & tools (`cURL`, `Node`, `Python`, `Ruby`, `Java`, `Go`, `C#`...), or for selected endpoints.
5
5
6
6
## Installation
7
7
8
8
```bash
9
-
npm i swagger-snippet
9
+
npm i openapi-snippet
10
10
```
11
11
12
-
## Build Swagger Snippet (for use in browser)
13
-
Clone the Swagger Snippet repository. Install required dependencies:
12
+
## Build OpenAPI Snippet (for use in browser)
13
+
Clone this repository. Install required dependencies:
14
14
15
15
```bash
16
16
npm i
17
17
```
18
18
19
-
Build a minified version of Swagger Snippet (`swaggersnippet.min.js`):
19
+
Build a minified version of OpenAPI Snippet (`openapisnippet.min.js`):
20
20
21
21
```bash
22
22
npm run build
@@ -27,44 +27,44 @@ npm run build
27
27
### As a module
28
28
29
29
```javascript
30
-
constSwaggerSnippet=require('swagger-snippet')
30
+
constOpenAPISnippet=require('openapi-snippet')
31
31
32
32
// define input:
33
-
constswagger=...//a Swagger / Open API specification
33
+
constopenApi=...// Open API document
34
34
consttargets= ['node_unirest', 'c'] // array of targets for code snippets. See list below...
35
35
36
36
try {
37
37
// either, get snippets for ALL endpoints:
38
-
constresults=SwaggerSnippet.getSwaggerSnippets(swagger, targets) // results is now array of snippets, see "Output" below.
38
+
constresults=OpenAPISnippet.getSnippets(openApi, targets) // results is now array of snippets, see "Output" below.
Use Swagger Snippet, which now defines the global variable `SwaggerSnippet`.
55
+
Use OpenAPI Snippet, which now defines the global variable `OpenAPISnippet`.
56
56
57
57
58
58
## Output
59
-
The output for every endpoint is an object, containing the `method`, `url`, a human-readable `description`, and the corresponding `resource` - all of these values stem from the specification. In addition, within the `snippets` list, an object containing a code snippet for every chosen target is provided. As of version `0.4.0`, the snippets include exemplary payload data.
59
+
The output for every endpoint is an object, containing the `method`, `url`, a human-readable `description`, and the corresponding `resource` - all of these values stem from the OpenAPI document. In addition, within the `snippets` list, an object containing a code snippet for every chosen target is provided. As of version `0.4.0`, the snippets include exemplary payload data.
60
60
61
-
If `getSwaggerSnippets` is used, an array of the above described objects is returned.
61
+
If `getSnippets` is used, an array of the above described objects is returned.
0 commit comments