@redocly/openapi-core 1.0.0-beta.63 → 1.0.0-beta.67

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.
Files changed (70) hide show
  1. package/__tests__/lint.test.ts +17 -0
  2. package/lib/config/all.js +9 -1
  3. package/lib/config/config.js +1 -1
  4. package/lib/config/minimal.js +1 -0
  5. package/lib/config/recommended.js +1 -0
  6. package/lib/index.d.ts +1 -1
  7. package/lib/index.js +2 -1
  8. package/lib/oas-types.js +3 -0
  9. package/lib/rules/builtin.d.ts +6 -0
  10. package/lib/rules/common/info-description-override.d.ts +2 -0
  11. package/lib/rules/common/info-description-override.js +24 -0
  12. package/lib/rules/common/info-license-url.js +1 -0
  13. package/lib/rules/common/no-http-verbs-in-paths.d.ts +2 -0
  14. package/lib/rules/common/no-http-verbs-in-paths.js +33 -0
  15. package/lib/rules/common/operation-4xx-response.d.ts +2 -0
  16. package/lib/rules/common/operation-4xx-response.js +17 -0
  17. package/lib/rules/common/operation-description-override.d.ts +2 -0
  18. package/lib/rules/common/operation-description-override.js +29 -0
  19. package/lib/rules/common/path-excludes-patterns.d.ts +2 -0
  20. package/lib/rules/common/path-excludes-patterns.js +22 -0
  21. package/lib/rules/common/path-segment-plural.d.ts +2 -0
  22. package/lib/rules/common/path-segment-plural.js +32 -0
  23. package/lib/rules/common/tag-description-override.d.ts +2 -0
  24. package/lib/rules/common/tag-description-override.js +25 -0
  25. package/lib/rules/oas2/index.d.ts +9 -0
  26. package/lib/rules/oas2/index.js +18 -0
  27. package/lib/rules/oas2/request-mime-type.d.ts +2 -0
  28. package/lib/rules/oas2/request-mime-type.js +17 -0
  29. package/lib/rules/oas2/response-mime-type.d.ts +2 -0
  30. package/lib/rules/oas2/response-mime-type.js +17 -0
  31. package/lib/rules/oas3/index.d.ts +3 -0
  32. package/lib/rules/oas3/index.js +19 -1
  33. package/lib/rules/oas3/request-mime-type.d.ts +2 -0
  34. package/lib/rules/oas3/request-mime-type.js +31 -0
  35. package/lib/rules/oas3/response-mime-type.d.ts +2 -0
  36. package/lib/rules/oas3/response-mime-type.js +31 -0
  37. package/lib/types/oas3_1.js +6 -0
  38. package/lib/types/redocly-yaml.js +332 -21
  39. package/lib/utils.d.ts +13 -0
  40. package/lib/utils.js +77 -1
  41. package/package.json +4 -2
  42. package/src/__tests__/lint.test.ts +13 -0
  43. package/src/__tests__/utils.test.ts +74 -0
  44. package/src/config/all.ts +9 -1
  45. package/src/config/config.ts +2 -2
  46. package/src/config/minimal.ts +1 -0
  47. package/src/config/recommended.ts +1 -0
  48. package/src/index.ts +1 -1
  49. package/src/oas-types.ts +4 -0
  50. package/src/rules/common/__tests__/info-license.test.ts +1 -1
  51. package/src/rules/common/__tests__/operation-4xx-response.test.ts +108 -0
  52. package/src/rules/common/info-description-override.ts +24 -0
  53. package/src/rules/common/info-license-url.ts +1 -0
  54. package/src/rules/common/no-http-verbs-in-paths.ts +36 -0
  55. package/src/rules/common/operation-4xx-response.ts +17 -0
  56. package/src/rules/common/operation-description-override.ts +30 -0
  57. package/src/rules/common/path-excludes-patterns.ts +23 -0
  58. package/src/rules/common/path-segment-plural.ts +31 -0
  59. package/src/rules/common/tag-description-override.ts +25 -0
  60. package/src/rules/oas2/index.ts +18 -0
  61. package/src/rules/oas2/request-mime-type.ts +17 -0
  62. package/src/rules/oas2/response-mime-type.ts +17 -0
  63. package/src/rules/oas3/index.ts +20 -3
  64. package/src/rules/oas3/request-mime-type.ts +31 -0
  65. package/src/rules/oas3/response-mime-type.ts +31 -0
  66. package/src/rules/utils.ts +1 -1
  67. package/src/types/oas3_1.ts +7 -0
  68. package/src/types/redocly-yaml.ts +434 -22
  69. package/src/utils.ts +95 -0
  70. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,17 @@
