Skip to content

Commit c2a766e

Browse files
authored
Merge pull request #1 from JaredCE/document-parts
Document parts
2 parents f49783d + 8244804 commit c2a766e

File tree

14 files changed

+2879
-1
lines changed

14 files changed

+2879
-1
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: "[BUG]"
5+
labels: ""
6+
assignees: JaredCE
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
```json
16+
{
17+
"openapi": "3.0.1"
18+
}
19+
```
20+
21+
**Expected behavior**
22+
A clear and concise description of what you expected to happen.
23+
24+
**Additional context**
25+
Add any other context about the problem here.

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"

.github/workflows/node.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: ["main"]
9+
pull_request:
10+
branches: ["main"]
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [14.x, 16.x, 18.x, 20.x]
19+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
cache: "npm"
28+
- run: npm ci
29+
- run: npm run build --if-present
30+
- run: npm test

.github/workflows/npm-publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-node@v3
16+
with:
17+
node-version: 18
18+
- run: npm ci
19+
# - run: npm test
20+
21+
publish-npm:
22+
needs: build
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
- uses: actions/setup-node@v3
27+
with:
28+
node-version: 18
29+
registry-url: https://registry.npmjs.org/
30+
- run: npm ci
31+
- run: npm publish
32+
env:
33+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/*

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+
```

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const OpenAPIDecorator = require("./src/OpenAPIDecorator");
2+
3+
module.exports = OpenAPIDecorator;

0 commit comments

Comments
 (0)