@checkdigit/spectral-config 3.1.0-PR.24-701d → 3.1.0-PR.26-2219

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
@@ -54,3 +54,7 @@ Set Included files to the following glob pattern `**/*swagger.yml`.
54
54
  Install Spectral, by Spotlight https://marketplace.visualstudio.com/items?itemName=stoplight.spectral
55
55
 
56
56
  ### Rules for Certain Warnings and Errors
57
+
58
+ `operation-operationId Operation must have "operationId"`
59
+
60
+ Add an operationId to the operation. Check Digit uses a `noun-noun-verb` naming convention. For example, the correct operationId for a `PUT` to path `/resource/{id}/item/{itemId}/key` is `resource-item-key-put`
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@checkdigit/spectral-config","version":"3.1.0-PR.24-701d","private":false,"description":"Check Digit Spectral Config","homepage":"https://github.com/checkdigit/spectral-config#readme","bugs":{"url":"https://github.com/checkdigit/spectral-config/issues"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/spectral-config.git"},"license":"UNLICENSED","author":"Check Digit, LLC","main":"ruleset.json","files":["ruleset.json"],"scripts":{"ci:compile":"","ci:coverage":"","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"spectral lint test/openapi.yml --ruleset test/.spectral.json","lint":"","lint:fix":"","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:style && npm run ci:lint"},"prettier":"@checkdigit/prettier-config","devDependencies":{"@checkdigit/prettier-config":"^7.1.2"},"peerDependencies":{"@stoplight/spectral-cli":"6.15.0"},"engines":{"node":">=22.18"}}
1
+ {"name":"@checkdigit/spectral-config","version":"3.1.0-PR.26-2219","private":false,"description":"Check Digit Spectral Config","homepage":"https://github.com/checkdigit/spectral-config#readme","bugs":{"url":"https://github.com/checkdigit/spectral-config/issues"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/spectral-config.git"},"license":"UNLICENSED","author":"Check Digit, LLC","main":"ruleset.json","files":["ruleset.json","spectral-schema-resolver.cjs"],"scripts":{"ci:compile":"","ci:coverage":"","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"spectral lint test/openapi.yml --ruleset test/.spectral.json","lint":"","lint:fix":"","oas31":"spectral lint test/openapi-31.yml --ruleset test/.spectral.json --resolver=spectral-schema-resolver.cjs","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:style && npm run ci:lint"},"prettier":"@checkdigit/prettier-config","devDependencies":{"@checkdigit/currency":"7.1.0-PR.27-f937","@checkdigit/prettier-config":"^6.0.0"},"peerDependencies":{"@stoplight/json-ref-readers":"1.2.2","@stoplight/json-ref-resolver":"3.1.6","@stoplight/spectral-cli":"6.15.0"},"engines":{"node":">=22.18"}}
package/ruleset.json CHANGED
@@ -2,14 +2,18 @@
2
2
  "extends": ["spectral:oas"],
3
3
  "rules": {
4
4
  "no-$ref-siblings": "off",
5
+
5
6
  "info-contact": "error",
6
7
  "info-description": "error",
7
8
  "duplicated-entry-in-enum": "error",
8
9
  "operation-success-response": "error",
10
+ "operation-operationId-unique": "error",
9
11
  "operation-tag-defined": "error",
10
12
  "no-eval-in-markdown": "error",
11
13
  "no-script-tags-in-markdown": "error",
12
14
  "operation-description": "error",
15
+ "operation-operationId": "error",
16
+ "operation-operationId-valid-in-url": "error",
13
17
  "operation-tags": "error",
14
18
  "path-declarations-must-exist": "error",
15
19
  "path-keys-no-trailing-slash": "error",
@@ -20,8 +24,10 @@
20
24
  "oas3-operation-security-defined": "error",
21
25
  "oas3-server-trailing-slash": "error",
22
26
  "oas3-unused-component": "error",
27
+
23
28
  "oas2-api-host": "off",
24
29
  "oas2-api-schemes": "off",
30
+
25
31
  "oas2-anyOf": "error",
26
32
  "oas2-discriminator": "error",
27
33
  "oas2-host-trailing-slash": "error",
@@ -31,6 +37,7 @@
31
37
  "oas2-schema": "error",
32
38
  "oas2-unused-definition": "error",
33
39
  "oas2-valid-media-example": "error",
40
+
34
41
  "header-required-property": {
35
42
  "description": "All headers must explicitly define whether they are required.",
36
43
  "message": "Header is missing 'required' property.",
@@ -40,26 +47,6 @@
40
47
  "field": "required",
41
48
  "function": "defined"
42
49
  }
43
- },
44
- "operation-operationId": "off",
45
- "operation-operationId-unique": "off",
46
- "operation-operationId-valid-in-url": "off",
47
- "no-operationId-allowed": {
48
- "description": "operationId is not allowed in our API style.",
49
- "message": "Remove `operationId` from operations.",
50
- "severity": "error",
51
- "given": "$.paths[*][*]",
52
- "then": {
53
- "function": "schema",
54
- "functionOptions": {
55
- "schema": {
56
- "type": "object",
57
- "not": {
58
- "required": ["operationId"]
59
- }
60
- }
61
- }
62
- }
63
50
  }
64
51
  }
65
52
  }
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs');
4
+
5
+ const { schemaResolver } = require('@checkdigit/openapi');
6
+
7
+ const { Resolver } = require('@stoplight/json-ref-resolver');
8
+ const { resolveFile } = require('@stoplight/json-ref-readers');
9
+
10
+ const resolver = new Resolver({
11
+ resolvers: {
12
+ file: { resolve: resolveFile },
13
+ https: {
14
+ resolve: (uri) => {
15
+ const url = uri.href();
16
+ if (schemaResolver.isHttpsSchemaReferenceUrl(url)) {
17
+ const localSchemaPath = schemaResolver.mapHttpsToLocalResourcePath(url);
18
+ return fs.readFileSync(localSchemaPath, 'utf8');
19
+ }
20
+ throw new Error(`Unable to resolve https:// schema URL: ${uri}`);
21
+ },
22
+ },
23
+ service: {
24
+ resolve: (uri) => {
25
+ const url = uri.href();
26
+ if (schemaResolver.isServiceSchemaReferenceUrl(url)) {
27
+ const localSchemaPath = schemaResolver.mapServiceToLocalResourcePath(url);
28
+ return fs.readFileSync(localSchemaPath, 'utf8');
29
+ }
30
+ throw new Error(`Unable to resolve service:// schema URL: ${uri}`);
31
+ },
32
+ },
33
+ },
34
+ });
35
+ module.exports = resolver;