1
+ import outdent from 'outdent';
2
+ import { detectOpenAPI } from '../src/oas-types';
3
+ import { parseYamlToDocument } from './utils';
4
+
5
+ describe.only('lint', () => {
6
+ it('detect OpenAPI should throw an error when version is not string', () => {
7
+
8
+ const testDocument = parseYamlToDocument(
9
+ outdent`
10
+ openapi: 3.0
11
+ `,
12
+ '',
13
+ );
14
+ expect(() => detectOpenAPI(testDocument.parsed))
15
+ .toThrow(`Invalid OpenAPI version: should be a string but got "number"`)
16
+ });
17
+ });
package/lib/config/all.js CHANGED
@@ -12,11 +12,13 @@ exports.default = {
12
12
  'no-identical-paths': 'error',
13
13
  'no-ambiguous-paths': 'error',
14
14
  'no-path-trailing-slash': 'error',
15
+ 'path-segment-plural': 'error',
15
16
  'path-declaration-must-exist': 'error',
16
17
  'path-not-include-query': 'error',
17
18
  'path-parameters-defined': 'error',
18
19
  'operation-description': 'error',
19
20
  'operation-2xx-response': 'error',
21
+ 'operation-4xx-response': 'error',
20
22
  'operation-operationId': 'error',
21
23
  'operation-summary': 'error',
22
24
  'operation-operationId-unique': 'error',
@@ -29,6 +31,12 @@ exports.default = {
29
31
  'no-enum-type-mismatch': 'error',
30
32
  'boolean-parameter-prefixes': 'error',
31
33
  'paths-kebab-case': 'error',
34
+ 'no-http-verbs-in-paths': 'error',
35
+ 'path-excludes-patterns': {
36
+ severity: 'error',
37
+ patterns: [],
38
+ },
39
+ 'request-mime-type': 'error',
32
40
  spec: 'error',
33
41
  },
34
42
  oas3_0Rules: {
@@ -49,5 +57,5 @@ exports.default = {
49
57
  'no-unused-components': 'error',
50
58
  'no-undefined-server-variable': 'error',
51
59
  'no-servers-empty-enum': 'error',
52
- }
60
+ },
53
61
  };
