Skip to content

Commit b702c6a

Browse files
committed
Add a README
1 parent 4af9cc8 commit b702c6a

1 file changed

Lines changed: 129 additions & 1 deletion

File tree

README.md

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,129 @@
1-
# OpenAPI-AWS-Decorator
1+
# OpenAPI-AWS-Decorator
2+
3+
<p>
4+
<a href="https://www.npmjs.com/package/openapi-aws-decorator">
5+
<img src="https://img.shields.io/npm/v/openapi-aws-decorator.svg?style=flat-square">
6+
</a>
7+
<a href="https://github.com/JaredCE/OpenAPI-AWS-Decorator/actions/workflows/node.yml">
8+
<img src="https://github.com/JaredCE/OpenAPI-AWS-Decorator/actions/workflows/node.yml/badge.svg">
9+
</a>
10+
</p>
11+
12+
This will decorate an Open API v3 document with specific `x-amazon-` OpenAPI syntax.
13+
14+
## Install
15+
16+
To install:
17+
**Using npm:**
18+
19+
```bash
20+
npm install openapi-aws-decorator
21+
```
22+
23+
## Usage
24+
25+
### x-amazon-apigateway-documentation
26+
27+
To decorate an OpenAPI file with `x-amazon-apigateway-documentation`, which are [Documentation Parts](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-documenting-api-content-representation.html#api-gateway-documenting-api-content-representation-documentation-parts) you can run this code:
28+
29+
```js
30+
const OpenAPIDecorator = require("openapi-aws-decorator");
31+
32+
const openAPI = {
33+
openapi: "3.0.1",
34+
info: {
35+
description:
36+
"The Data Set API (DSAPI) allows the public users to discover and search USPTO exported data sets. This is a generic API that allows USPTO users to make any CSV based data files searchable through API. With the help of GET call, it returns the list of data fields that are searchable. With the help of POST call, data can be fetched based on the filters on the field names. Please note that POST call is used to search the actual data. The reason for the POST call is that it allows users to specify any complex search criteria without worry about the GET size limitations as well as encoding of the input parameters.",
37+
version: "1.0.0",
38+
title: "USPTO Data Set API",
39+
contact: {
40+
name: "Open Data Portal",
41+
url: "https://developer.uspto.gov",
42+
email: "developer@uspto.gov",
43+
},
44+
},
45+
paths: {
46+
"/": {
47+
get: {
48+
operationId: "list-data-sets",
49+
summary: "List available data sets",
50+
responses: {
51+
200: {
52+
description: "Returns a list of data sets",
53+
content: {
54+
"application/json": {
55+
schema: {
56+
$ref: "#/components/schemas/responseData",
57+
},
58+
},
59+
},
60+
},
61+
},
62+
},
63+
},
64+
},
65+
components: {
66+
schemas: {
67+
responseData: {
68+
type: "string",
69+
},
70+
},
71+
},
72+
};
73+
74+
const openAPIDecorator = new OpenAPIDecorator(openAPI);
75+
openAPIDecorator.decorate();
76+
77+
console.log(openAPIDecorator.openAPI);
78+
```
79+
80+
This will end up with the original OpenAPI document containing a new property section of `x-amazon-apigateway-documentation` with the various Documentation Parts listed out.
81+
82+
```json
83+
{
84+
"openapi": "3.0.1",
85+
"info": {
86+
"description": "The Data Set API (DSAPI) allows the public users to discover and search USPTO exported data sets. This is a generic API that allows USPTO users to make any CSV based data files searchable through API. With the help of GET call, it returns the list of data fields that are searchable. With the help of POST call, data can be fetched based on the filters on the field names. Please note that POST call is used to search the actual data. The reason for the POST call is that it allows users to specify any complex search criteria without worry about the GET size limitations as well as encoding of the input parameters.",
87+
"version": "1.0.0",
88+
"title": "USPTO Data Set API",
89+
"contact": {
90+
"name": "Open Data Portal",
91+
"url": "https://developer.uspto.gov",
92+
"email": "developer@uspto.gov"
93+
}
94+
},
95+
...
96+
"x-amazon-apigateway-documentation": {
97+
"version": "1.0.0",
98+
"documentationParts": [
99+
{
100+
"location": { "type": "API" },
101+
"properties": {
102+
"description": "The Data Set API (DSAPI) allows the public users to discover and search USPTO exported data sets. This is a generic API that allows USPTO users to make any CSV based data files searchable through API. With the help of GET call, it returns the list of data fields that are searchable. With the help of POST call, data can be fetched based on the filters on the field names. Please note that POST call is used to search the actual data. The reason for the POST call is that it allows users to specify any complex search criteria without worry about the GET size limitations as well as encoding of the input parameters.",
103+
"version": "1.0.0",
104+
"title": "USPTO Data Set API",
105+
"contact": {
106+
"name": "Open Data Portal",
107+
"url": "https://developer.uspto.gov",
108+
"email": "developer@uspto.gov"
109+
}
110+
}
111+
},
112+
{ "location": { "type": "RESOURCE", "path": "/" }, "properties": {} },
113+
{
114+
"location": { "type": "METHOD", "path": "/", "method": "get" },
115+
"properties": { "summary": "List available data sets" }
116+
},
117+
{
118+
"location": {
119+
"path": "/",
120+
"method": "get",
121+
"statusCode": "200",
122+
"type": "RESPONSE"
123+
},
124+
"properties": { "description": "Returns a list of data sets" }
125+
}
126+
]
127+
}
128+
}
129+
```

0 commit comments

Comments
 (0)