@redocly/openapi-core 0.0.0-snapshot.1737554067
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 +268 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.d.ts +4 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +38 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.d.ts +4 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +44 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.d.ts +4 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +25 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.d.ts +4 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +37 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.d.ts +4 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +36 -0
- package/lib/benchmark/benches/recommended-oas3.bench.d.ts +3 -0
- package/lib/benchmark/benches/recommended-oas3.bench.js +21 -0
- package/lib/benchmark/benches/resolve-with-no-external.bench.d.ts +3 -0
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +22 -0
- package/lib/benchmark/utils.d.ts +6 -0
- package/lib/benchmark/utils.js +34 -0
- package/lib/bundle.d.ts +50 -0
- package/lib/bundle.js +385 -0
- package/lib/config/all.d.ts +3 -0
- package/lib/config/all.js +227 -0
- package/lib/config/builtIn.d.ts +3 -0
- package/lib/config/builtIn.js +53 -0
- package/lib/config/config-resolvers.d.ts +30 -0
- package/lib/config/config-resolvers.js +447 -0
- package/lib/config/config.d.ts +53 -0
- package/lib/config/config.js +320 -0
- package/lib/config/index.d.ts +7 -0
- package/lib/config/index.js +23 -0
- package/lib/config/load.d.ts +38 -0
- package/lib/config/load.js +140 -0
- package/lib/config/minimal.d.ts +3 -0
- package/lib/config/minimal.js +203 -0
- package/lib/config/recommended-strict.d.ts +3 -0
- package/lib/config/recommended-strict.js +203 -0
- package/lib/config/recommended.d.ts +3 -0
- package/lib/config/recommended.js +203 -0
- package/lib/config/rules.d.ts +10 -0
- package/lib/config/rules.js +37 -0
- package/lib/config/spec.d.ts +3 -0
- package/lib/config/spec.js +29 -0
- package/lib/config/types.d.ts +189 -0
- package/lib/config/types.js +2 -0
- package/lib/config/utils.d.ts +19 -0
- package/lib/config/utils.js +308 -0
- package/lib/decorators/arazzo/index.d.ts +1 -0
- package/lib/decorators/arazzo/index.js +4 -0
- package/lib/decorators/async2/index.d.ts +1 -0
- package/lib/decorators/async2/index.js +4 -0
- package/lib/decorators/async3/index.d.ts +1 -0
- package/lib/decorators/async3/index.js +4 -0
- package/lib/decorators/common/filters/filter-helper.d.ts +3 -0
- package/lib/decorators/common/filters/filter-helper.js +66 -0
- package/lib/decorators/common/filters/filter-in.d.ts +2 -0
- package/lib/decorators/common/filters/filter-in.js +17 -0
- package/lib/decorators/common/filters/filter-out.d.ts +2 -0
- package/lib/decorators/common/filters/filter-out.js +17 -0
- package/lib/decorators/common/info-description-override.d.ts +2 -0
- package/lib/decorators/common/info-description-override.js +24 -0
- package/lib/decorators/common/info-override.d.ts +2 -0
- package/lib/decorators/common/info-override.js +17 -0
- package/lib/decorators/common/media-type-examples-override.d.ts +2 -0
- package/lib/decorators/common/media-type-examples-override.js +59 -0
- package/lib/decorators/common/operation-description-override.d.ts +2 -0
- package/lib/decorators/common/operation-description-override.js +29 -0
- package/lib/decorators/common/registry-dependencies.d.ts +2 -0
- package/lib/decorators/common/registry-dependencies.js +24 -0
- package/lib/decorators/common/remove-x-internal.d.ts +2 -0
- package/lib/decorators/common/remove-x-internal.js +69 -0
- package/lib/decorators/common/tag-description-override.d.ts +2 -0
- package/lib/decorators/common/tag-description-override.js +25 -0
- package/lib/decorators/oas2/index.d.ts +11 -0
- package/lib/decorators/oas2/index.js +21 -0
- package/lib/decorators/oas2/remove-unused-components.d.ts +2 -0
- package/lib/decorators/oas2/remove-unused-components.js +89 -0
- package/lib/decorators/oas3/index.d.ts +12 -0
- package/lib/decorators/oas3/index.js +23 -0
- package/lib/decorators/oas3/remove-unused-components.d.ts +2 -0
- package/lib/decorators/oas3/remove-unused-components.js +100 -0
- package/lib/env.d.ts +2 -0
- package/lib/env.js +7 -0
- package/lib/format/codeframes.d.ts +22 -0
- package/lib/format/codeframes.js +185 -0
- package/lib/format/format.d.ts +20 -0
- package/lib/format/format.js +365 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.js +98 -0
- package/lib/js-yaml/index.d.ts +3 -0
- package/lib/js-yaml/index.js +15 -0
- package/lib/lint.d.ts +32 -0
- package/lib/lint.js +118 -0
- package/lib/logger.d.ts +10 -0
- package/lib/logger.js +31 -0
- package/lib/oas-types.d.ts +36 -0
- package/lib/oas-types.js +92 -0
- package/lib/output.d.ts +3 -0
- package/lib/output.js +9 -0
- package/lib/redocly/domains.d.ts +14 -0
- package/lib/redocly/domains.js +41 -0
- package/lib/redocly/index.d.ts +30 -0
- package/lib/redocly/index.js +131 -0
- package/lib/redocly/redocly-client-types.d.ts +8 -0
- package/lib/redocly/redocly-client-types.js +2 -0
- package/lib/redocly/registry-api-types.d.ts +29 -0
- package/lib/redocly/registry-api-types.js +2 -0
- package/lib/redocly/registry-api.d.ts +17 -0
- package/lib/redocly/registry-api.js +96 -0
- package/lib/ref-utils.d.ts +27 -0
- package/lib/ref-utils.js +85 -0
- package/lib/resolve.d.ts +66 -0
- package/lib/resolve.js +342 -0
- package/lib/rules/ajv.d.ts +10 -0
- package/lib/rules/ajv.js +82 -0
- package/lib/rules/arazzo/criteria-unique.d.ts +2 -0
- package/lib/rules/arazzo/criteria-unique.js +71 -0
- package/lib/rules/arazzo/index.d.ts +3 -0
- package/lib/rules/arazzo/index.js +36 -0
- package/lib/rules/arazzo/parameters-unique.d.ts +2 -0
- package/lib/rules/arazzo/parameters-unique.js +32 -0
- package/lib/rules/arazzo/requestBody-replacements-unique.d.ts +2 -0
- package/lib/rules/arazzo/requestBody-replacements-unique.js +28 -0
- package/lib/rules/arazzo/sourceDescription-type.d.ts +2 -0
- package/lib/rules/arazzo/sourceDescription-type.js +22 -0
- package/lib/rules/arazzo/sourceDescriptions-name-unique.d.ts +2 -0
- package/lib/rules/arazzo/sourceDescriptions-name-unique.js +24 -0
- package/lib/rules/arazzo/sourceDescriptions-not-empty.d.ts +2 -0
- package/lib/rules/arazzo/sourceDescriptions-not-empty.js +18 -0
- package/lib/rules/arazzo/step-onFailure-unique.d.ts +2 -0
- package/lib/rules/arazzo/step-onFailure-unique.js +32 -0
- package/lib/rules/arazzo/step-onSuccess-unique.d.ts +2 -0
- package/lib/rules/arazzo/step-onSuccess-unique.js +32 -0
- package/lib/rules/arazzo/stepId-unique.d.ts +2 -0
- package/lib/rules/arazzo/stepId-unique.js +26 -0
- package/lib/rules/arazzo/workflow-dependsOn.d.ts +2 -0
- package/lib/rules/arazzo/workflow-dependsOn.js +56 -0
- package/lib/rules/arazzo/workflowId-unique.d.ts +2 -0
- package/lib/rules/arazzo/workflowId-unique.js +22 -0
- package/lib/rules/async2/channels-kebab-case.d.ts +2 -0
- package/lib/rules/async2/channels-kebab-case.js +19 -0
- package/lib/rules/async2/index.d.ts +3 -0
- package/lib/rules/async2/index.js +27 -0
- package/lib/rules/async2/no-channel-trailing-slash.d.ts +2 -0
- package/lib/rules/async2/no-channel-trailing-slash.js +16 -0
- package/lib/rules/async3/channels-kebab-case.d.ts +2 -0
- package/lib/rules/async3/channels-kebab-case.js +19 -0
- package/lib/rules/async3/index.d.ts +3 -0
- package/lib/rules/async3/index.js +27 -0
- package/lib/rules/async3/no-channel-trailing-slash.d.ts +2 -0
- package/lib/rules/async3/no-channel-trailing-slash.js +16 -0
- package/lib/rules/common/assertions/asserts.d.ts +30 -0
- package/lib/rules/common/assertions/asserts.js +281 -0
- package/lib/rules/common/assertions/index.d.ts +27 -0
- package/lib/rules/common/assertions/index.js +24 -0
- package/lib/rules/common/assertions/utils.d.ts +28 -0
- package/lib/rules/common/assertions/utils.js +226 -0
- package/lib/rules/common/info-contact.d.ts +2 -0
- package/lib/rules/common/info-contact.js +17 -0
- package/lib/rules/common/info-license-strict.d.ts +2 -0
- package/lib/rules/common/info-license-strict.js +26 -0
- package/lib/rules/common/info-license-url.d.ts +2 -0
- package/lib/rules/common/info-license-url.js +12 -0
- package/lib/rules/common/info-license.d.ts +2 -0
- package/lib/rules/common/info-license.js +17 -0
- package/lib/rules/common/no-ambiguous-paths.d.ts +2 -0
- package/lib/rules/common/no-ambiguous-paths.js +45 -0
- package/lib/rules/common/no-enum-type-mismatch.d.ts +2 -0
- package/lib/rules/common/no-enum-type-mismatch.js +41 -0
- package/lib/rules/common/no-http-verbs-in-paths.d.ts +2 -0
- package/lib/rules/common/no-http-verbs-in-paths.js +33 -0
- package/lib/rules/common/no-identical-paths.d.ts +2 -0
- package/lib/rules/common/no-identical-paths.js +24 -0
- package/lib/rules/common/no-invalid-parameter-examples.d.ts +1 -0
- package/lib/rules/common/no-invalid-parameter-examples.js +24 -0
- package/lib/rules/common/no-invalid-schema-examples.d.ts +1 -0
- package/lib/rules/common/no-invalid-schema-examples.js +22 -0
- package/lib/rules/common/no-path-trailing-slash.d.ts +2 -0
- package/lib/rules/common/no-path-trailing-slash.js +16 -0
- package/lib/rules/common/no-required-schema-properties-undefined.d.ts +2 -0
- package/lib/rules/common/no-required-schema-properties-undefined.js +36 -0
- package/lib/rules/common/operation-2xx-response.d.ts +2 -0
- package/lib/rules/common/operation-2xx-response.js +23 -0
- package/lib/rules/common/operation-4xx-response.d.ts +2 -0
- package/lib/rules/common/operation-4xx-response.js +23 -0
- package/lib/rules/common/operation-description.d.ts +2 -0
- package/lib/rules/common/operation-description.js +12 -0
- package/lib/rules/common/operation-operationId-unique.d.ts +2 -0
- package/lib/rules/common/operation-operationId-unique.js +20 -0
- package/lib/rules/common/operation-operationId-url-safe.d.ts +2 -0
- package/lib/rules/common/operation-operationId-url-safe.js +18 -0
- package/lib/rules/common/operation-operationId.d.ts +2 -0
- package/lib/rules/common/operation-operationId.js +16 -0
- package/lib/rules/common/operation-parameters-unique.d.ts +2 -0
- package/lib/rules/common/operation-parameters-unique.js +40 -0
- package/lib/rules/common/operation-singular-tag.d.ts +2 -0
- package/lib/rules/common/operation-singular-tag.js +16 -0
- package/lib/rules/common/operation-summary.d.ts +2 -0
- package/lib/rules/common/operation-summary.js +12 -0
- package/lib/rules/common/operation-tag-defined.d.ts +2 -0
- package/lib/rules/common/operation-tag-defined.js +24 -0
- package/lib/rules/common/parameter-description.d.ts +2 -0
- package/lib/rules/common/parameter-description.js +22 -0
- package/lib/rules/common/path-declaration-must-exist.d.ts +2 -0
- package/lib/rules/common/path-declaration-must-exist.js +16 -0
- package/lib/rules/common/path-excludes-patterns.d.ts +2 -0
- package/lib/rules/common/path-excludes-patterns.js +22 -0
- package/lib/rules/common/path-http-verbs-order.d.ts +2 -0
- package/lib/rules/common/path-http-verbs-order.js +26 -0
- package/lib/rules/common/path-not-include-query.d.ts +2 -0
- package/lib/rules/common/path-not-include-query.js +18 -0
- package/lib/rules/common/path-params-defined.d.ts +2 -0
- package/lib/rules/common/path-params-defined.js +58 -0
- package/lib/rules/common/path-segment-plural.d.ts +2 -0
- package/lib/rules/common/path-segment-plural.js +33 -0
- package/lib/rules/common/paths-kebab-case.d.ts +2 -0
- package/lib/rules/common/paths-kebab-case.js +20 -0
- package/lib/rules/common/required-string-property-missing-min-length.d.ts +2 -0
- package/lib/rules/common/required-string-property-missing-min-length.js +37 -0
- package/lib/rules/common/response-contains-header.d.ts +2 -0
- package/lib/rules/common/response-contains-header.js +29 -0
- package/lib/rules/common/scalar-property-missing-example.d.ts +2 -0
- package/lib/rules/common/scalar-property-missing-example.js +42 -0
- package/lib/rules/common/security-defined.d.ts +2 -0
- package/lib/rules/common/security-defined.js +65 -0
- package/lib/rules/common/spec-strict-refs.d.ts +2 -0
- package/lib/rules/common/spec-strict-refs.js +30 -0
- package/lib/rules/common/struct.d.ts +2 -0
- package/lib/rules/common/struct.js +158 -0
- package/lib/rules/common/tag-description.d.ts +2 -0
- package/lib/rules/common/tag-description.js +12 -0
- package/lib/rules/common/tags-alphabetical.d.ts +2 -0
- package/lib/rules/common/tags-alphabetical.js +23 -0
- package/lib/rules/no-unresolved-refs.d.ts +5 -0
- package/lib/rules/no-unresolved-refs.js +46 -0
- package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +5 -0
- package/lib/rules/oas2/boolean-parameter-prefixes.js +22 -0
- package/lib/rules/oas2/index.d.ts +3 -0
- package/lib/rules/oas2/index.js +98 -0
- package/lib/rules/oas2/request-mime-type.d.ts +2 -0
- package/lib/rules/oas2/request-mime-type.js +17 -0
- package/lib/rules/oas2/response-contains-property.d.ts +2 -0
- package/lib/rules/oas2/response-contains-property.js +37 -0
- package/lib/rules/oas2/response-mime-type.d.ts +2 -0
- package/lib/rules/oas2/response-mime-type.js +17 -0
- package/lib/rules/oas3/array-parameter-serialization.d.ts +5 -0
- package/lib/rules/oas3/array-parameter-serialization.js +29 -0
- package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +5 -0
- package/lib/rules/oas3/boolean-parameter-prefixes.js +24 -0
- package/lib/rules/oas3/component-name-unique.d.ts +2 -0
- package/lib/rules/oas3/component-name-unique.js +133 -0
- package/lib/rules/oas3/index.d.ts +3 -0
- package/lib/rules/oas3/index.js +122 -0
- package/lib/rules/oas3/no-empty-servers.d.ts +2 -0
- package/lib/rules/oas3/no-empty-servers.js +23 -0
- package/lib/rules/oas3/no-example-value-and-externalValue.d.ts +2 -0
- package/lib/rules/oas3/no-example-value-and-externalValue.js +16 -0
- package/lib/rules/oas3/no-invalid-media-type-examples.d.ts +2 -0
- package/lib/rules/oas3/no-invalid-media-type-examples.js +39 -0
- package/lib/rules/oas3/no-server-example.com.d.ts +2 -0
- package/lib/rules/oas3/no-server-example.com.js +18 -0
- package/lib/rules/oas3/no-server-trailing-slash.d.ts +2 -0
- package/lib/rules/oas3/no-server-trailing-slash.js +18 -0
- package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +2 -0
- package/lib/rules/oas3/no-server-variables-empty-enum.js +66 -0
- package/lib/rules/oas3/no-undefined-server-variable.d.ts +2 -0
- package/lib/rules/oas3/no-undefined-server-variable.js +31 -0
- package/lib/rules/oas3/no-unused-components.d.ts +2 -0
- package/lib/rules/oas3/no-unused-components.js +73 -0
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts +5 -0
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +36 -0
- package/lib/rules/oas3/request-mime-type.d.ts +2 -0
- package/lib/rules/oas3/request-mime-type.js +31 -0
- package/lib/rules/oas3/response-contains-property.d.ts +2 -0
- package/lib/rules/oas3/response-contains-property.js +39 -0
- package/lib/rules/oas3/response-mime-type.d.ts +2 -0
- package/lib/rules/oas3/response-mime-type.js +31 -0
- package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +2 -0
- package/lib/rules/oas3/spec-components-invalid-map-name.js +62 -0
- package/lib/rules/other/stats.d.ts +41 -0
- package/lib/rules/other/stats.js +75 -0
- package/lib/rules/spot/no-criteria-xpath.d.ts +2 -0
- package/lib/rules/spot/no-criteria-xpath.js +21 -0
- package/lib/rules/spot/spot-supported-versions.d.ts +2 -0
- package/lib/rules/spot/spot-supported-versions.js +21 -0
- package/lib/rules/utils.d.ts +22 -0
- package/lib/rules/utils.js +183 -0
- package/lib/types/arazzo.d.ts +2 -0
- package/lib/types/arazzo.js +311 -0
- package/lib/types/asyncapi2.d.ts +17 -0
- package/lib/types/asyncapi2.js +1008 -0
- package/lib/types/asyncapi3.d.ts +2 -0
- package/lib/types/asyncapi3.js +347 -0
- package/lib/types/index.d.ts +57 -0
- package/lib/types/index.js +94 -0
- package/lib/types/json-schema-adapter.d.ts +3 -0
- package/lib/types/json-schema-adapter.js +159 -0
- package/lib/types/oas2.d.ts +3 -0
- package/lib/types/oas2.js +456 -0
- package/lib/types/oas3.d.ts +7 -0
- package/lib/types/oas3.js +554 -0
- package/lib/types/oas3_1.d.ts +6 -0
- package/lib/types/oas3_1.js +285 -0
- package/lib/types/redocly-yaml.d.ts +26 -0
- package/lib/types/redocly-yaml.js +1126 -0
- package/lib/typings/arazzo.d.ts +131 -0
- package/lib/typings/arazzo.js +5 -0
- package/lib/typings/asyncapi.d.ts +21 -0
- package/lib/typings/asyncapi.js +2 -0
- package/lib/typings/asyncapi3.d.ts +53 -0
- package/lib/typings/asyncapi3.js +2 -0
- package/lib/typings/common.d.ts +8 -0
- package/lib/typings/common.js +2 -0
- package/lib/typings/openapi.d.ts +355 -0
- package/lib/typings/openapi.js +2 -0
- package/lib/typings/swagger.d.ts +217 -0
- package/lib/typings/swagger.js +2 -0
- package/lib/utils.d.ts +70 -0
- package/lib/utils.js +301 -0
- package/lib/visitors.d.ts +229 -0
- package/lib/visitors.js +176 -0
- package/lib/walk.d.ts +78 -0
- package/lib/walk.js +290 -0
- package/package.json +59 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoUnresolvedRefs = void 0;
|
|
4
|
+
exports.reportUnresolvedRef = reportUnresolvedRef;
|
|
5
|
+
const resolve_1 = require("../resolve");
|
|
6
|
+
const NoUnresolvedRefs = () => {
|
|
7
|
+
return {
|
|
8
|
+
ref: {
|
|
9
|
+
leave(_, { report, location }, resolved) {
|
|
10
|
+
if (resolved.node !== undefined)
|
|
11
|
+
return;
|
|
12
|
+
reportUnresolvedRef(resolved, report, location);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
DiscriminatorMapping(mapping, { report, resolve, location }) {
|
|
16
|
+
for (const mappingName of Object.keys(mapping)) {
|
|
17
|
+
const resolved = resolve({ $ref: mapping[mappingName] });
|
|
18
|
+
if (resolved.node !== undefined)
|
|
19
|
+
return;
|
|
20
|
+
reportUnresolvedRef(resolved, report, location.child(mappingName));
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.NoUnresolvedRefs = NoUnresolvedRefs;
|
|
26
|
+
function reportUnresolvedRef(resolved, report, location) {
|
|
27
|
+
const error = resolved.error;
|
|
28
|
+
if (error instanceof resolve_1.YamlParseError) {
|
|
29
|
+
report({
|
|
30
|
+
message: 'Failed to parse: ' + error.message,
|
|
31
|
+
location: {
|
|
32
|
+
source: error.source,
|
|
33
|
+
pointer: undefined,
|
|
34
|
+
start: {
|
|
35
|
+
col: error.col,
|
|
36
|
+
line: error.line,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const message = resolved.error?.message;
|
|
42
|
+
report({
|
|
43
|
+
location,
|
|
44
|
+
message: `Can't resolve $ref${message ? ': ' + message : ''}`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanParameterPrefixes = void 0;
|
|
4
|
+
const BooleanParameterPrefixes = (options) => {
|
|
5
|
+
const prefixes = options.prefixes || ['is', 'has'];
|
|
6
|
+
const regexp = new RegExp(`^(${prefixes.join('|')})[A-Z-_]`);
|
|
7
|
+
const wrappedPrefixes = prefixes.map((p) => `\`${p}\``);
|
|
8
|
+
const prefixesString = wrappedPrefixes.length === 1
|
|
9
|
+
? wrappedPrefixes[0]
|
|
10
|
+
: wrappedPrefixes.slice(0, -1).join(', ') + ' or ' + wrappedPrefixes[prefixes.length - 1];
|
|
11
|
+
return {
|
|
12
|
+
Parameter(param, { report, location }) {
|
|
13
|
+
if (param.type === 'boolean' && !regexp.test(param.name)) {
|
|
14
|
+
report({
|
|
15
|
+
message: `Boolean parameter \`${param.name}\` should have ${prefixesString} prefix.`,
|
|
16
|
+
location: location.child('name'),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.BooleanParameterPrefixes = BooleanParameterPrefixes;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.preprocessors = exports.rules = void 0;
|
|
4
|
+
const struct_1 = require("../common/struct");
|
|
5
|
+
const no_invalid_schema_examples_1 = require("../common/no-invalid-schema-examples");
|
|
6
|
+
const no_invalid_parameter_examples_1 = require("../common/no-invalid-parameter-examples");
|
|
7
|
+
const info_contact_1 = require("../common/info-contact");
|
|
8
|
+
const info_license_1 = require("../common/info-license");
|
|
9
|
+
const info_license_url_1 = require("../common/info-license-url");
|
|
10
|
+
const info_license_strict_1 = require("../common/info-license-strict");
|
|
11
|
+
const boolean_parameter_prefixes_1 = require("./boolean-parameter-prefixes");
|
|
12
|
+
const tag_description_1 = require("../common/tag-description");
|
|
13
|
+
const tags_alphabetical_1 = require("../common/tags-alphabetical");
|
|
14
|
+
const paths_kebab_case_1 = require("../common/paths-kebab-case");
|
|
15
|
+
const no_enum_type_mismatch_1 = require("../common/no-enum-type-mismatch");
|
|
16
|
+
const no_path_trailing_slash_1 = require("../common/no-path-trailing-slash");
|
|
17
|
+
const operation_2xx_response_1 = require("../common/operation-2xx-response");
|
|
18
|
+
const operation_4xx_response_1 = require("../common/operation-4xx-response");
|
|
19
|
+
const assertions_1 = require("../common/assertions");
|
|
20
|
+
const operation_operationId_unique_1 = require("../common/operation-operationId-unique");
|
|
21
|
+
const operation_parameters_unique_1 = require("../common/operation-parameters-unique");
|
|
22
|
+
const path_params_defined_1 = require("../common/path-params-defined");
|
|
23
|
+
const operation_tag_defined_1 = require("../common/operation-tag-defined");
|
|
24
|
+
const path_declaration_must_exist_1 = require("../common/path-declaration-must-exist");
|
|
25
|
+
const operation_operationId_url_safe_1 = require("../common/operation-operationId-url-safe");
|
|
26
|
+
const operation_description_1 = require("../common/operation-description");
|
|
27
|
+
const path_not_include_query_1 = require("../common/path-not-include-query");
|
|
28
|
+
const parameter_description_1 = require("../common/parameter-description");
|
|
29
|
+
const operation_singular_tag_1 = require("../common/operation-singular-tag");
|
|
30
|
+
const security_defined_1 = require("../common/security-defined");
|
|
31
|
+
const no_unresolved_refs_1 = require("../no-unresolved-refs");
|
|
32
|
+
const path_http_verbs_order_1 = require("../common/path-http-verbs-order");
|
|
33
|
+
const no_identical_paths_1 = require("../common/no-identical-paths");
|
|
34
|
+
const operation_operationId_1 = require("../common/operation-operationId");
|
|
35
|
+
const operation_summary_1 = require("../common/operation-summary");
|
|
36
|
+
const no_ambiguous_paths_1 = require("../common/no-ambiguous-paths");
|
|
37
|
+
const no_http_verbs_in_paths_1 = require("../common/no-http-verbs-in-paths");
|
|
38
|
+
const path_excludes_patterns_1 = require("../common/path-excludes-patterns");
|
|
39
|
+
const request_mime_type_1 = require("./request-mime-type");
|
|
40
|
+
const response_mime_type_1 = require("./response-mime-type");
|
|
41
|
+
const path_segment_plural_1 = require("../common/path-segment-plural");
|
|
42
|
+
const response_contains_header_1 = require("../common/response-contains-header");
|
|
43
|
+
const response_contains_property_1 = require("./response-contains-property");
|
|
44
|
+
const scalar_property_missing_example_1 = require("../common/scalar-property-missing-example");
|
|
45
|
+
const required_string_property_missing_min_length_1 = require("../common/required-string-property-missing-min-length");
|
|
46
|
+
const spec_strict_refs_1 = require("../common/spec-strict-refs");
|
|
47
|
+
const no_required_schema_properties_undefined_1 = require("../common/no-required-schema-properties-undefined");
|
|
48
|
+
exports.rules = {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
|
+
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future
|
|
51
|
+
spec: struct_1.Struct,
|
|
52
|
+
struct: struct_1.Struct,
|
|
53
|
+
'no-invalid-schema-examples': no_invalid_schema_examples_1.NoInvalidSchemaExamples,
|
|
54
|
+
'no-invalid-parameter-examples': no_invalid_parameter_examples_1.NoInvalidParameterExamples,
|
|
55
|
+
'info-contact': info_contact_1.InfoContact,
|
|
56
|
+
'info-license': info_license_1.InfoLicense,
|
|
57
|
+
'info-license-url': info_license_url_1.InfoLicenseUrl,
|
|
58
|
+
'info-license-strict': info_license_strict_1.InfoLicenseStrict,
|
|
59
|
+
'tag-description': tag_description_1.TagDescription,
|
|
60
|
+
'tags-alphabetical': tags_alphabetical_1.TagsAlphabetical,
|
|
61
|
+
'paths-kebab-case': paths_kebab_case_1.PathsKebabCase,
|
|
62
|
+
'no-enum-type-mismatch': no_enum_type_mismatch_1.NoEnumTypeMismatch,
|
|
63
|
+
'boolean-parameter-prefixes': boolean_parameter_prefixes_1.BooleanParameterPrefixes,
|
|
64
|
+
'no-path-trailing-slash': no_path_trailing_slash_1.NoPathTrailingSlash,
|
|
65
|
+
'operation-2xx-response': operation_2xx_response_1.Operation2xxResponse,
|
|
66
|
+
'operation-4xx-response': operation_4xx_response_1.Operation4xxResponse,
|
|
67
|
+
assertions: assertions_1.Assertions,
|
|
68
|
+
'operation-operationId-unique': operation_operationId_unique_1.OperationIdUnique,
|
|
69
|
+
'operation-parameters-unique': operation_parameters_unique_1.OperationParametersUnique,
|
|
70
|
+
'path-parameters-defined': path_params_defined_1.PathParamsDefined,
|
|
71
|
+
'operation-tag-defined': operation_tag_defined_1.OperationTagDefined,
|
|
72
|
+
'path-declaration-must-exist': path_declaration_must_exist_1.PathDeclarationMustExist,
|
|
73
|
+
'operation-operationId-url-safe': operation_operationId_url_safe_1.OperationIdUrlSafe,
|
|
74
|
+
'operation-operationId': operation_operationId_1.OperationOperationId,
|
|
75
|
+
'operation-summary': operation_summary_1.OperationSummary,
|
|
76
|
+
'operation-description': operation_description_1.OperationDescription,
|
|
77
|
+
'path-not-include-query': path_not_include_query_1.PathNotIncludeQuery,
|
|
78
|
+
'path-params-defined': path_params_defined_1.PathParamsDefined,
|
|
79
|
+
'parameter-description': parameter_description_1.ParameterDescription,
|
|
80
|
+
'operation-singular-tag': operation_singular_tag_1.OperationSingularTag,
|
|
81
|
+
'security-defined': security_defined_1.SecurityDefined,
|
|
82
|
+
'no-unresolved-refs': no_unresolved_refs_1.NoUnresolvedRefs,
|
|
83
|
+
'no-identical-paths': no_identical_paths_1.NoIdenticalPaths,
|
|
84
|
+
'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths,
|
|
85
|
+
'path-http-verbs-order': path_http_verbs_order_1.PathHttpVerbsOrder,
|
|
86
|
+
'no-http-verbs-in-paths': no_http_verbs_in_paths_1.NoHttpVerbsInPaths,
|
|
87
|
+
'path-excludes-patterns': path_excludes_patterns_1.PathExcludesPatterns,
|
|
88
|
+
'request-mime-type': request_mime_type_1.RequestMimeType,
|
|
89
|
+
'response-mime-type': response_mime_type_1.ResponseMimeType,
|
|
90
|
+
'path-segment-plural': path_segment_plural_1.PathSegmentPlural,
|
|
91
|
+
'response-contains-header': response_contains_header_1.ResponseContainsHeader,
|
|
92
|
+
'response-contains-property': response_contains_property_1.ResponseContainsProperty,
|
|
93
|
+
'scalar-property-missing-example': scalar_property_missing_example_1.ScalarPropertyMissingExample,
|
|
94
|
+
'required-string-property-missing-min-length': required_string_property_missing_min_length_1.RequiredStringPropertyMissingMinLength,
|
|
95
|
+
'spec-strict-refs': spec_strict_refs_1.SpecStrictRefs,
|
|
96
|
+
'no-required-schema-properties-undefined': no_required_schema_properties_undefined_1.NoRequiredSchemaPropertiesUndefined,
|
|
97
|
+
};
|
|
98
|
+
exports.preprocessors = {};
|
|
@@ -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
|
+
Root(root, ctx) {
|
|
8
|
+
(0, utils_1.validateMimeType)({ type: 'consumes', value: root }, ctx, allowedValues);
|
|
9
|
+
},
|
|
10
|
+
Operation: {
|
|
11
|
+
leave(operation, ctx) {
|
|
12
|
+
(0, utils_1.validateMimeType)({ type: 'consumes', value: operation }, ctx, allowedValues);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.RequestMimeType = RequestMimeType;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseContainsProperty = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const ResponseContainsProperty = (options) => {
|
|
6
|
+
const names = options.names || {};
|
|
7
|
+
let key;
|
|
8
|
+
return {
|
|
9
|
+
Operation: {
|
|
10
|
+
Response: {
|
|
11
|
+
skip: (_response, key) => {
|
|
12
|
+
return `${key}` === '204';
|
|
13
|
+
},
|
|
14
|
+
enter: (_response, ctx) => {
|
|
15
|
+
key = ctx.key;
|
|
16
|
+
},
|
|
17
|
+
Schema(schema, { report, location }) {
|
|
18
|
+
if (schema.type !== 'object')
|
|
19
|
+
return;
|
|
20
|
+
const expectedProperties = names[key] ||
|
|
21
|
+
names[(0, utils_1.getMatchingStatusCodeRange)(key)] ||
|
|
22
|
+
names[(0, utils_1.getMatchingStatusCodeRange)(key).toLowerCase()] ||
|
|
23
|
+
[];
|
|
24
|
+
for (const expectedProperty of expectedProperties) {
|
|
25
|
+
if (!schema.properties?.[expectedProperty]) {
|
|
26
|
+
report({
|
|
27
|
+
message: `Response object must contain a top-level "${expectedProperty}" property.`,
|
|
28
|
+
location: location.child('properties').key(),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.ResponseContainsProperty = ResponseContainsProperty;
|
|
@@ -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
|
+
Root(root, ctx) {
|
|
8
|
+
(0, utils_1.validateMimeType)({ type: 'produces', value: root }, ctx, allowedValues);
|
|
9
|
+
},
|
|
10
|
+
Operation: {
|
|
11
|
+
leave(operation, ctx) {
|
|
12
|
+
(0, utils_1.validateMimeType)({ type: 'produces', value: operation }, ctx, allowedValues);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.ResponseMimeType = ResponseMimeType;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayParameterSerialization = void 0;
|
|
4
|
+
const ref_utils_1 = require("../../ref-utils");
|
|
5
|
+
const ArrayParameterSerialization = (options) => {
|
|
6
|
+
return {
|
|
7
|
+
Parameter: {
|
|
8
|
+
leave(node, ctx) {
|
|
9
|
+
if (!node.schema) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const schema = ((0, ref_utils_1.isRef)(node.schema) ? ctx.resolve(node.schema).node : node.schema);
|
|
13
|
+
if (schema &&
|
|
14
|
+
shouldReportMissingStyleAndExplode(node, schema, options)) {
|
|
15
|
+
ctx.report({
|
|
16
|
+
message: `Parameter \`${node.name}\` should have \`style\` and \`explode \` fields`,
|
|
17
|
+
location: ctx.location,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.ArrayParameterSerialization = ArrayParameterSerialization;
|
|
25
|
+
function shouldReportMissingStyleAndExplode(node, schema, options) {
|
|
26
|
+
return ((schema.type === 'array' || schema.items || schema.prefixItems) &&
|
|
27
|
+
(node.style === undefined || node.explode === undefined) &&
|
|
28
|
+
(!options.in || (node.in && options.in?.includes(node.in))));
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanParameterPrefixes = void 0;
|
|
4
|
+
const BooleanParameterPrefixes = (options) => {
|
|
5
|
+
const prefixes = options.prefixes || ['is', 'has'];
|
|
6
|
+
const regexp = new RegExp(`^(${prefixes.join('|')})[A-Z-_]`);
|
|
7
|
+
const wrappedPrefixes = prefixes.map((p) => `\`${p}\``);
|
|
8
|
+
const prefixesString = wrappedPrefixes.length === 1
|
|
9
|
+
? wrappedPrefixes[0]
|
|
10
|
+
: wrappedPrefixes.slice(0, -1).join(', ') + ' or ' + wrappedPrefixes[prefixes.length - 1];
|
|
11
|
+
return {
|
|
12
|
+
Parameter: {
|
|
13
|
+
Schema(schema, { report, parentLocations }, parents) {
|
|
14
|
+
if (schema.type === 'boolean' && !regexp.test(parents.Parameter.name)) {
|
|
15
|
+
report({
|
|
16
|
+
message: `Boolean parameter \`${parents.Parameter.name}\` should have ${prefixesString} prefix.`,
|
|
17
|
+
location: parentLocations.Parameter.child(['name']),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.BooleanParameterPrefixes = BooleanParameterPrefixes;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentNameUnique = void 0;
|
|
4
|
+
const TYPE_NAME_SCHEMA = 'Schema';
|
|
5
|
+
const TYPE_NAME_PARAMETER = 'Parameter';
|
|
6
|
+
const TYPE_NAME_RESPONSE = 'Response';
|
|
7
|
+
const TYPE_NAME_REQUEST_BODY = 'RequestBody';
|
|
8
|
+
const TYPE_NAME_TO_OPTION_COMPONENT_NAME = {
|
|
9
|
+
[TYPE_NAME_SCHEMA]: 'schemas',
|
|
10
|
+
[TYPE_NAME_PARAMETER]: 'parameters',
|
|
11
|
+
[TYPE_NAME_RESPONSE]: 'responses',
|
|
12
|
+
[TYPE_NAME_REQUEST_BODY]: 'requestBodies',
|
|
13
|
+
};
|
|
14
|
+
const ComponentNameUnique = (options) => {
|
|
15
|
+
const components = new Map();
|
|
16
|
+
const typeNames = [];
|
|
17
|
+
if (options.schemas !== 'off') {
|
|
18
|
+
typeNames.push(TYPE_NAME_SCHEMA);
|
|
19
|
+
}
|
|
20
|
+
if (options.parameters !== 'off') {
|
|
21
|
+
typeNames.push(TYPE_NAME_PARAMETER);
|
|
22
|
+
}
|
|
23
|
+
if (options.responses !== 'off') {
|
|
24
|
+
typeNames.push(TYPE_NAME_RESPONSE);
|
|
25
|
+
}
|
|
26
|
+
if (options.requestBodies !== 'off') {
|
|
27
|
+
typeNames.push(TYPE_NAME_REQUEST_BODY);
|
|
28
|
+
}
|
|
29
|
+
const rule = {
|
|
30
|
+
ref: {
|
|
31
|
+
leave(ref, { type, resolve }) {
|
|
32
|
+
const typeName = type.name;
|
|
33
|
+
if (typeNames.includes(typeName)) {
|
|
34
|
+
const resolvedRef = resolve(ref);
|
|
35
|
+
if (!resolvedRef.location)
|
|
36
|
+
return;
|
|
37
|
+
addComponentFromAbsoluteLocation(typeName, resolvedRef.location);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
Root: {
|
|
42
|
+
leave(root, ctx) {
|
|
43
|
+
components.forEach((value, key, _) => {
|
|
44
|
+
if (value.absolutePointers.size > 1) {
|
|
45
|
+
const component = getComponentFromKey(key);
|
|
46
|
+
const optionComponentName = getOptionComponentNameForTypeName(component.typeName);
|
|
47
|
+
const componentSeverity = optionComponentName ? options[optionComponentName] : null;
|
|
48
|
+
for (const location of value.locations) {
|
|
49
|
+
const definitions = Array.from(value.absolutePointers)
|
|
50
|
+
.filter((v) => v !== location.absolutePointer.toString())
|
|
51
|
+
.map((v) => `- ${v}`)
|
|
52
|
+
.join('\n');
|
|
53
|
+
const problem = {
|
|
54
|
+
message: `Component '${optionComponentName}/${component.componentName}' is not unique. It is also defined at:\n${definitions}`,
|
|
55
|
+
location: location,
|
|
56
|
+
};
|
|
57
|
+
if (componentSeverity) {
|
|
58
|
+
problem.forceSeverity = componentSeverity;
|
|
59
|
+
}
|
|
60
|
+
ctx.report(problem);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
if (options.schemas != 'off') {
|
|
68
|
+
rule.NamedSchemas = {
|
|
69
|
+
Schema(_, { location }) {
|
|
70
|
+
addComponentFromAbsoluteLocation(TYPE_NAME_SCHEMA, location);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (options.responses != 'off') {
|
|
75
|
+
rule.NamedResponses = {
|
|
76
|
+
Response(_, { location }) {
|
|
77
|
+
addComponentFromAbsoluteLocation(TYPE_NAME_RESPONSE, location);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (options.parameters != 'off') {
|
|
82
|
+
rule.NamedParameters = {
|
|
83
|
+
Parameter(_, { location }) {
|
|
84
|
+
addComponentFromAbsoluteLocation(TYPE_NAME_PARAMETER, location);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (options.requestBodies != 'off') {
|
|
89
|
+
rule.NamedRequestBodies = {
|
|
90
|
+
RequestBody(_, { location }) {
|
|
91
|
+
addComponentFromAbsoluteLocation(TYPE_NAME_REQUEST_BODY, location);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return rule;
|
|
96
|
+
function getComponentNameFromAbsoluteLocation(absoluteLocation) {
|
|
97
|
+
const componentName = absoluteLocation.split('/').slice(-1)[0];
|
|
98
|
+
if (componentName.endsWith('.yml') ||
|
|
99
|
+
componentName.endsWith('.yaml') ||
|
|
100
|
+
componentName.endsWith('.json')) {
|
|
101
|
+
return componentName.slice(0, componentName.lastIndexOf('.'));
|
|
102
|
+
}
|
|
103
|
+
return componentName;
|
|
104
|
+
}
|
|
105
|
+
function addFoundComponent(typeName, componentName, location) {
|
|
106
|
+
const key = getKeyForComponent(typeName, componentName);
|
|
107
|
+
const entry = components.get(key) ?? {
|
|
108
|
+
absolutePointers: new Set(),
|
|
109
|
+
locations: [],
|
|
110
|
+
};
|
|
111
|
+
const absoluteLocation = location.absolutePointer.toString();
|
|
112
|
+
if (!entry.absolutePointers.has(absoluteLocation)) {
|
|
113
|
+
entry.absolutePointers.add(absoluteLocation);
|
|
114
|
+
entry.locations.push(location);
|
|
115
|
+
}
|
|
116
|
+
components.set(key, entry);
|
|
117
|
+
}
|
|
118
|
+
function addComponentFromAbsoluteLocation(typeName, location) {
|
|
119
|
+
const componentName = getComponentNameFromAbsoluteLocation(location.absolutePointer.toString());
|
|
120
|
+
addFoundComponent(typeName, componentName, location);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
exports.ComponentNameUnique = ComponentNameUnique;
|
|
124
|
+
function getOptionComponentNameForTypeName(typeName) {
|
|
125
|
+
return TYPE_NAME_TO_OPTION_COMPONENT_NAME[typeName] ?? null;
|
|
126
|
+
}
|
|
127
|
+
function getKeyForComponent(typeName, componentName) {
|
|
128
|
+
return `${typeName}/${componentName}`;
|
|
129
|
+
}
|
|
130
|
+
function getComponentFromKey(key) {
|
|
131
|
+
const [typeName, componentName] = key.split('/');
|
|
132
|
+
return { typeName, componentName };
|
|
133
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.preprocessors = exports.rules = void 0;
|
|
4
|
+
const struct_1 = require("../common/struct");
|
|
5
|
+
const operation_2xx_response_1 = require("../common/operation-2xx-response");
|
|
6
|
+
const operation_4xx_response_1 = require("../common/operation-4xx-response");
|
|
7
|
+
const assertions_1 = require("../common/assertions");
|
|
8
|
+
const operation_operationId_unique_1 = require("../common/operation-operationId-unique");
|
|
9
|
+
const operation_parameters_unique_1 = require("../common/operation-parameters-unique");
|
|
10
|
+
const path_params_defined_1 = require("../common/path-params-defined");
|
|
11
|
+
const operation_tag_defined_1 = require("../common/operation-tag-defined");
|
|
12
|
+
const no_example_value_and_externalValue_1 = require("./no-example-value-and-externalValue");
|
|
13
|
+
const no_enum_type_mismatch_1 = require("../common/no-enum-type-mismatch");
|
|
14
|
+
const no_path_trailing_slash_1 = require("../common/no-path-trailing-slash");
|
|
15
|
+
const path_declaration_must_exist_1 = require("../common/path-declaration-must-exist");
|
|
16
|
+
const operation_operationId_url_safe_1 = require("../common/operation-operationId-url-safe");
|
|
17
|
+
const tags_alphabetical_1 = require("../common/tags-alphabetical");
|
|
18
|
+
const no_server_example_com_1 = require("./no-server-example.com");
|
|
19
|
+
const no_server_trailing_slash_1 = require("./no-server-trailing-slash");
|
|
20
|
+
const tag_description_1 = require("../common/tag-description");
|
|
21
|
+
const info_contact_1 = require("../common/info-contact");
|
|
22
|
+
const info_license_1 = require("../common/info-license");
|
|
23
|
+
const info_license_url_1 = require("../common/info-license-url");
|
|
24
|
+
const info_license_strict_1 = require("../common/info-license-strict");
|
|
25
|
+
const operation_description_1 = require("../common/operation-description");
|
|
26
|
+
const no_unused_components_1 = require("./no-unused-components");
|
|
27
|
+
const path_not_include_query_1 = require("../common/path-not-include-query");
|
|
28
|
+
const parameter_description_1 = require("../common/parameter-description");
|
|
29
|
+
const operation_singular_tag_1 = require("../common/operation-singular-tag");
|
|
30
|
+
const security_defined_1 = require("../common/security-defined");
|
|
31
|
+
const no_unresolved_refs_1 = require("../no-unresolved-refs");
|
|
32
|
+
const boolean_parameter_prefixes_1 = require("./boolean-parameter-prefixes");
|
|
33
|
+
const paths_kebab_case_1 = require("../common/paths-kebab-case");
|
|
34
|
+
const path_http_verbs_order_1 = require("../common/path-http-verbs-order");
|
|
35
|
+
const no_empty_servers_1 = require("./no-empty-servers");
|
|
36
|
+
const no_invalid_media_type_examples_1 = require("./no-invalid-media-type-examples");
|
|
37
|
+
const no_identical_paths_1 = require("../common/no-identical-paths");
|
|
38
|
+
const no_undefined_server_variable_1 = require("./no-undefined-server-variable");
|
|
39
|
+
const operation_operationId_1 = require("../common/operation-operationId");
|
|
40
|
+
const operation_summary_1 = require("../common/operation-summary");
|
|
41
|
+
const no_ambiguous_paths_1 = require("../common/no-ambiguous-paths");
|
|
42
|
+
const no_server_variables_empty_enum_1 = require("./no-server-variables-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 path_excludes_patterns_1 = require("../common/path-excludes-patterns");
|
|
48
|
+
const no_invalid_schema_examples_1 = require("../common/no-invalid-schema-examples");
|
|
49
|
+
const no_invalid_parameter_examples_1 = require("../common/no-invalid-parameter-examples");
|
|
50
|
+
const response_contains_header_1 = require("../common/response-contains-header");
|
|
51
|
+
const response_contains_property_1 = require("./response-contains-property");
|
|
52
|
+
const scalar_property_missing_example_1 = require("../common/scalar-property-missing-example");
|
|
53
|
+
const spec_components_invalid_map_name_1 = require("./spec-components-invalid-map-name");
|
|
54
|
+
const operation_4xx_problem_details_rfc7807_1 = require("./operation-4xx-problem-details-rfc7807");
|
|
55
|
+
const required_string_property_missing_min_length_1 = require("../common/required-string-property-missing-min-length");
|
|
56
|
+
const spec_strict_refs_1 = require("../common/spec-strict-refs");
|
|
57
|
+
const component_name_unique_1 = require("./component-name-unique");
|
|
58
|
+
const array_parameter_serialization_1 = require("./array-parameter-serialization");
|
|
59
|
+
const no_required_schema_properties_undefined_1 = require("../common/no-required-schema-properties-undefined");
|
|
60
|
+
exports.rules = {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
62
|
+
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future
|
|
63
|
+
spec: struct_1.Struct,
|
|
64
|
+
struct: struct_1.Struct,
|
|
65
|
+
'info-contact': info_contact_1.InfoContact,
|
|
66
|
+
'info-license': info_license_1.InfoLicense,
|
|
67
|
+
'info-license-url': info_license_url_1.InfoLicenseUrl,
|
|
68
|
+
'info-license-strict': info_license_strict_1.InfoLicenseStrict,
|
|
69
|
+
'operation-2xx-response': operation_2xx_response_1.Operation2xxResponse,
|
|
70
|
+
'operation-4xx-response': operation_4xx_response_1.Operation4xxResponse,
|
|
71
|
+
'operation-4xx-problem-details-rfc7807': operation_4xx_problem_details_rfc7807_1.Operation4xxProblemDetailsRfc7807,
|
|
72
|
+
assertions: assertions_1.Assertions,
|
|
73
|
+
'operation-operationId-unique': operation_operationId_unique_1.OperationIdUnique,
|
|
74
|
+
'operation-parameters-unique': operation_parameters_unique_1.OperationParametersUnique,
|
|
75
|
+
'operation-tag-defined': operation_tag_defined_1.OperationTagDefined,
|
|
76
|
+
'no-example-value-and-externalValue': no_example_value_and_externalValue_1.NoExampleValueAndExternalValue,
|
|
77
|
+
'no-enum-type-mismatch': no_enum_type_mismatch_1.NoEnumTypeMismatch,
|
|
78
|
+
'no-path-trailing-slash': no_path_trailing_slash_1.NoPathTrailingSlash,
|
|
79
|
+
'no-empty-servers': no_empty_servers_1.NoEmptyServers,
|
|
80
|
+
'path-declaration-must-exist': path_declaration_must_exist_1.PathDeclarationMustExist,
|
|
81
|
+
'operation-operationId-url-safe': operation_operationId_url_safe_1.OperationIdUrlSafe,
|
|
82
|
+
'operation-operationId': operation_operationId_1.OperationOperationId,
|
|
83
|
+
'operation-summary': operation_summary_1.OperationSummary,
|
|
84
|
+
'tags-alphabetical': tags_alphabetical_1.TagsAlphabetical,
|
|
85
|
+
'no-server-example.com': no_server_example_com_1.NoServerExample,
|
|
86
|
+
'no-server-trailing-slash': no_server_trailing_slash_1.NoServerTrailingSlash,
|
|
87
|
+
'tag-description': tag_description_1.TagDescription,
|
|
88
|
+
'operation-description': operation_description_1.OperationDescription,
|
|
89
|
+
'no-unused-components': no_unused_components_1.NoUnusedComponents,
|
|
90
|
+
'path-not-include-query': path_not_include_query_1.PathNotIncludeQuery,
|
|
91
|
+
'path-parameters-defined': path_params_defined_1.PathParamsDefined,
|
|
92
|
+
'path-params-defined': path_params_defined_1.PathParamsDefined,
|
|
93
|
+
'parameter-description': parameter_description_1.ParameterDescription,
|
|
94
|
+
'operation-singular-tag': operation_singular_tag_1.OperationSingularTag,
|
|
95
|
+
'security-defined': security_defined_1.SecurityDefined,
|
|
96
|
+
'no-unresolved-refs': no_unresolved_refs_1.NoUnresolvedRefs,
|
|
97
|
+
'paths-kebab-case': paths_kebab_case_1.PathsKebabCase,
|
|
98
|
+
'boolean-parameter-prefixes': boolean_parameter_prefixes_1.BooleanParameterPrefixes,
|
|
99
|
+
'path-http-verbs-order': path_http_verbs_order_1.PathHttpVerbsOrder,
|
|
100
|
+
'no-invalid-media-type-examples': no_invalid_media_type_examples_1.ValidContentExamples,
|
|
101
|
+
'no-identical-paths': no_identical_paths_1.NoIdenticalPaths,
|
|
102
|
+
'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths,
|
|
103
|
+
'no-undefined-server-variable': no_undefined_server_variable_1.NoUndefinedServerVariable,
|
|
104
|
+
'no-server-variables-empty-enum': no_server_variables_empty_enum_1.NoServerVariablesEmptyEnum,
|
|
105
|
+
'no-http-verbs-in-paths': no_http_verbs_in_paths_1.NoHttpVerbsInPaths,
|
|
106
|
+
'path-excludes-patterns': path_excludes_patterns_1.PathExcludesPatterns,
|
|
107
|
+
'request-mime-type': request_mime_type_1.RequestMimeType,
|
|
108
|
+
'response-mime-type': response_mime_type_1.ResponseMimeType,
|
|
109
|
+
'path-segment-plural': path_segment_plural_1.PathSegmentPlural,
|
|
110
|
+
'no-invalid-schema-examples': no_invalid_schema_examples_1.NoInvalidSchemaExamples,
|
|
111
|
+
'no-invalid-parameter-examples': no_invalid_parameter_examples_1.NoInvalidParameterExamples,
|
|
112
|
+
'response-contains-header': response_contains_header_1.ResponseContainsHeader,
|
|
113
|
+
'response-contains-property': response_contains_property_1.ResponseContainsProperty,
|
|
114
|
+
'scalar-property-missing-example': scalar_property_missing_example_1.ScalarPropertyMissingExample,
|
|
115
|
+
'spec-components-invalid-map-name': spec_components_invalid_map_name_1.SpecComponentsInvalidMapName,
|
|
116
|
+
'required-string-property-missing-min-length': required_string_property_missing_min_length_1.RequiredStringPropertyMissingMinLength,
|
|
117
|
+
'spec-strict-refs': spec_strict_refs_1.SpecStrictRefs,
|
|
118
|
+
'component-name-unique': component_name_unique_1.ComponentNameUnique,
|
|
119
|
+
'array-parameter-serialization': array_parameter_serialization_1.ArrayParameterSerialization,
|
|
120
|
+
'no-required-schema-properties-undefined': no_required_schema_properties_undefined_1.NoRequiredSchemaPropertiesUndefined,
|
|
121
|
+
};
|
|
122
|
+
exports.preprocessors = {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoEmptyServers = void 0;
|
|
4
|
+
const NoEmptyServers = () => {
|
|
5
|
+
return {
|
|
6
|
+
Root(root, { report, location }) {
|
|
7
|
+
if (!root.hasOwnProperty('servers')) {
|
|
8
|
+
report({
|
|
9
|
+
message: 'Servers must be present.',
|
|
10
|
+
location: location.child(['openapi']).key(),
|
|
11
|
+
});
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (!Array.isArray(root.servers) || root.servers.length === 0) {
|
|
15
|
+
report({
|
|
16
|
+
message: 'Servers must be a non-empty array.',
|
|
17
|
+
location: location.child(['servers']).key(),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.NoEmptyServers = NoEmptyServers;
|