@mimik/api-helper 1.1.1 → 1.1.2
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 +2 -1
- package/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,11 +32,12 @@ Setup the API to be use for a service
|
|
|
32
32
|
- <code>Promise</code> An error is thrown if the initiatilization failed.
|
|
33
33
|
|
|
34
34
|
For the security schemes, the following scheme names are reserved: `SystemSecurity`, `AdminSecurity`, `UserSecurity`, `PeerSecurity`, `ApiKeySecurity`.
|
|
35
|
-
The secOptions in the options
|
|
35
|
+
The secOptions in the options property passed when using `init` allows the following operations:
|
|
36
36
|
- introduce a customer sevurity scheme, in this case secOptions contains: { newSecurityScheme: {function}newSecurityHandler },
|
|
37
37
|
- disable a security scheme that is defined in the swagger API, in this case secOptions contains: { securitySchemeToDisable: { {boolean}notEnabled: true } },
|
|
38
38
|
- overwite an existing security scheme, in this case secOptions contains: { securitySchemeToOverwrite: {function}newSecurityHandler }.
|
|
39
39
|
If the secOptions is not present either to introduce, disable or overwrite a security scheme that is present in the swagger API file an error is generated.
|
|
40
|
+
If the secOptions contains unused security schemes, an error is generated.
|
|
40
41
|
|
|
41
42
|
The default formats for validation are: `date`, `time`, `date-time`, `byte`, `uuid`, `uri`, `email`, `ipv4`, `ipv6`, `semver`, `ip`.
|
|
42
43
|
|
package/index.js
CHANGED
|
@@ -67,11 +67,12 @@ const {
|
|
|
67
67
|
* @throws {Promise} An error is thrown if the initiatilization failed.
|
|
68
68
|
*
|
|
69
69
|
* For the security schemes, the following scheme names are reserved: `SystemSecurity`, `AdminSecurity`, `UserSecurity`, `PeerSecurity`, `ApiKeySecurity`.
|
|
70
|
-
* The secOptions in the options
|
|
70
|
+
* The secOptions in the options property passed when using `init` allows the following operations:
|
|
71
71
|
* - introduce a customer sevurity scheme, in this case secOptions contains: { newSecurityScheme: {function}newSecurityHandler },
|
|
72
72
|
* - disable a security scheme that is defined in the swagger API, in this case secOptions contains: { securitySchemeToDisable: { {boolean}notEnabled: true } },
|
|
73
73
|
* - overwite an existing security scheme, in this case secOptions contains: { securitySchemeToOverwrite: {function}newSecurityHandler }.
|
|
74
74
|
* If the secOptions is not present either to introduce, disable or overwrite a security scheme that is present in the swagger API file an error is generated.
|
|
75
|
+
* If the secOptions contains unused security schemes, an error is generated.
|
|
75
76
|
*
|
|
76
77
|
* The default formats for validation are: `date`, `time`, `date-time`, `byte`, `uuid`, `uri`, `email`, `ipv4`, `ipv6`, `semver`, `ip`.
|
|
77
78
|
*/
|
|
@@ -121,6 +122,9 @@ const apiSetup = (setup, registeredOperations, securityHandlers, extraFormats, c
|
|
|
121
122
|
|
|
122
123
|
if (securityHandlers) {
|
|
123
124
|
const securityHandlerNames = Object.keys(securityHandlers);
|
|
125
|
+
const unusedSecuritySchemes = difference(securityHandlerNames, definedSecuritySchemes);
|
|
126
|
+
|
|
127
|
+
if (unusedSecuritySchemes.length !== 0) throw getRichError('System', 'unused handlers for security schemes', { unusedSecuritySchemes });
|
|
124
128
|
|
|
125
129
|
remainingSecurities.forEach((securityScheme) => {
|
|
126
130
|
if (!securityHandlerNames.includes(securityScheme) && !securityHandlers[securityScheme].notEnabled) {
|