-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(inital commit): the initial commit
- Loading branch information
0 parents
commit 624e4b4
Showing
14 changed files
with
23,235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# package directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Serverless directories | ||
.serverless | ||
.dynamodb | ||
.serverless | ||
|
||
# Webpack directories | ||
.webpack | ||
|
||
.serverless | ||
build | ||
|
||
.DS_Store | ||
|
||
# Compiled Code | ||
dist | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
__tests__ | ||
node_modules | ||
src | ||
jest.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Serverless Auto Swagger | ||
|
||
This plugin allows you to automatically generate a swagger endpoint, describing your application endpoints. | ||
|
||
## Usage | ||
|
||
This plugin is designed to work with vanilla Serverless Framework. All you need to do is add this plugin to your plugin list and it will generate the swagger file and add the endpoints required. Your new swagger UI will be available at `https://{your-url-domain}/swagger`. | ||
|
||
### Adding more details | ||
|
||
The default swagger file from vanilla Serverless framework will have the correct paths and methods but no details about the data. | ||
|
||
#### Adding Data Types | ||
|
||
This plugin uses typescript types to generate the data types for the endpoints. By default it pulls the types from `src/types/api-types.d.ts`. | ||
|
||
You can then assign these typescript definition to post requests | ||
|
||
#### Responses | ||
|
||
You can now add responses to each of the http endpoint events. This is an object that contains the response code with some example details: | ||
|
||
```js | ||
responses: { | ||
// response with description and response body | ||
200: { | ||
description: 'this went well', | ||
bodyType: 'helloPostResponse', | ||
}, | ||
|
||
// response with just a description | ||
400: { | ||
description: 'failed Post', | ||
}, | ||
// shorthand for just a description | ||
502: 'server error', | ||
} | ||
``` | ||
|
||
### with Serverless Offline | ||
|
||
In the plugin list, you must list serverless-auto-swagger before the serverless-offline plugin. If you don't you won't get the required endpoints added to your local endpoints. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { recursiveFixAnyOf } from '../src/index'; | ||
|
||
describe('test of recursiveFixAnyOf', () => { | ||
test('without AnyOf', () => { | ||
const definition: { [key: string]: Definition } = { | ||
helloPostBody: { | ||
properties: { | ||
hello: { | ||
properties: { | ||
there: { | ||
properties: { | ||
everyone: { | ||
type: 'string', | ||
}, | ||
}, | ||
required: ['everyone'], | ||
additionalProperties: false, | ||
type: 'object', | ||
}, | ||
}, | ||
required: ['there'], | ||
additionalProperties: false, | ||
type: 'object', | ||
}, | ||
date: { | ||
type: 'number', | ||
}, | ||
number: { | ||
type: 'number', | ||
}, | ||
people: { | ||
items: { | ||
$ref: '#/components/schema/People', | ||
}, | ||
type: 'array', | ||
}, | ||
}, | ||
required: ['hello', 'date', 'number', 'people'], | ||
additionalProperties: false, | ||
type: 'object', | ||
}, | ||
}; | ||
|
||
const result = recursiveFixAnyOf(definition); | ||
|
||
expect(result).toMatchObject(definition); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
roots: ['<rootDir>/src'], | ||
testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'], | ||
transform: { | ||
'^.+\\.(ts|tsx)$': 'ts-jest', | ||
}, | ||
}; |
Oops, something went wrong.