@@ -73,7 +73,7 @@ class LintConfig {
73
73
  const ignoreFile = path.join(dir, exports.IGNORE_FILE);
74
74
  const mapped = {};
75
75
  for (const absFileName of Object.keys(this.ignore)) {
76
- const ignoredRules = (mapped[path.relative(dir, absFileName)] = this.ignore[absFileName]);
76
+ const ignoredRules = (mapped[utils_1.slash(path.relative(dir, absFileName))] = this.ignore[absFileName]);
77
77
  for (const ruleId of Object.keys(ignoredRules)) {
78
78
  ignoredRules[ruleId] = Array.from(ignoredRules[ruleId]);
79
79
  }
@@ -17,6 +17,7 @@ exports.default = {
17
17
  'path-parameters-defined': 'warn',
18
18
  'operation-description': 'off',
19
19
  'operation-2xx-response': 'warn',
20
+ 'operation-4xx-response': 'off',
20
21
  'operation-operationId': 'warn',
21
22
  'operation-summary': 'warn',
22
23
  'operation-operationId-unique': 'warn',
@@ -17,6 +17,7 @@ exports.default = {
17
17
  'path-parameters-defined': 'error',
18
18
  'operation-description': 'off',
19
19
  'operation-2xx-response': 'warn',
20
+ 'operation-4xx-response': 'warn',
20
21
  'operation-operationId': 'warn',
21
22
  'operation-summary': 'error',
22
23
  'operation-operationId-unique': 'error',
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { BundleOutputFormat, readFileFromUrl } from './utils';
1
+ export { BundleOutputFormat, readFileFromUrl, slash } from './utils';
2
2
  export { Oas3_1Types } from './types/oas3_1';
3
3
  export { Oas3Types } from './types/oas3';
4
4
  export { Oas2Types } from './types/oas2';
package/lib/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.RedoclyClient = exports.loadConfig = exports.IGNORE_FILE = exports.LintConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.Oas2Types = exports.Oas3Types = exports.Oas3_1Types = exports.readFileFromUrl = void 0;
3
+ exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.RedoclyClient = exports.loadConfig = exports.IGNORE_FILE = exports.LintConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.Oas2Types = exports.Oas3Types = exports.Oas3_1Types = exports.slash = exports.readFileFromUrl = void 0;
4
4
  var utils_1 = require("./utils");
5
5
  Object.defineProperty(exports, "readFileFromUrl", { enumerable: true, get: function () { return utils_1.readFileFromUrl; } });
6
+ Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return utils_1.slash; } });
6
7
  var oas3_1_1 = require("./types/oas3_1");
7
8
  Object.defineProperty(exports, "Oas3_1Types", { enumerable: true, get: function () { return oas3_1_1.Oas3_1Types; } });
8
9
  var oas3_1 = require("./types/oas3");
package/lib/oas-types.js CHANGED
@@ -19,6 +19,9 @@ function detectOpenAPI(root) {
19
19
  if (!(root.openapi || root.swagger)) {
20
20
  throw new Error('This doesn’t look like an OpenAPI document.\n');
21
21
  }
22
+ if (root.openapi && typeof root.openapi !== 'string') {
23
+ throw new Error(`Invalid OpenAPI version: should be a string but got "${typeof root.openapi}"`);
24
+ }
22
25
  if (root.openapi && root.openapi.startsWith('3.0')) {
23
26
  return OasVersion.Version3_0;
24
27
  }
@@ -7,8 +7,14 @@ export declare const preprocessors: {
7
7
  export declare const decorators: {
8
8
  oas3: {
9
9
  'registry-dependencies': import("../visitors").Oas3Decorator;
10
+ 'operation-description-override': import("../visitors").Oas3Decorator;
11
+ 'tag-description-override': import("../visitors").Oas3Decorator;
12
+ 'info-description-override': import("../visitors").Oas3Decorator;
10
13
  };
11
14
  oas2: {
12
15
  'registry-dependencies': import("../visitors").Oas2Decorator;
16
+ 'operation-description-override': import("../visitors").Oas2Decorator;
17
+ 'tag-description-override': import("../visitors").Oas2Decorator;
18
+ 'info-description-override': import("../visitors").Oas2Decorator;
13
19
  };
14
20
  };
@@ -0,0 +1,2 @@
1
+ import { Oas3Decorator, Oas2Decorator } from '../../visitors';
2
+ export declare const InfoDescriptionOverride: Oas3Decorator | Oas2Decorator;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InfoDescriptionOverride = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const InfoDescriptionOverride = ({ filePath }) => {
6
+ return {
7
+ Info: {
8
+ leave(info, { report, location }) {
9
+ if (!filePath)
10
+ throw new Error(`Parameter "filePath" is not provided for "info-description-override" rule`);
11
+ try {
12
+ info.description = utils_1.readFileAsStringSync(filePath);
13
+ }
14
+ catch (e) {
15
+ report({
16
+ message: `Failed to read markdown override file for "info.description".\n${e.message}`,
17
+ location: location.child('description'),
18
+ });
19
+ }
20
+ },
21
+ },
22
+ };
23
+ };
24
+ exports.InfoDescriptionOverride = InfoDescriptionOverride;
@@ -8,6 +8,7 @@ const InfoLicense = () => {
8
8
  if (!info.license) {
9
9
  report({
10
10
  message: utils_1.missingRequiredField('Info', 'license'),
11
+ location: { reportOnKey: true }
11
12
  });
12
13
  }
13
14
  },
@@ -0,0 +1,2 @@
1
+ import { Oas3Rule, Oas2Rule } from '../../visitors';
2
+ export declare const NoHttpVerbsInPaths: Oas3Rule | Oas2Rule;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoHttpVerbsInPaths = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const httpMethods = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace'];
6
+ const NoHttpVerbsInPaths = ({ splitIntoWords }) => {
7
+ return {
8
+ PathItem(_path, { key, report, location }) {
9
+ const pathKey = key.toString();
10
+ if (!pathKey.startsWith('/'))
11
+ return;
12
+ const pathSegments = pathKey.split('/');
13
+ for (const pathSegment of pathSegments) {
14
+ if (!pathSegment || utils_1.isPathParameter(pathSegment))
15
+ continue;
16
+ const isHttpMethodIncluded = (method) => {
17
+ return splitIntoWords
18
+ ? utils_1.splitCamelCaseIntoWords(pathSegment).has(method)
19
+ : pathSegment.toLocaleLowerCase().includes(method);
20
+ };
21
+ for (const method of httpMethods) {
22
+ if (isHttpMethodIncluded(method)) {
23
+ report({
24
+ message: `path \`${pathKey}\` should not contain http verb ${method}`,
25
+ location: location.key(),
26
+ });
27
+ }
28
+ }
29
+ }
30
+ },
31
+ };
32
+ };
33
+ exports.NoHttpVerbsInPaths = NoHttpVerbsInPaths;
@@ -0,0 +1,2 @@
1
+ import { Oas3Rule, Oas2Rule } from '../../visitors';
2
+ export declare const Operation4xxResponse: Oas3Rule | Oas2Rule;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Operation4xxResponse = void 0;
4
+ const Operation4xxResponse = () => {
5
+ return {
6
+ ResponsesMap(responses, { report }) {
7
+ const codes = Object.keys(responses);
8
+ if (!codes.some((code) => /4[Xx0-9]{2}/.test(code))) {
9
+ report({
10
+ message: 'Operation must have at least one `4xx` response.',
11
+ location: { reportOnKey: true },
12
+ });
13
+ }
14
+ },
15
+ };
16
+ };
17
+ exports.Operation4xxResponse = Operation4xxResponse;
@@ -0,0 +1,2 @@
1
+ import { Oas3Decorator, Oas2Decorator } from '../../visitors';
2
+ export declare const OperationDescriptionOverride: Oas3Decorator | Oas2Decorator;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OperationDescriptionOverride = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const OperationDescriptionOverride = ({ operationIds }) => {
6
+ return {
7
+ Operation: {
8
+ leave(operation, { report, location }) {
9
+ if (!operation.operationId)
10
+ return;
11
+ if (!operationIds)
12
+ throw new Error(`Parameter "operationIds" is not provided for "operation-description-override" rule`);
13
+ const operationId = operation.operationId;
14
+ if (operationIds[operationId]) {
15
+ try {
16
+ operation.description = utils_1.readFileAsStringSync(operationIds[operationId]);
17
+ }
18
+ catch (e) {
19
+ report({
20
+ message: `Failed to read markdown override file for operation "${operationId}".\n${e.message}`,
21
+ location: location.child('operationId').key(),
22
+ });
23
+ }
24
+ }
25
+ },
26
+ },
27
+ };
28
+ };
29
+ exports.OperationDescriptionOverride = OperationDescriptionOverride;
@@ -0,0 +1,2 @@
1
+ import { Oas2Rule, Oas3Rule } from '../../visitors';
2
+ export declare const PathExcludesPatterns: Oas3Rule | Oas2Rule;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PathExcludesPatterns = void 0;
4
+ const PathExcludesPatterns = ({ patterns }) => {
5
+ return {
6
+ PathItem(_path, { report, key, location }) {
7
+ if (!patterns)
8
+ throw new Error(`Parameter "patterns" is not provided for "path-excludes-patterns" rule`);
9
+ const pathKey = key.toString();
10
+ if (pathKey.startsWith('/')) {
11
+ const matches = patterns.filter((pattern) => pathKey.match(pattern));
12
+ for (const match of matches) {
13
+ report({
14
+ message: `path \`${pathKey}\` should not match regex pattern: \`${match}\``,
15
+ location: location.key(),
16
+ });
17
+ }
18
+ }
19
+ },
20
+ };
21
+ };
22
+ exports.PathExcludesPatterns = PathExcludesPatterns;
@@ -0,0 +1,2 @@
1
+ import { Oas3Rule, Oas2Rule } from '../../visitors';
2
+ export declare const PathSegmentPlural: Oas3Rule | Oas2Rule;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PathSegmentPlural = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const PathSegmentPlural = (opts) => {
6
+ const { ignoreLastPathSegment, exceptions } = opts;
7
+ return {
8
+ PathItem: {
9
+ leave(_path, { report, key, location }) {
10
+ const pathKey = key.toString();
11
+ if (pathKey.startsWith('/')) {
12
+ const pathSegments = pathKey.split('/');
13
+ pathSegments.shift();
14
+ if (ignoreLastPathSegment && pathSegments.length > 1) {
15
+ pathSegments.pop();
16
+ }
17
+ for (const pathSegment of pathSegments) {
18
+ if (exceptions && exceptions.includes(pathSegment))
19
+ continue;
20
+ if (!utils_1.isPathParameter(pathSegment) && utils_1.isSingular(pathSegment)) {
21
+ report({
22
+ message: `path segment \`${pathSegment}\` should be plural.`,
23
+ location: location.key(),
24
+ });
25
+ }
26
+ }
27
+ }
28
+ },
29
+ },
30
+ };
31
+ };
32
+ exports.PathSegmentPlural = PathSegmentPlural;
@@ -0,0 +1,2 @@
1
+ import { Oas3Decorator, Oas2Decorator } from '../../visitors';
2
+ export declare const TagDescriptionOverride: Oas3Decorator | Oas2Decorator;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TagDescriptionOverride = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const TagDescriptionOverride = ({ tagNames }) => {
6
+ return {
7
+ Tag: {
8
+ leave(tag, { report }) {
9
+ if (!tagNames)
10
+ throw new Error(`Parameter "tagNames" is not provided for "tag-description-override" rule`);
11
+ if (tagNames[tag.name]) {
12
+ try {
13
+ tag.description = utils_1.readFileAsStringSync(tagNames[tag.name]);
14
+ }
15
+ catch (e) {
16
+ report({
17
+ message: `Failed to read markdown override file for tag "${tag.name}".\n${e.message}`,
18
+ });
19
+ }
20
+ }
21
+ },
22
+ },
23
+ };
24
+ };
25
+ exports.TagDescriptionOverride = TagDescriptionOverride;
@@ -12,6 +12,7 @@ export declare const rules: {
12
12
  'boolean-parameter-prefixes': Oas2Rule;
13
13
  'no-path-trailing-slash': Oas2Rule;
14
14
  'operation-2xx-response': Oas2Rule;
15
+ 'operation-4xx-response': Oas2Rule;
15
16
  'operation-operationId-unique': Oas2Rule;
16
17
  'operation-parameters-unique': Oas2Rule;
17
18
  'path-parameters-defined': Oas2Rule;
@@ -30,8 +31,16 @@ export declare const rules: {
30
31
  'no-identical-paths': Oas2Rule;
31
32
  'no-ambiguous-paths': Oas2Rule;
32
33
  'path-http-verbs-order': Oas2Rule;
34
+ 'no-http-verbs-in-paths': Oas2Rule;
35
+ 'path-excludes-patterns': Oas2Rule;
36
+ 'request-mime-type': Oas2Rule;
37
+ 'response-mime-type': Oas2Rule;
38
+ 'path-segment-plural': Oas2Rule;
33
39
  };
34
40
  export declare const preprocessors: {};
35
41
  export declare const decorators: {
36
42
  'registry-dependencies': Oas2Decorator;
43
+ 'operation-description-override': Oas2Decorator;
44
+ 'tag-description-override': Oas2Decorator;
45
+ 'info-description-override': Oas2Decorator;
37
46
  };
@@ -13,6 +13,7 @@ const paths_kebab_case_1 = require("../common/paths-kebab-case");
13
13
  const no_enum_type_mismatch_1 = require("../common/no-enum-type-mismatch");
14
14
  const no_path_trailing_slash_1 = require("../common/no-path-trailing-slash");
15
15
  const operation_2xx_response_1 = require("../common/operation-2xx-response");
16
+ const operation_4xx_response_1 = require("../common/operation-4xx-response");
16
17
  const operation_operationId_unique_1 = require("../common/operation-operationId-unique");
17
18
  const operation_parameters_unique_1 = require("../common/operation-parameters-unique");
18
19
  const path_params_defined_1 = require("../common/path-params-defined");
@@ -31,6 +32,14 @@ const no_identical_paths_1 = require("../common/no-identical-paths");
31
32
  const operation_operationId_1 = require("../common/operation-operationId");
32
33
  const operation_summary_1 = require("../common/operation-summary");
33
34
  const no_ambiguous_paths_1 = require("../common/no-ambiguous-paths");
35
+ const no_http_verbs_in_paths_1 = require("../common/no-http-verbs-in-paths");
36
+ const path_excludes_patterns_1 = require("../common/path-excludes-patterns");
37
+ const request_mime_type_1 = require("./request-mime-type");
38
+ const response_mime_type_1 = require("./response-mime-type");
39
+ const path_segment_plural_1 = require("../common/path-segment-plural");
40
+ const operation_description_override_1 = require("../common/operation-description-override");
41
+ const tag_description_override_1 = require("../common/tag-description-override");
42
+ const info_description_override_1 = require("../common/info-description-override");
34
43
  exports.rules = {
35
44
  spec: spec_1.OasSpec,
36
45
  'info-description': info_description_1.InfoDescription,
@@ -44,6 +53,7 @@ exports.rules = {
44
53
  'boolean-parameter-prefixes': boolean_parameter_prefixes_1.BooleanParameterPrefixes,
45
54
  'no-path-trailing-slash': no_path_trailing_slash_1.NoPathTrailingSlash,
46
55
  'operation-2xx-response': operation_2xx_response_1.Operation2xxResponse,
56
+ 'operation-4xx-response': operation_4xx_response_1.Operation4xxResponse,
47
57
  'operation-operationId-unique': operation_operationId_unique_1.OperationIdUnique,
48
58
  'operation-parameters-unique': operation_parameters_unique_1.OperationParametersUnique,
49
59
  'path-parameters-defined': path_params_defined_1.PathParamsDefined,
@@ -62,8 +72,16 @@ exports.rules = {
62
72
  'no-identical-paths': no_identical_paths_1.NoIdenticalPaths,
63
73
  'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths,
64
74
  'path-http-verbs-order': path_http_verbs_order_1.PathHttpVerbsOrder,
75
+ 'no-http-verbs-in-paths': no_http_verbs_in_paths_1.NoHttpVerbsInPaths,
76
+ 'path-excludes-patterns': path_excludes_patterns_1.PathExcludesPatterns,
77
+ 'request-mime-type': request_mime_type_1.RequestMimeType,
78
+ 'response-mime-type': response_mime_type_1.ResponseMimeType,
79
+ 'path-segment-plural': path_segment_plural_1.PathSegmentPlural,
65
80
  };
66
81
  exports.preprocessors = {};
67
82
  exports.decorators = {
68
83
  'registry-dependencies': registry_dependencies_1.RegistryDependencies,
84
+ 'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
85
+ 'tag-description-override': tag_description_override_1.TagDescriptionOverride,
86
+ 'info-description-override': info_description_override_1.InfoDescriptionOverride,
69
87
  };
@@ -0,0 +1,2 @@
1
+ import { Oas2Rule } from '../../visitors';
2
+ export declare const RequestMimeType: Oas2Rule;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestMimeType = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const RequestMimeType = ({ allowedValues }) => {
6
+ return {
7
+ DefinitionRoot(root, ctx) {
8
+ utils_1.validateMimeType({ type: 'consumes', value: root }, ctx, allowedValues);
9
+ },
10
+ Operation: {
11
+ leave(operation, ctx) {
12
+ utils_1.validateMimeType({ type: 'consumes', value: operation }, ctx, allowedValues);
13
+ },
14
+ },
15
+ };
16
+ };
17
+ exports.RequestMimeType = RequestMimeType;
@@ -0,0 +1,2 @@
1
+ import { Oas2Rule } from '../../visitors';
2
+ export declare const ResponseMimeType: Oas2Rule;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResponseMimeType = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const ResponseMimeType = ({ allowedValues }) => {
6
+ return {
7
+ DefinitionRoot(root, ctx) {
8
+ utils_1.validateMimeType({ type: 'produces', value: root }, ctx, allowedValues);
9
+ },
10
+ Operation: {
11
+ leave(operation, ctx) {
12
+ utils_1.validateMimeType({ type: 'produces', value: operation }, ctx, allowedValues);
13
+ },
14
+ },
15
+ };
16
+ };
17
+ exports.ResponseMimeType = ResponseMimeType;
@@ -4,4 +4,7 @@ export declare const rules: Oas3RuleSet;
4
4
  export declare const preprocessors: {};
5
5
  export declare const decorators: {
6
6
  'registry-dependencies': Oas3Decorator;
7
+ 'operation-description-override': Oas3Decorator;
8
+ 'tag-description-override': Oas3Decorator;
9
+ 'info-description-override': Oas3Decorator;
7
10
  };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decorators = exports.preprocessors = exports.rules = void 0;
4
4
  const spec_1 = require("../common/spec");
5
5
  const operation_2xx_response_1 = require("../common/operation-2xx-response");
6
+ const operation_4xx_response_1 = require("../common/operation-4xx-response");
6
7
  const operation_operationId_unique_1 = require("../common/operation-operationId-unique");
7
8
  const operation_parameters_unique_1 = require("../common/operation-parameters-unique");
8
9
  const path_params_defined_1 = require("../common/path-params-defined");
@@ -39,6 +40,14 @@ const operation_operationId_1 = require("../common/operation-operationId");
39
40
  const operation_summary_1 = require("../common/operation-summary");
40
41
  const no_ambiguous_paths_1 = require("../common/no-ambiguous-paths");
41
42
  const no_servers_empty_enum_1 = require("./no-servers-empty-enum");
43
+ const no_http_verbs_in_paths_1 = require("../common/no-http-verbs-in-paths");
44
+ const request_mime_type_1 = require("./request-mime-type");
45
+ const response_mime_type_1 = require("./response-mime-type");
46
+ const path_segment_plural_1 = require("../common/path-segment-plural");
47
+ const operation_description_override_1 = require("../common/operation-description-override");
48
+ const tag_description_override_1 = require("../common/tag-description-override");
49
+ const info_description_override_1 = require("../common/info-description-override");
50
+ const path_excludes_patterns_1 = require("../common/path-excludes-patterns");
42
51
  exports.rules = {
43
52
  spec: spec_1.OasSpec,
44
53
  'info-description': info_description_1.InfoDescription,
@@ -46,6 +55,7 @@ exports.rules = {
46
55
  'info-license': info_license_url_1.InfoLicense,
47
56
  'info-license-url': license_url_1.InfoLicenseUrl,
48
57
  'operation-2xx-response': operation_2xx_response_1.Operation2xxResponse,
58
+ 'operation-4xx-response': operation_4xx_response_1.Operation4xxResponse,
49
59
  'operation-operationId-unique': operation_operationId_unique_1.OperationIdUnique,
50
60
  'operation-parameters-unique': operation_parameters_unique_1.OperationParametersUnique,
51
61
  'path-parameters-defined': path_params_defined_1.PathParamsDefined,
@@ -77,9 +87,17 @@ exports.rules = {
77
87
  'no-identical-paths': no_identical_paths_1.NoIdenticalPaths,
78
88
  'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths,
79
89
  'no-undefined-server-variable': no_undefined_server_variable_1.NoUndefinedServerVariable,
80
- 'no-servers-empty-enum': no_servers_empty_enum_1.NoEmptyEnumServers
90
+ 'no-servers-empty-enum': no_servers_empty_enum_1.NoEmptyEnumServers,
91
+ 'no-http-verbs-in-paths': no_http_verbs_in_paths_1.NoHttpVerbsInPaths,
92
+ 'path-excludes-patterns': path_excludes_patterns_1.PathExcludesPatterns,
93
+ 'request-mime-type': request_mime_type_1.RequestMimeType,
94
+ 'response-mime-type': response_mime_type_1.ResponseMimeType,
95
+ 'path-segment-plural': path_segment_plural_1.PathSegmentPlural,
81
96
  };
82
97
  exports.preprocessors = {};
83
98
  exports.decorators = {
84
99
  'registry-dependencies': registry_dependencies_1.RegistryDependencies,
100
+ 'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
101
+ 'tag-description-override': tag_description_override_1.TagDescriptionOverride,
102
+ 'info-description-override': info_description_override_1.InfoDescriptionOverride,
85
103
  };
@@ -0,0 +1,2 @@
1
+ import { Oas3Rule } from '../../visitors';
2
+ export declare const RequestMimeType: Oas3Rule;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestMimeType = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const RequestMimeType = ({ allowedValues }) => {
6
+ return {
7
+ PathMap: {
8
+ RequestBody: {
9
+ leave(requestBody, ctx) {
10
+ utils_1.validateMimeTypeOAS3({ type: 'consumes', value: requestBody }, ctx, allowedValues);
11
+ },
12
+ },
13
+ Callback: {
14
+ RequestBody() { },
15
+ Response: {
16
+ leave(response, ctx) {
17
+ utils_1.validateMimeTypeOAS3({ type: 'consumes', value: response }, ctx, allowedValues);
18
+ },
19
+ },
20
+ },
21
+ },
22
+ WebhooksMap: {
23
+ Response: {
24
+ leave(response, ctx) {
25
+ utils_1.validateMimeTypeOAS3({ type: 'consumes', value: response }, ctx, allowedValues);
26
+ },
27
+ },
28
+ },
29
+ };
30
+ };
31
+ exports.RequestMimeType = RequestMimeType;
@@ -0,0 +1,2 @@
1
+ import { Oas3Rule } from '../../visitors';
2
+ export declare const ResponseMimeType: Oas3Rule;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResponseMimeType = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const ResponseMimeType = ({ allowedValues }) => {
6
+ return {
7
+ PathMap: {
8
+ Response: {
9
+ leave(response, ctx) {
10
+ utils_1.validateMimeTypeOAS3({ type: 'produces', value: response }, ctx, allowedValues);
11
+ },
12
+ },
13
+ Callback: {
14
+ Response() { },
15
+ RequestBody: {
16
+ leave(requestBody, ctx) {
17
+ utils_1.validateMimeTypeOAS3({ type: 'produces', value: requestBody }, ctx, allowedValues);
18
+ },
19
+ },
20
+ },
21
+ },
22
+ WebhooksMap: {
23
+ RequestBody: {
24
+ leave(requestBody, ctx) {
25
+ utils_1.validateMimeTypeOAS3({ type: 'produces', value: requestBody }, ctx, allowedValues);
26
+ },
27
+ },
28
+ },
29
+ };
30
+ };
31
+ exports.ResponseMimeType = ResponseMimeType;
@@ -94,6 +94,12 @@ const Operation = {
94
94
  };
95
95
  const Schema = {
96
96
  properties: {
97
+ $id: { type: 'string' },
98
+ id: { type: 'string' },
99
+ $schema: { type: 'string' },
100
+ definitions: 'NamedSchemas',
101
+ $defs: 'NamedSchemas',
102
+ $vocabulary: { type: 'string' },
97
103
  externalDocs: 'ExternalDocs',
98
104
  discriminator: 'Discriminator',
99
105
  myArbitraryKeyword: { type: 'boolean' },