From 2f808c7926fcbf36c5d4e290a085a2c259c1716b Mon Sep 17 00:00:00 2001 From: David Wright <61992143+dw-bayer@users.noreply.github.com> Date: Thu, 17 Feb 2022 12:56:14 -0600 Subject: [PATCH] update to swagger-ui 4.5.0 (#34) * update to swagger-ui 4.5.0 * better html. --- README.md | 12 ++++---- src/resources/swagger-html.py | 47 +++++++++++++++-------------- src/resources/swagger-html.ts | 56 +++++++++++++++++++---------------- 3 files changed, 61 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 8dbdad2..3375e84 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ You can also run `sls generate-swagger` if you want to generate the swagger file ## Config Options -``` +```yaml custom: autoswagger: generateSwaggerOnDeploy?: true | false @@ -111,7 +111,7 @@ When you create a `POST` or `PUT` endpoint, you expect to receive a specific str You can do that by adding a `bodyType` to the http event: -``` +```js http: { path: 'hello', method: 'post', @@ -124,7 +124,7 @@ http: { If you want to specify the query string parameters on an endpoint you can do this by adding an object of `queryStringParameters` to the event (original I know). This has two required properties of `required` and `type` as well as an optional `description`. -``` +```js http: { path: 'goodbye', method: 'get', @@ -148,7 +148,7 @@ http: { If you use multi-value query string parameters (array), then you must specify that your `type` is `array` and specify your data type (string or integer) in `arrayItemsType` -``` +```js http: { path: 'goodbye', method: 'get', @@ -176,7 +176,7 @@ Works the same way as `queryStringParameters`, but for headers. To use it, just define it under `headerParameters`: -``` +```js http: { path: 'goodbye', method: 'get', @@ -198,7 +198,7 @@ http: { You can exclude some endpoints from the swagger generation by adding `exclude` to the http event: -``` +```js http: { path: 'hello', method: 'post', diff --git a/src/resources/swagger-html.py b/src/resources/swagger-html.py index a0fde2d..1d260cb 100644 --- a/src/resources/swagger-html.py +++ b/src/resources/swagger-html.py @@ -1,28 +1,31 @@ swagger_ui = """ - - + + + + + SwaggerUI + - -
- - - + + - - - + + +
+ """ diff --git a/src/resources/swagger-html.ts b/src/resources/swagger-html.ts index 4c8b35f..1f1d5cd 100644 --- a/src/resources/swagger-html.ts +++ b/src/resources/swagger-html.ts @@ -3,34 +3,38 @@ exports.handler = async () => { statusCode: 200, body: swaggerUI, headers: { - "content-type": "text/html", + 'content-type': 'text/html', }, - } -} + }; +}; const swaggerUI = ` - - + + + + + SwaggerUI + - -
- - - + + - - - -` + + +
+ + +`;