Skip to content

Commit 6d406f3

Browse files
authored
Merge pull request #152 from JaredCE/switch-to-redocly
Switch to redocly
2 parents 6b946b1 + bbb21f0 commit 6d406f3

File tree

8 files changed

+295
-111
lines changed

8 files changed

+295
-111
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ To Run: `serverless openapi generate -o openapi.json -f json -a 3.0.3 -p postman
4444
Options:
4545

4646
```
47-
--output -o What filename the OpenAPI documentation should output under. Default: openapi.json
48-
--format -f Whether to output the OpenAPI documentation as json or yaml. Default: json
47+
--output -o What filename the OpenAPI Description should output under. Default: openapi.json
48+
--format -f Whether to output the OpenAPI Description as json or yaml. Default: json
4949
--indent -i File indentation in spaces. Default: 2
5050
--openApiVersion -a OpenAPI version to generate for. Default: 3.0.0
51-
--postmanCollection -p Will generate a postman collection (from the generated openAPI documentation), in json only, if passed in. Default postman.json
51+
--postmanCollection -p Will generate a postman collection (from the generated OpenAPI Description), in json only, if passed in. Default postman.json
5252
--validationWarn -w Warn about validation errors only. Will write the OpenAPI file if generation is successful. Default: false
5353
```
5454

@@ -71,6 +71,10 @@ Options:
7171
- [CORS](#cors)
7272
- [OWASP Secure Headers](#owasp)
7373

74+
#### Validation
75+
76+
- [Validation](#validator)
77+
7478
### OpenAPI Mapping
7579

7680
| OpenAPI field | Serverless field |
@@ -133,7 +137,7 @@ Options:
133137

134138
### Configuration
135139

136-
To configure this plugin to generate valid OpenAPI documentation there are two places you'll need to modify in your `serverless.yml` file, the `custom` variables section and the `http/httpApi` event section for each given function in your service.
140+
To configure this plugin to generate a valid OpenAPI Description, there are two places you'll need to modify in your `serverless.yml` file, the `custom` variables section and the `http/httpApi` event section for each given function in your service.
137141

138142
The `custom` section of your `serverless.yml` can be configured as below:
139143

@@ -934,6 +938,12 @@ methodResponse:
934938

935939
This will set the `Cache-Control` Response Header to have a value of "no-store" rather than any value the OWASP Secure Headers Project recommends.
936940

941+
## Validator
942+
943+
Validation for the OpenAPI Description is now (as of 0.0.90) done by [Redocly](https://redocly.com/). This is a slightly less opinionated validator for an OpenAPI Description, it should result in less errors around "YAML Anchors". It's also a maintained library, and has support for OpenAPI 3.1.0 which I hope to be able to support very soon.
944+
945+
I am making use of https://www.npmjs.com/package/@redocly/openapi-core, which I have been warned is likely to change. If you notice anything going wrong with validation of your OpenAPI Description, feel free to open an issue here. I make active use of this library, so will hopefully come across those issues too.
946+
937947
## Example configuration
938948

939949
Please view the example [serverless.yml](test/serverless-tests/best/serverless.yml).
@@ -975,7 +985,7 @@ We use the plugin [JSON Schema $Ref Parser](https://apitools.dev/json-schema-ref
975985
}
976986
```
977987

978-
Where the definition "link" refers to a schema held in a directory that the resolver does not know about, we will not be able to fully resolve the schema which will likely cause errors in validation of the openAPI 3.0.X specification.
988+
Where the definition "link" refers to a schema held in a directory that the resolver does not know about, we will not be able to fully resolve the schema which will likely cause errors in validation of the OpenAPI 3.0.X Description.
979989

980990
Because of the dependency we use to parse externally linked schemas, we can supply our own options to resolve schemas that are more difficult than a straight forward example.
981991

package-lock.json

Lines changed: 124 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-openapi-documenter",
3-
"version": "0.0.84",
3+
"version": "0.0.90",
44
"description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
55
"main": "index.js",
66
"keywords": [
@@ -38,11 +38,11 @@
3838
"license": "MIT",
3939
"dependencies": {
4040
"@apidevtools/json-schema-ref-parser": "^9.1.0",
41+
"@redocly/openapi-core": "^1.2.0",
4142
"chalk": "^4.1.2",
4243
"js-yaml": "^4.1.0",
4344
"json-schema-for-openapi": "^0.4.1",
4445
"lodash.isequal": "^4.5.0",
45-
"oas-validator": "^5.0.8",
4646
"openapi-to-postmanv2": "^4.18.0",
4747
"swagger2openapi": "^7.0.8",
4848
"uuid": "^9.0.0"

0 commit comments

Comments
 (0)