serverless-openapi-documenter 0.0.97 → 0.0.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -942,16 +942,31 @@ This will set the `Cache-Control` Response Header to have a value of "no-store"
942
942
 
943
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
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
+
947
+ ### Rules
948
+
945
949
  I have configured the validator to use these Rules:
946
950
 
947
- * [spec](https://redocly.com/docs/cli/rules/spec/)
948
- * [path-parameters-defined](https://redocly.com/docs/cli/rules/path-parameters-defined/)
949
- * [operation-2xx-response](https://redocly.com/docs/cli/rules/operation-2xx-response/)
950
- * [operation-4xx-response](https://redocly.com/docs/cli/rules/operation-4xx-response/)
951
- * [operation-operationId-unique](https://redocly.com/docs/cli/rules/operation-operationid-unique/)
952
- * [path-declaration-must-exist](https://redocly.com/docs/cli/rules/path-declaration-must-exist/)
951
+ - [spec](https://redocly.com/docs/cli/rules/spec/)
952
+ - [path-parameters-defined](https://redocly.com/docs/cli/rules/path-parameters-defined/)
953
+ - [operation-2xx-response](https://redocly.com/docs/cli/rules/operation-2xx-response/)
954
+ - [operation-4xx-response](https://redocly.com/docs/cli/rules/operation-4xx-response/)
955
+ - [operation-operationId-unique](https://redocly.com/docs/cli/rules/operation-operationid-unique/)
956
+ - [path-declaration-must-exist](https://redocly.com/docs/cli/rules/path-declaration-must-exist/)
953
957
 
954
- 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.
958
+ However, you can configure your own rules from the [ruleset available on the Redocly site](https://redocly.com/docs/cli/rules/built-in-rules/). To do this, you will need to create a `redocly.json` file within an `options` folder. The file should look like:
959
+
960
+ ```json
961
+ {
962
+ "spec": "error",
963
+ "path-parameters-defined": "error",
964
+ "operation-2xx-response": "error",
965
+ "operation-4xx-response": "error",
966
+ "operation-operationId-unique": "error",
967
+ "path-declaration-must-exist": "error"
968
+ }
969
+ ```
955
970
 
956
971
  ## Example configuration
957
972
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-openapi-documenter",
3
- "version": "0.0.97",
3
+ "version": "0.0.100",
4
4
  "description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -69,6 +69,19 @@ class DefinitionGenerator {
69
69
  },
70
70
  };
71
71
 
72
+ try {
73
+ this.REDOCLY_RULES = require(path.resolve("options", "redocly.json"));
74
+ } catch (err) {
75
+ this.REDOCLY_RULES = {
76
+ spec: "error",
77
+ "path-parameters-defined": "error",
78
+ "operation-2xx-response": "error",
79
+ "operation-4xx-response": "error",
80
+ "operation-operationId-unique": "error",
81
+ "path-declaration-must-exist": "error",
82
+ };
83
+ }
84
+
72
85
  try {
73
86
  this.refParserOptions = require(path.resolve("options", "ref-parser.js"));
74
87
  } catch (err) {
@@ -1003,16 +1016,7 @@ class DefinitionGenerator {
1003
1016
  async validate() {
1004
1017
  const config = await createConfig({
1005
1018
  apis: {},
1006
- // styleguide: {
1007
- rules: {
1008
- spec: "error",
1009
- "path-parameters-defined": "error",
1010
- "operation-2xx-response": "error",
1011
- "operation-4xx-response": "error",
1012
- "operation-operationId-unique": "error",
1013
- "path-declaration-must-exist": "error",
1014
- },
1015
- // },
1019
+ rules: this.REDOCLY_RULES,
1016
1020
  });
1017
1021
 
1018
1022
  const apiDesc = stringifyYaml(this.openAPI);
@@ -0,0 +1,4 @@
1
+ {
2
+ "spec": "error",
3
+ "operation-2xx-response": "warn"
4
+ }