@redocly/openapi-core 1.0.0-beta.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 +25 -0
- package/__tests__/utils.ts +86 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.d.ts +3 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +34 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.d.ts +3 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +40 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.d.ts +3 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +21 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.d.ts +3 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +34 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.d.ts +3 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +32 -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 +31 -0
- package/lib/bundle.d.ts +47 -0
- package/lib/bundle.js +291 -0
- package/lib/config/all.d.ts +3 -0
- package/lib/config/all.js +65 -0
- package/lib/config/builtIn.d.ts +3 -0
- package/lib/config/builtIn.js +36 -0
- package/lib/config/config-resolvers.d.ts +16 -0
- package/lib/config/config-resolvers.js +242 -0
- package/lib/config/config.d.ts +64 -0
- package/lib/config/config.js +244 -0
- package/lib/config/index.d.ts +7 -0
- package/lib/config/index.js +19 -0
- package/lib/config/load.d.ts +6 -0
- package/lib/config/load.js +93 -0
- package/lib/config/minimal.d.ts +3 -0
- package/lib/config/minimal.js +58 -0
- package/lib/config/recommended.d.ts +3 -0
- package/lib/config/recommended.js +58 -0
- package/lib/config/rules.d.ts +7 -0
- package/lib/config/rules.js +34 -0
- package/lib/config/types.d.ts +113 -0
- package/lib/config/types.js +2 -0
- package/lib/config/utils.d.ts +13 -0
- package/lib/config/utils.js +160 -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/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 +58 -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 +8 -0
- package/lib/decorators/oas2/index.js +15 -0
- package/lib/decorators/oas3/index.d.ts +8 -0
- package/lib/decorators/oas3/index.js +15 -0
- package/lib/format/codeframes.d.ts +22 -0
- package/lib/format/codeframes.js +177 -0
- package/lib/format/format.d.ts +20 -0
- package/lib/format/format.js +236 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +69 -0
- package/lib/js-yaml/index.d.ts +3 -0
- package/lib/js-yaml/index.js +19 -0
- package/lib/lint.d.ts +23 -0
- package/lib/lint.js +99 -0
- package/lib/oas-types.d.ts +19 -0
- package/lib/oas-types.js +45 -0
- package/lib/redocly/index.d.ts +30 -0
- package/lib/redocly/index.js +153 -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 +106 -0
- package/lib/ref-utils.d.ts +25 -0
- package/lib/ref-utils.js +75 -0
- package/lib/resolve.d.ts +66 -0
- package/lib/resolve.js +311 -0
- package/lib/rules/ajv.d.ts +10 -0
- package/lib/rules/ajv.js +80 -0
- package/lib/rules/common/assertions/asserts.d.ts +5 -0
- package/lib/rules/common/assertions/asserts.js +143 -0
- package/lib/rules/common/assertions/index.d.ts +2 -0
- package/lib/rules/common/assertions/index.js +52 -0
- package/lib/rules/common/assertions/utils.d.ts +20 -0
- package/lib/rules/common/assertions/utils.js +127 -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-description.d.ts +2 -0
- package/lib/rules/common/info-description.js +12 -0
- package/lib/rules/common/info-license-url.d.ts +2 -0
- package/lib/rules/common/info-license-url.js +17 -0
- package/lib/rules/common/license-url.d.ts +2 -0
- package/lib/rules/common/license-url.js +12 -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 +43 -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 +25 -0
- package/lib/rules/common/no-invalid-schema-examples.d.ts +1 -0
- package/lib/rules/common/no-invalid-schema-examples.js +23 -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/operation-2xx-response.d.ts +2 -0
- package/lib/rules/common/operation-2xx-response.js +17 -0
- package/lib/rules/common/operation-4xx-response.d.ts +2 -0
- package/lib/rules/common/operation-4xx-response.js +17 -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 +17 -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-security-defined.d.ts +2 -0
- package/lib/rules/common/operation-security-defined.js +38 -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 +25 -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 +53 -0
- package/lib/rules/common/path-segment-plural.d.ts +2 -0
- package/lib/rules/common/path-segment-plural.js +32 -0
- package/lib/rules/common/paths-kebab-case.d.ts +2 -0
- package/lib/rules/common/paths-kebab-case.js +17 -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/spec.d.ts +2 -0
- package/lib/rules/common/spec.js +136 -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 +20 -0
- package/lib/rules/no-unresolved-refs.d.ts +5 -0
- package/lib/rules/no-unresolved-refs.js +47 -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 +46 -0
- package/lib/rules/oas2/index.js +89 -0
- package/lib/rules/oas2/remove-unused-components.d.ts +2 -0
- package/lib/rules/oas2/remove-unused-components.js +73 -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 +38 -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/boolean-parameter-prefixes.d.ts +5 -0
- package/lib/rules/oas3/boolean-parameter-prefixes.js +24 -0
- package/lib/rules/oas3/index.d.ts +3 -0
- package/lib/rules/oas3/index.js +105 -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 +37 -0
- package/lib/rules/oas3/no-server-example.com.d.ts +2 -0
- package/lib/rules/oas3/no-server-example.com.js +16 -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-servers-empty-enum.d.ts +2 -0
- package/lib/rules/oas3/no-servers-empty-enum.js +67 -0
- package/lib/rules/oas3/no-undefined-server-variable.d.ts +2 -0
- package/lib/rules/oas3/no-undefined-server-variable.js +32 -0
- package/lib/rules/oas3/no-unused-components.d.ts +2 -0
- package/lib/rules/oas3/no-unused-components.js +74 -0
- package/lib/rules/oas3/remove-unused-components.d.ts +2 -0
- package/lib/rules/oas3/remove-unused-components.js +83 -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 +40 -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/other/stats.d.ts +41 -0
- package/lib/rules/other/stats.js +44 -0
- package/lib/rules/utils.d.ts +17 -0
- package/lib/rules/utils.js +107 -0
- package/lib/types/index.d.ts +56 -0
- package/lib/types/index.js +77 -0
- package/lib/types/oas2.d.ts +2 -0
- package/lib/types/oas2.js +380 -0
- package/lib/types/oas3.d.ts +2 -0
- package/lib/types/oas3.js +479 -0
- package/lib/types/oas3_1.d.ts +2 -0
- package/lib/types/oas3_1.js +247 -0
- package/lib/types/redocly-yaml.d.ts +2 -0
- package/lib/types/redocly-yaml.js +533 -0
- package/lib/typings/common.d.ts +8 -0
- package/lib/typings/common.js +2 -0
- package/lib/typings/openapi.d.ts +299 -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 +41 -0
- package/lib/utils.js +177 -0
- package/lib/visitors.d.ts +175 -0
- package/lib/visitors.js +140 -0
- package/lib/walk.d.ts +87 -0
- package/lib/walk.js +253 -0
- package/package.json +56 -0
- package/src/__tests__/__snapshots__/bundle.test.ts.snap +255 -0
- package/src/__tests__/bundle.test.ts +156 -0
- package/src/__tests__/codeframes.test.ts +531 -0
- package/src/__tests__/fixtures/extension.js +24 -0
- package/src/__tests__/fixtures/refs/definitions.yaml +3 -0
- package/src/__tests__/fixtures/refs/examples.yaml +8 -0
- package/src/__tests__/fixtures/refs/external-request-body.yaml +13 -0
- package/src/__tests__/fixtures/refs/externalref.yaml +35 -0
- package/src/__tests__/fixtures/refs/hosted.yaml +35 -0
- package/src/__tests__/fixtures/refs/openapi-with-external-refs-conflicting-names.yaml +21 -0
- package/src/__tests__/fixtures/refs/openapi-with-external-refs.yaml +33 -0
- package/src/__tests__/fixtures/refs/openapi-with-url-refs.yaml +18 -0
- package/src/__tests__/fixtures/refs/param-b.yaml +1 -0
- package/src/__tests__/fixtures/refs/param-c.yaml +1 -0
- package/src/__tests__/fixtures/refs/rename.yaml +1 -0
- package/src/__tests__/fixtures/refs/requestBody.yaml +9 -0
- package/src/__tests__/fixtures/refs/schema-a.yaml +1 -0
- package/src/__tests__/fixtures/refs/simple.yaml +1 -0
- package/src/__tests__/fixtures/refs/vendor.schema.yaml +20 -0
- package/src/__tests__/fixtures/resolve/External.yaml +10 -0
- package/src/__tests__/fixtures/resolve/External2.yaml +4 -0
- package/src/__tests__/fixtures/resolve/description.md +3 -0
- package/src/__tests__/fixtures/resolve/externalInfo.yaml +4 -0
- package/src/__tests__/fixtures/resolve/externalLicense.yaml +1 -0
- package/src/__tests__/fixtures/resolve/openapi-with-back.yaml +13 -0
- package/src/__tests__/fixtures/resolve/openapi-with-md-description.yaml +5 -0
- package/src/__tests__/fixtures/resolve/openapi.yaml +28 -0
- package/src/__tests__/fixtures/resolve/schemas/type-a.yaml +10 -0
- package/src/__tests__/fixtures/resolve/schemas/type-b.yaml +6 -0
- package/src/__tests__/fixtures/resolve/transitive/a.yaml +1 -0
- package/src/__tests__/fixtures/resolve/transitive/components.yaml +5 -0
- package/src/__tests__/fixtures/resolve/transitive/schemas.yaml +3 -0
- package/src/__tests__/js-yaml.test.ts +71 -0
- package/src/__tests__/lint.test.ts +232 -0
- package/src/__tests__/login.test.ts +17 -0
- package/src/__tests__/normalizeVisitors.test.ts +151 -0
- package/src/__tests__/ref-utils.test.ts +120 -0
- package/src/__tests__/resolve-http.test.ts +77 -0
- package/src/__tests__/resolve.test.ts +405 -0
- package/src/__tests__/utils.test.ts +85 -0
- package/src/__tests__/walk.test.ts +1485 -0
- package/src/benchmark/benches/lint-with-many-rules.bench.ts +35 -0
- package/src/benchmark/benches/lint-with-nested-rule.bench.ts +39 -0
- package/src/benchmark/benches/lint-with-no-rules.bench.ts +20 -0
- package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +36 -0
- package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +32 -0
- package/src/benchmark/benches/rebilly.yaml +32267 -0
- package/src/benchmark/benches/recommended-oas3.bench.ts +22 -0
- package/src/benchmark/benches/resolve-with-no-external.bench.ts +23 -0
- package/src/benchmark/benchmark.js +307 -0
- package/src/benchmark/colors.js +29 -0
- package/src/benchmark/fork.js +83 -0
- package/src/benchmark/utils.ts +36 -0
- package/src/bundle.ts +386 -0
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +157 -0
- package/src/config/__tests__/config-resolvers.test.ts +429 -0
- package/src/config/__tests__/config.test.ts +244 -0
- package/src/config/__tests__/fixtures/plugin-config.yaml +3 -0
- package/src/config/__tests__/fixtures/plugin.js +56 -0
- package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +12 -0
- package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +67 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-circular.yaml +8 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +19 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config.yaml +10 -0
- package/src/config/__tests__/fixtures/resolve-config/plugin.js +66 -0
- package/src/config/__tests__/fixtures/resolve-remote-configs/nested-remote-config.yaml +4 -0
- package/src/config/__tests__/fixtures/resolve-remote-configs/remote-config.yaml +5 -0
- package/src/config/__tests__/load.test.ts +83 -0
- package/src/config/__tests__/resolve-plugins.test.ts +27 -0
- package/src/config/all.ts +66 -0
- package/src/config/builtIn.ts +37 -0
- package/src/config/config-resolvers.ts +359 -0
- package/src/config/config.ts +312 -0
- package/src/config/index.ts +7 -0
- package/src/config/load.ts +84 -0
- package/src/config/minimal.ts +58 -0
- package/src/config/recommended.ts +58 -0
- package/src/config/rules.ts +46 -0
- package/src/config/types.ts +168 -0
- package/src/config/utils.ts +208 -0
- package/src/decorators/__tests__/remove-x-internal.test.ts +316 -0
- package/src/decorators/common/info-description-override.ts +24 -0
- package/src/decorators/common/operation-description-override.ts +30 -0
- package/src/decorators/common/registry-dependencies.ts +25 -0
- package/src/decorators/common/remove-x-internal.ts +59 -0
- package/src/decorators/common/tag-description-override.ts +25 -0
- package/src/decorators/oas2/index.ts +14 -0
- package/src/decorators/oas3/index.ts +14 -0
- package/src/format/codeframes.ts +210 -0
- package/src/format/format.ts +339 -0
- package/src/index.ts +68 -0
- package/src/js-yaml/index.ts +18 -0
- package/src/lint.ts +125 -0
- package/src/oas-types.ts +62 -0
- package/src/redocly/__tests__/redocly-client.test.ts +140 -0
- package/src/redocly/index.ts +182 -0
- package/src/redocly/redocly-client-types.ts +10 -0
- package/src/redocly/registry-api-types.ts +32 -0
- package/src/redocly/registry-api.ts +134 -0
- package/src/ref-utils.ts +80 -0
- package/src/resolve.ts +378 -0
- package/src/rules/__tests__/fixtures/invalid-yaml.yaml +1 -0
- package/src/rules/__tests__/fixtures/ref.yaml +1 -0
- package/src/rules/__tests__/no-unresolved-refs.test.ts +168 -0
- package/src/rules/ajv.ts +103 -0
- package/src/rules/common/__tests__/info-description.test.ts +102 -0
- package/src/rules/common/__tests__/info-license.test.ts +62 -0
- package/src/rules/common/__tests__/license-url.test.ts +63 -0
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +96 -0
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +209 -0
- package/src/rules/common/__tests__/no-identical-paths.test.ts +58 -0
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +85 -0
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +91 -0
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +107 -0
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +76 -0
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +45 -0
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +167 -0
- package/src/rules/common/__tests__/operation-security-defined.test.ts +69 -0
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +72 -0
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +95 -0
- package/src/rules/common/__tests__/path-not-include-query.test.ts +64 -0
- package/src/rules/common/__tests__/path-params-defined.test.ts +133 -0
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +108 -0
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +264 -0
- package/src/rules/common/__tests__/spec.test.ts +62 -0
- package/src/rules/common/__tests__/tag-description.test.ts +65 -0
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +64 -0
- package/src/rules/common/assertions/__tests__/asserts.test.ts +231 -0
- package/src/rules/common/assertions/__tests__/index.test.ts +65 -0
- package/src/rules/common/assertions/__tests__/utils.test.ts +89 -0
- package/src/rules/common/assertions/asserts.ts +137 -0
- package/src/rules/common/assertions/index.ts +75 -0
- package/src/rules/common/assertions/utils.ts +167 -0
- package/src/rules/common/info-contact.ts +15 -0
- package/src/rules/common/info-description.ts +10 -0
- package/src/rules/common/info-license-url.ts +15 -0
- package/src/rules/common/license-url.ts +10 -0
- package/src/rules/common/no-ambiguous-paths.ts +50 -0
- package/src/rules/common/no-enum-type-mismatch.ts +49 -0
- package/src/rules/common/no-http-verbs-in-paths.ts +36 -0
- package/src/rules/common/no-identical-paths.ts +24 -0
- package/src/rules/common/no-invalid-parameter-examples.ts +36 -0
- package/src/rules/common/no-invalid-schema-examples.ts +27 -0
- package/src/rules/common/no-path-trailing-slash.ts +15 -0
- package/src/rules/common/operation-2xx-response.ts +16 -0
- package/src/rules/common/operation-4xx-response.ts +17 -0
- package/src/rules/common/operation-description.ts +13 -0
- package/src/rules/common/operation-operationId-unique.ts +21 -0
- package/src/rules/common/operation-operationId-url-safe.ts +19 -0
- package/src/rules/common/operation-operationId.ts +17 -0
- package/src/rules/common/operation-parameters-unique.ts +48 -0
- package/src/rules/common/operation-security-defined.ts +45 -0
- package/src/rules/common/operation-singular-tag.ts +17 -0
- package/src/rules/common/operation-summary.ts +13 -0
- package/src/rules/common/operation-tag-defined.ts +26 -0
- package/src/rules/common/parameter-description.ts +22 -0
- package/src/rules/common/path-declaration-must-exist.ts +15 -0
- package/src/rules/common/path-excludes-patterns.ts +23 -0
- package/src/rules/common/path-http-verbs-order.ts +30 -0
- package/src/rules/common/path-not-include-query.ts +17 -0
- package/src/rules/common/path-params-defined.ts +58 -0
- package/src/rules/common/path-segment-plural.ts +31 -0
- package/src/rules/common/paths-kebab-case.ts +16 -0
- package/src/rules/common/response-contains-header.ts +30 -0
- package/src/rules/common/scalar-property-missing-example.ts +58 -0
- package/src/rules/common/spec.ts +143 -0
- package/src/rules/common/tag-description.ts +10 -0
- package/src/rules/common/tags-alphabetical.ts +20 -0
- package/src/rules/no-unresolved-refs.ts +51 -0
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +110 -0
- package/src/rules/oas2/__tests__/response-contains-header.test.ts +174 -0
- package/src/rules/oas2/__tests__/response-contains-property.test.ts +155 -0
- package/src/rules/oas2/__tests__/spec/fixtures/description.md +1 -0
- package/src/rules/oas2/__tests__/spec/info.test.ts +355 -0
- package/src/rules/oas2/__tests__/spec/operation.test.ts +123 -0
- package/src/rules/oas2/__tests__/spec/paths.test.ts +245 -0
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +31 -0
- package/src/rules/oas2/__tests__/spec/utils.ts +32 -0
- package/src/rules/oas2/boolean-parameter-prefixes.ts +26 -0
- package/src/rules/oas2/index.ts +89 -0
- package/src/rules/oas2/remove-unused-components.ts +76 -0
- package/src/rules/oas2/request-mime-type.ts +17 -0
- package/src/rules/oas2/response-contains-property.ts +36 -0
- package/src/rules/oas2/response-mime-type.ts +17 -0
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +111 -0
- package/src/rules/oas3/__tests__/fixtures/common.yaml +11 -0
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +205 -0
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +65 -0
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +392 -0
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +60 -0
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +79 -0
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +131 -0
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +273 -0
- package/src/rules/oas3/__tests__/response-contains-property.test.ts +403 -0
- package/src/rules/oas3/__tests__/spec/callbacks.test.ts +41 -0
- package/src/rules/oas3/__tests__/spec/fixtures/description.md +1 -0
- package/src/rules/oas3/__tests__/spec/info.test.ts +391 -0
- package/src/rules/oas3/__tests__/spec/operation.test.ts +253 -0
- package/src/rules/oas3/__tests__/spec/paths.test.ts +284 -0
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +77 -0
- package/src/rules/oas3/__tests__/spec/servers.test.ts +499 -0
- package/src/rules/oas3/__tests__/spec/spec.test.ts +288 -0
- package/src/rules/oas3/__tests__/spec/utils.ts +32 -0
- package/src/rules/oas3/boolean-parameter-prefixes.ts +28 -0
- package/src/rules/oas3/index.ts +105 -0
- package/src/rules/oas3/no-empty-servers.ts +22 -0
- package/src/rules/oas3/no-example-value-and-externalValue.ts +14 -0
- package/src/rules/oas3/no-invalid-media-type-examples.ts +41 -0
- package/src/rules/oas3/no-server-example.com.ts +14 -0
- package/src/rules/oas3/no-server-trailing-slash.ts +15 -0
- package/src/rules/oas3/no-servers-empty-enum.ts +67 -0
- package/src/rules/oas3/no-undefined-server-variable.ts +30 -0
- package/src/rules/oas3/no-unused-components.ts +75 -0
- package/src/rules/oas3/remove-unused-components.ts +84 -0
- package/src/rules/oas3/request-mime-type.ts +31 -0
- package/src/rules/oas3/response-contains-property.ts +38 -0
- package/src/rules/oas3/response-mime-type.ts +31 -0
- package/src/rules/other/stats.ts +44 -0
- package/src/rules/utils.ts +123 -0
- package/src/types/index.ts +138 -0
- package/src/types/oas2.ts +397 -0
- package/src/types/oas3.ts +510 -0
- package/src/types/oas3_1.ts +253 -0
- package/src/types/redocly-yaml.ts +647 -0
- package/src/typings/common.ts +9 -0
- package/src/typings/openapi.ts +298 -0
- package/src/typings/swagger.ts +236 -0
- package/src/utils.ts +193 -0
- package/src/visitors.ts +448 -0
- package/src/walk.ts +416 -0
- package/tsconfig.json +8 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { NormalizedProblem } from '../walk';
|
|
3
|
+
import { OasVersion, OasMajorVersion, Oas2RuleSet, Oas3RuleSet } from '../oas-types';
|
|
4
|
+
import type { NodeType } from '../types';
|
|
5
|
+
import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedLintConfig, RuleConfig } from './types';
|
|
6
|
+
export declare const env: NodeJS.ProcessEnv;
|
|
7
|
+
export declare const IGNORE_FILE = ".redocly.lint-ignore.yaml";
|
|
8
|
+
export declare const DEFAULT_REGION = "us";
|
|
9
|
+
export declare const DOMAINS: {
|
|
10
|
+
us: string;
|
|
11
|
+
eu: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const AVAILABLE_REGIONS: Region[];
|
|
14
|
+
export declare class LintConfig {
|
|
15
|
+
rawConfig: ResolvedLintConfig;
|
|
16
|
+
configFile?: string | undefined;
|
|
17
|
+
plugins: Plugin[];
|
|
18
|
+
ignore: Record<string, Record<string, Set<string>>>;
|
|
19
|
+
doNotResolveExamples: boolean;
|
|
20
|
+
rules: Record<OasVersion, Record<string, RuleConfig>>;
|
|
21
|
+
preprocessors: Record<OasVersion, Record<string, PreprocessorConfig>>;
|
|
22
|
+
decorators: Record<OasVersion, Record<string, DecoratorConfig>>;
|
|
23
|
+
private _usedRules;
|
|
24
|
+
private _usedVersions;
|
|
25
|
+
recommendedFallback: boolean;
|
|
26
|
+
extendPaths: string[];
|
|
27
|
+
pluginPaths: string[];
|
|
28
|
+
constructor(rawConfig: ResolvedLintConfig, configFile?: string | undefined);
|
|
29
|
+
saveIgnore(): void;
|
|
30
|
+
addIgnore(problem: NormalizedProblem): void;
|
|
31
|
+
addProblemToIgnore(problem: NormalizedProblem): NormalizedProblem;
|
|
32
|
+
extendTypes(types: Record<string, NodeType>, version: OasVersion): Record<string, NodeType>;
|
|
33
|
+
getRuleSettings(ruleId: string, oasVersion: OasVersion): {
|
|
34
|
+
severity: import("../walk").ProblemSeverity | "off";
|
|
35
|
+
};
|
|
36
|
+
getPreprocessorSettings(ruleId: string, oasVersion: OasVersion): {
|
|
37
|
+
severity: import("../walk").ProblemSeverity | "off";
|
|
38
|
+
};
|
|
39
|
+
getDecoratorSettings(ruleId: string, oasVersion: OasVersion): {
|
|
40
|
+
severity: import("../walk").ProblemSeverity | "off";
|
|
41
|
+
};
|
|
42
|
+
getUnusedRules(): {
|
|
43
|
+
rules: string[];
|
|
44
|
+
preprocessors: string[];
|
|
45
|
+
decorators: string[];
|
|
46
|
+
};
|
|
47
|
+
getRulesForOasVersion(version: OasMajorVersion): Oas3RuleSet[] | Oas2RuleSet[];
|
|
48
|
+
skipRules(rules?: string[]): void;
|
|
49
|
+
skipPreprocessors(preprocessors?: string[]): void;
|
|
50
|
+
skipDecorators(decorators?: string[]): void;
|
|
51
|
+
}
|
|
52
|
+
export declare class Config {
|
|
53
|
+
rawConfig: ResolvedConfig;
|
|
54
|
+
configFile?: string | undefined;
|
|
55
|
+
apis: Record<string, ResolvedApi>;
|
|
56
|
+
lint: LintConfig;
|
|
57
|
+
resolve: ResolveConfig;
|
|
58
|
+
licenseKey?: string;
|
|
59
|
+
region?: Region;
|
|
60
|
+
'features.openapi': Record<string, any>;
|
|
61
|
+
'features.mockServer'?: Record<string, any>;
|
|
62
|
+
organization?: string;
|
|
63
|
+
constructor(rawConfig: ResolvedConfig, configFile?: string | undefined);
|
|
64
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Config = exports.LintConfig = exports.AVAILABLE_REGIONS = exports.DOMAINS = exports.DEFAULT_REGION = exports.IGNORE_FILE = exports.env = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const js_yaml_1 = require("../js-yaml");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const oas_types_1 = require("../oas-types");
|
|
9
|
+
const utils_2 = require("./utils");
|
|
10
|
+
// Alias environment here so this file can work in browser environments too.
|
|
11
|
+
exports.env = typeof process !== 'undefined' ? process.env || {} : {};
|
|
12
|
+
exports.IGNORE_FILE = '.redocly.lint-ignore.yaml';
|
|
13
|
+
const IGNORE_BANNER = `# This file instructs Redocly's linter to ignore the rules contained for specific parts of your API.\n` +
|
|
14
|
+
`# See https://redoc.ly/docs/cli/ for more information.\n`;
|
|
15
|
+
exports.DEFAULT_REGION = 'us';
|
|
16
|
+
function getDomains() {
|
|
17
|
+
const domains = {
|
|
18
|
+
us: 'redocly.com',
|
|
19
|
+
eu: 'eu.redocly.com',
|
|
20
|
+
};
|
|
21
|
+
// FIXME: temporary fix for our lab environments
|
|
22
|
+
const domain = exports.env.REDOCLY_DOMAIN;
|
|
23
|
+
if (domain === null || domain === void 0 ? void 0 : domain.endsWith('.redocly.host')) {
|
|
24
|
+
domains[domain.split('.')[0]] = domain;
|
|
25
|
+
}
|
|
26
|
+
if (domain === 'redoc.online') {
|
|
27
|
+
domains[domain] = domain;
|
|
28
|
+
}
|
|
29
|
+
return domains;
|
|
30
|
+
}
|
|
31
|
+
exports.DOMAINS = getDomains();
|
|
32
|
+
exports.AVAILABLE_REGIONS = Object.keys(exports.DOMAINS);
|
|
33
|
+
class LintConfig {
|
|
34
|
+
constructor(rawConfig, configFile) {
|
|
35
|
+
this.rawConfig = rawConfig;
|
|
36
|
+
this.configFile = configFile;
|
|
37
|
+
this.ignore = {};
|
|
38
|
+
this._usedRules = new Set();
|
|
39
|
+
this._usedVersions = new Set();
|
|
40
|
+
this.plugins = rawConfig.plugins || [];
|
|
41
|
+
this.doNotResolveExamples = !!rawConfig.doNotResolveExamples;
|
|
42
|
+
this.recommendedFallback = rawConfig.recommendedFallback || false;
|
|
43
|
+
this.rules = {
|
|
44
|
+
[oas_types_1.OasVersion.Version2]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas2Rules),
|
|
45
|
+
[oas_types_1.OasVersion.Version3_0]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas3_0Rules),
|
|
46
|
+
[oas_types_1.OasVersion.Version3_1]: Object.assign(Object.assign({}, rawConfig.rules), rawConfig.oas3_1Rules),
|
|
47
|
+
};
|
|
48
|
+
this.preprocessors = {
|
|
49
|
+
[oas_types_1.OasVersion.Version2]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas2Preprocessors),
|
|
50
|
+
[oas_types_1.OasVersion.Version3_0]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas3_0Preprocessors),
|
|
51
|
+
[oas_types_1.OasVersion.Version3_1]: Object.assign(Object.assign({}, rawConfig.preprocessors), rawConfig.oas3_1Preprocessors),
|
|
52
|
+
};
|
|
53
|
+
this.decorators = {
|
|
54
|
+
[oas_types_1.OasVersion.Version2]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas2Decorators),
|
|
55
|
+
[oas_types_1.OasVersion.Version3_0]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas3_0Decorators),
|
|
56
|
+
[oas_types_1.OasVersion.Version3_1]: Object.assign(Object.assign({}, rawConfig.decorators), rawConfig.oas3_1Decorators),
|
|
57
|
+
};
|
|
58
|
+
this.extendPaths = rawConfig.extendPaths || [];
|
|
59
|
+
this.pluginPaths = rawConfig.pluginPaths || [];
|
|
60
|
+
const dir = this.configFile
|
|
61
|
+
? path.dirname(this.configFile)
|
|
62
|
+
: (typeof process !== 'undefined' && process.cwd()) || '';
|
|
63
|
+
const ignoreFile = path.join(dir, exports.IGNORE_FILE);
|
|
64
|
+
/* no crash when using it on the client */
|
|
65
|
+
if (fs.hasOwnProperty('existsSync') && fs.existsSync(ignoreFile)) {
|
|
66
|
+
// TODO: parse errors
|
|
67
|
+
this.ignore =
|
|
68
|
+
js_yaml_1.parseYaml(fs.readFileSync(ignoreFile, 'utf-8')) || {};
|
|
69
|
+
// resolve ignore paths
|
|
70
|
+
for (const fileName of Object.keys(this.ignore)) {
|
|
71
|
+
this.ignore[path.resolve(path.dirname(ignoreFile), fileName)] = this.ignore[fileName];
|
|
72
|
+
for (const ruleId of Object.keys(this.ignore[fileName])) {
|
|
73
|
+
this.ignore[fileName][ruleId] = new Set(this.ignore[fileName][ruleId]);
|
|
74
|
+
}
|
|
75
|
+
delete this.ignore[fileName];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
saveIgnore() {
|
|
80
|
+
const dir = this.configFile ? path.dirname(this.configFile) : process.cwd();
|
|
81
|
+
const ignoreFile = path.join(dir, exports.IGNORE_FILE);
|
|
82
|
+
const mapped = {};
|
|
83
|
+
for (const absFileName of Object.keys(this.ignore)) {
|
|
84
|
+
const ignoredRules = (mapped[utils_1.slash(path.relative(dir, absFileName))] =
|
|
85
|
+
this.ignore[absFileName]);
|
|
86
|
+
for (const ruleId of Object.keys(ignoredRules)) {
|
|
87
|
+
ignoredRules[ruleId] = Array.from(ignoredRules[ruleId]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
fs.writeFileSync(ignoreFile, IGNORE_BANNER + js_yaml_1.stringifyYaml(mapped));
|
|
91
|
+
}
|
|
92
|
+
addIgnore(problem) {
|
|
93
|
+
const ignore = this.ignore;
|
|
94
|
+
const loc = problem.location[0];
|
|
95
|
+
if (loc.pointer === undefined)
|
|
96
|
+
return;
|
|
97
|
+
const fileIgnore = (ignore[loc.source.absoluteRef] = ignore[loc.source.absoluteRef] || {});
|
|
98
|
+
const ruleIgnore = (fileIgnore[problem.ruleId] = fileIgnore[problem.ruleId] || new Set());
|
|
99
|
+
ruleIgnore.add(loc.pointer);
|
|
100
|
+
}
|
|
101
|
+
addProblemToIgnore(problem) {
|
|
102
|
+
const loc = problem.location[0];
|
|
103
|
+
if (loc.pointer === undefined)
|
|
104
|
+
return problem;
|
|
105
|
+
const fileIgnore = this.ignore[loc.source.absoluteRef] || {};
|
|
106
|
+
const ruleIgnore = fileIgnore[problem.ruleId];
|
|
107
|
+
const ignored = ruleIgnore && ruleIgnore.has(loc.pointer);
|
|
108
|
+
return ignored
|
|
109
|
+
? Object.assign(Object.assign({}, problem), { ignored }) : problem;
|
|
110
|
+
}
|
|
111
|
+
extendTypes(types, version) {
|
|
112
|
+
let extendedTypes = types;
|
|
113
|
+
for (const plugin of this.plugins) {
|
|
114
|
+
if (plugin.typeExtension !== undefined) {
|
|
115
|
+
switch (version) {
|
|
116
|
+
case oas_types_1.OasVersion.Version3_0:
|
|
117
|
+
case oas_types_1.OasVersion.Version3_1:
|
|
118
|
+
if (!plugin.typeExtension.oas3)
|
|
119
|
+
continue;
|
|
120
|
+
extendedTypes = plugin.typeExtension.oas3(extendedTypes, version);
|
|
121
|
+
case oas_types_1.OasVersion.Version2:
|
|
122
|
+
if (!plugin.typeExtension.oas2)
|
|
123
|
+
continue;
|
|
124
|
+
extendedTypes = plugin.typeExtension.oas2(extendedTypes, version);
|
|
125
|
+
default:
|
|
126
|
+
throw new Error('Not implemented');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return extendedTypes;
|
|
131
|
+
}
|
|
132
|
+
getRuleSettings(ruleId, oasVersion) {
|
|
133
|
+
this._usedRules.add(ruleId);
|
|
134
|
+
this._usedVersions.add(oasVersion);
|
|
135
|
+
const settings = this.rules[oasVersion][ruleId] || 'off';
|
|
136
|
+
if (typeof settings === 'string') {
|
|
137
|
+
return {
|
|
138
|
+
severity: settings,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
return Object.assign({ severity: 'error' }, settings);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
getPreprocessorSettings(ruleId, oasVersion) {
|
|
146
|
+
this._usedRules.add(ruleId);
|
|
147
|
+
this._usedVersions.add(oasVersion);
|
|
148
|
+
const settings = this.preprocessors[oasVersion][ruleId] || 'off';
|
|
149
|
+
if (typeof settings === 'string') {
|
|
150
|
+
return {
|
|
151
|
+
severity: settings === 'on' ? 'error' : settings,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return Object.assign({ severity: 'error' }, settings);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
getDecoratorSettings(ruleId, oasVersion) {
|
|
159
|
+
this._usedRules.add(ruleId);
|
|
160
|
+
this._usedVersions.add(oasVersion);
|
|
161
|
+
const settings = this.decorators[oasVersion][ruleId] || 'off';
|
|
162
|
+
if (typeof settings === 'string') {
|
|
163
|
+
return {
|
|
164
|
+
severity: settings === 'on' ? 'error' : settings,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return Object.assign({ severity: 'error' }, settings);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
getUnusedRules() {
|
|
172
|
+
const rules = [];
|
|
173
|
+
const decorators = [];
|
|
174
|
+
const preprocessors = [];
|
|
175
|
+
for (const usedVersion of Array.from(this._usedVersions)) {
|
|
176
|
+
rules.push(...Object.keys(this.rules[usedVersion]).filter((name) => !this._usedRules.has(name)));
|
|
177
|
+
decorators.push(...Object.keys(this.decorators[usedVersion]).filter((name) => !this._usedRules.has(name)));
|
|
178
|
+
preprocessors.push(...Object.keys(this.preprocessors[usedVersion]).filter((name) => !this._usedRules.has(name)));
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
rules,
|
|
182
|
+
preprocessors,
|
|
183
|
+
decorators,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
getRulesForOasVersion(version) {
|
|
187
|
+
switch (version) {
|
|
188
|
+
case oas_types_1.OasMajorVersion.Version3:
|
|
189
|
+
const oas3Rules = []; // default ruleset
|
|
190
|
+
this.plugins.forEach((p) => { var _a; return ((_a = p.preprocessors) === null || _a === void 0 ? void 0 : _a.oas3) && oas3Rules.push(p.preprocessors.oas3); });
|
|
191
|
+
this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.oas3) && oas3Rules.push(p.rules.oas3); });
|
|
192
|
+
this.plugins.forEach((p) => { var _a; return ((_a = p.decorators) === null || _a === void 0 ? void 0 : _a.oas3) && oas3Rules.push(p.decorators.oas3); });
|
|
193
|
+
return oas3Rules;
|
|
194
|
+
case oas_types_1.OasMajorVersion.Version2:
|
|
195
|
+
const oas2Rules = []; // default ruleset
|
|
196
|
+
this.plugins.forEach((p) => { var _a; return ((_a = p.preprocessors) === null || _a === void 0 ? void 0 : _a.oas2) && oas2Rules.push(p.preprocessors.oas2); });
|
|
197
|
+
this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.oas2) && oas2Rules.push(p.rules.oas2); });
|
|
198
|
+
this.plugins.forEach((p) => { var _a; return ((_a = p.decorators) === null || _a === void 0 ? void 0 : _a.oas2) && oas2Rules.push(p.decorators.oas2); });
|
|
199
|
+
return oas2Rules;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
skipRules(rules) {
|
|
203
|
+
for (const ruleId of rules || []) {
|
|
204
|
+
for (const version of Object.values(oas_types_1.OasVersion)) {
|
|
205
|
+
if (this.rules[version][ruleId]) {
|
|
206
|
+
this.rules[version][ruleId] = 'off';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
skipPreprocessors(preprocessors) {
|
|
212
|
+
for (const preprocessorId of preprocessors || []) {
|
|
213
|
+
for (const version of Object.values(oas_types_1.OasVersion)) {
|
|
214
|
+
if (this.preprocessors[version][preprocessorId]) {
|
|
215
|
+
this.preprocessors[version][preprocessorId] = 'off';
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
skipDecorators(decorators) {
|
|
221
|
+
for (const decoratorId of decorators || []) {
|
|
222
|
+
for (const version of Object.values(oas_types_1.OasVersion)) {
|
|
223
|
+
if (this.decorators[version][decoratorId]) {
|
|
224
|
+
this.decorators[version][decoratorId] = 'off';
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.LintConfig = LintConfig;
|
|
231
|
+
class Config {
|
|
232
|
+
constructor(rawConfig, configFile) {
|
|
233
|
+
this.rawConfig = rawConfig;
|
|
234
|
+
this.configFile = configFile;
|
|
235
|
+
this.apis = rawConfig.apis || {};
|
|
236
|
+
this.lint = new LintConfig(rawConfig.lint || {}, configFile);
|
|
237
|
+
this['features.openapi'] = rawConfig['features.openapi'] || {};
|
|
238
|
+
this['features.mockServer'] = rawConfig['features.mockServer'] || {};
|
|
239
|
+
this.resolve = utils_2.getResolveConfig(rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.resolve);
|
|
240
|
+
this.region = rawConfig.region;
|
|
241
|
+
this.organization = rawConfig.organization;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.Config = Config;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./config"), exports);
|
|
14
|
+
__exportStar(require("./types"), exports);
|
|
15
|
+
__exportStar(require("./rules"), exports);
|
|
16
|
+
__exportStar(require("./builtIn"), exports);
|
|
17
|
+
__exportStar(require("./load"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./config-resolvers"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Config } from './config';
|
|
2
|
+
import type { RawConfig } from './types';
|
|
3
|
+
export declare function loadConfig(configPath?: string | undefined, customExtends?: string[]): Promise<Config>;
|
|
4
|
+
export declare const CONFIG_FILE_NAMES: string[];
|
|
5
|
+
export declare function findConfig(dir?: string): string | undefined;
|
|
6
|
+
export declare function getConfig(configPath?: string | undefined): Promise<RawConfig>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getConfig = exports.findConfig = exports.CONFIG_FILE_NAMES = exports.loadConfig = void 0;
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const redocly_1 = require("../redocly");
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
const config_1 = require("./config");
|
|
18
|
+
const utils_2 = require("./utils");
|
|
19
|
+
const config_resolvers_1 = require("./config-resolvers");
|
|
20
|
+
function loadConfig(configPath = findConfig(), customExtends) {
|
|
21
|
+
var _a;
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const rawConfig = yield getConfig(configPath);
|
|
24
|
+
if (customExtends !== undefined) {
|
|
25
|
+
rawConfig.lint = rawConfig.lint || {};
|
|
26
|
+
rawConfig.lint.extends = customExtends;
|
|
27
|
+
}
|
|
28
|
+
else if (utils_1.isEmptyObject(rawConfig)) {
|
|
29
|
+
// TODO: check if we can add recommended here. add message here?
|
|
30
|
+
// rawConfig.lint = { extends: ['recommended'], recommendedFallback: true };
|
|
31
|
+
}
|
|
32
|
+
const redoclyClient = new redocly_1.RedoclyClient();
|
|
33
|
+
const tokens = yield redoclyClient.getTokens();
|
|
34
|
+
if (tokens.length) {
|
|
35
|
+
if (!rawConfig.resolve)
|
|
36
|
+
rawConfig.resolve = {};
|
|
37
|
+
if (!rawConfig.resolve.http)
|
|
38
|
+
rawConfig.resolve.http = {};
|
|
39
|
+
rawConfig.resolve.http.headers = [...((_a = rawConfig.resolve.http.headers) !== null && _a !== void 0 ? _a : [])];
|
|
40
|
+
for (const item of tokens) {
|
|
41
|
+
const domain = config_1.DOMAINS[item.region];
|
|
42
|
+
rawConfig.resolve.http.headers.push({
|
|
43
|
+
matches: `https://api.${domain}/registry/**`,
|
|
44
|
+
name: 'Authorization',
|
|
45
|
+
envVariable: undefined,
|
|
46
|
+
value: item.token,
|
|
47
|
+
},
|
|
48
|
+
//support redocly.com domain for future compatibility
|
|
49
|
+
...(item.region === 'us'
|
|
50
|
+
? [
|
|
51
|
+
{
|
|
52
|
+
matches: `https://api.redoc.ly/registry/**`,
|
|
53
|
+
name: 'Authorization',
|
|
54
|
+
envVariable: undefined,
|
|
55
|
+
value: item.token,
|
|
56
|
+
},
|
|
57
|
+
]
|
|
58
|
+
: []));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return config_resolvers_1.resolveConfig(rawConfig, configPath);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.loadConfig = loadConfig;
|
|
65
|
+
exports.CONFIG_FILE_NAMES = ['redocly.yaml', 'redocly.yml', '.redocly.yaml', '.redocly.yml'];
|
|
66
|
+
function findConfig(dir) {
|
|
67
|
+
if (!fs.hasOwnProperty('existsSync'))
|
|
68
|
+
return;
|
|
69
|
+
const existingConfigFiles = exports.CONFIG_FILE_NAMES.map((name) => dir ? path.resolve(dir, name) : name).filter(fs.existsSync);
|
|
70
|
+
if (existingConfigFiles.length > 1) {
|
|
71
|
+
throw new Error(`
|
|
72
|
+
Multiple configuration files are not allowed.
|
|
73
|
+
Found the following files: ${existingConfigFiles.join(', ')}.
|
|
74
|
+
Please use 'redocly.yaml' instead.
|
|
75
|
+
`);
|
|
76
|
+
}
|
|
77
|
+
return existingConfigFiles[0];
|
|
78
|
+
}
|
|
79
|
+
exports.findConfig = findConfig;
|
|
80
|
+
function getConfig(configPath = findConfig()) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
if (!configPath)
|
|
83
|
+
return {};
|
|
84
|
+
try {
|
|
85
|
+
const rawConfig = ((yield utils_1.loadYaml(configPath)) || {});
|
|
86
|
+
return utils_2.transformConfig(rawConfig);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
throw new Error(`Error parsing config file at '${configPath}': ${e.message}`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
exports.getConfig = getConfig;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
rules: {
|
|
5
|
+
'info-description': 'warn',
|
|
6
|
+
'info-contact': 'off',
|
|
7
|
+
'info-license': 'off',
|
|
8
|
+
'info-license-url': 'off',
|
|
9
|
+
'tag-description': 'warn',
|
|
10
|
+
'tags-alphabetical': 'off',
|
|
11
|
+
'parameter-description': 'off',
|
|
12
|
+
'no-path-trailing-slash': 'warn',
|
|
13
|
+
'no-identical-paths': 'warn',
|
|
14
|
+
'no-ambiguous-paths': 'warn',
|
|
15
|
+
'path-declaration-must-exist': 'warn',
|
|
16
|
+
'path-not-include-query': 'warn',
|
|
17
|
+
'path-parameters-defined': 'warn',
|
|
18
|
+
'operation-description': 'off',
|
|
19
|
+
'operation-2xx-response': 'warn',
|
|
20
|
+
'operation-4xx-response': 'off',
|
|
21
|
+
'assertions': 'warn',
|
|
22
|
+
'operation-operationId': 'warn',
|
|
23
|
+
'operation-summary': 'warn',
|
|
24
|
+
'operation-operationId-unique': 'warn',
|
|
25
|
+
'operation-parameters-unique': 'warn',
|
|
26
|
+
'operation-tag-defined': 'off',
|
|
27
|
+
'operation-security-defined': 'warn',
|
|
28
|
+
'operation-operationId-url-safe': 'warn',
|
|
29
|
+
'operation-singular-tag': 'off',
|
|
30
|
+
'no-unresolved-refs': 'error',
|
|
31
|
+
'no-enum-type-mismatch': 'warn',
|
|
32
|
+
'boolean-parameter-prefixes': 'off',
|
|
33
|
+
'paths-kebab-case': 'off',
|
|
34
|
+
spec: 'error',
|
|
35
|
+
},
|
|
36
|
+
oas3_0Rules: {
|
|
37
|
+
'no-invalid-media-type-examples': {
|
|
38
|
+
severity: 'warn',
|
|
39
|
+
disallowAdditionalProperties: true,
|
|
40
|
+
},
|
|
41
|
+
'no-server-example.com': 'warn',
|
|
42
|
+
'no-server-trailing-slash': 'error',
|
|
43
|
+
'no-empty-servers': 'warn',
|
|
44
|
+
'no-example-value-and-externalValue': 'warn',
|
|
45
|
+
'no-unused-components': 'warn',
|
|
46
|
+
'no-undefined-server-variable': 'warn',
|
|
47
|
+
'no-servers-empty-enum': 'error',
|
|
48
|
+
},
|
|
49
|
+
oas3_1Rules: {
|
|
50
|
+
'no-server-example.com': 'warn',
|
|
51
|
+
'no-server-trailing-slash': 'error',
|
|
52
|
+
'no-empty-servers': 'warn',
|
|
53
|
+
'no-example-value-and-externalValue': 'warn',
|
|
54
|
+
'no-unused-components': 'warn',
|
|
55
|
+
'no-undefined-server-variable': 'warn',
|
|
56
|
+
'no-servers-empty-enum': 'error',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
rules: {
|
|
5
|
+
'info-description': 'warn',
|
|
6
|
+
'info-contact': 'off',
|
|
7
|
+
'info-license': 'warn',
|
|
8
|
+
'info-license-url': 'warn',
|
|
9
|
+
'tag-description': 'warn',
|
|
10
|
+
'tags-alphabetical': 'off',
|
|
11
|
+
'parameter-description': 'off',
|
|
12
|
+
'no-path-trailing-slash': 'error',
|
|
13
|
+
'no-identical-paths': 'error',
|
|
14
|
+
'no-ambiguous-paths': 'warn',
|
|
15
|
+
'path-declaration-must-exist': 'error',
|
|
16
|
+
'path-not-include-query': 'error',
|
|
17
|
+
'path-parameters-defined': 'error',
|
|
18
|
+
'operation-description': 'off',
|
|
19
|
+
'operation-2xx-response': 'warn',
|
|
20
|
+
'assertions': 'warn',
|
|
21
|
+
'operation-4xx-response': 'warn',
|
|
22
|
+
'operation-operationId': 'warn',
|
|
23
|
+
'operation-summary': 'error',
|
|
24
|
+
'operation-operationId-unique': 'error',
|
|
25
|
+
'operation-operationId-url-safe': 'error',
|
|
26
|
+
'operation-parameters-unique': 'error',
|
|
27
|
+
'operation-tag-defined': 'off',
|
|
28
|
+
'operation-security-defined': 'error',
|
|
29
|
+
'operation-singular-tag': 'off',
|
|
30
|
+
'no-unresolved-refs': 'error',
|
|
31
|
+
'no-enum-type-mismatch': 'error',
|
|
32
|
+
'boolean-parameter-prefixes': 'off',
|
|
33
|
+
'paths-kebab-case': 'off',
|
|
34
|
+
spec: 'error',
|
|
35
|
+
},
|
|
36
|
+
oas3_0Rules: {
|
|
37
|
+
'no-invalid-media-type-examples': {
|
|
38
|
+
severity: 'warn',
|
|
39
|
+
disallowAdditionalProperties: true,
|
|
40
|
+
},
|
|
41
|
+
'no-server-example.com': 'warn',
|
|
42
|
+
'no-server-trailing-slash': 'error',
|
|
43
|
+
'no-empty-servers': 'error',
|
|
44
|
+
'no-example-value-and-externalValue': 'error',
|
|
45
|
+
'no-unused-components': 'warn',
|
|
46
|
+
'no-undefined-server-variable': 'error',
|
|
47
|
+
'no-servers-empty-enum': 'error',
|
|
48
|
+
},
|
|
49
|
+
oas3_1Rules: {
|
|
50
|
+
'no-server-example.com': 'warn',
|
|
51
|
+
'no-server-trailing-slash': 'error',
|
|
52
|
+
'no-empty-servers': 'error',
|
|
53
|
+
'no-example-value-and-externalValue': 'error',
|
|
54
|
+
'no-unused-components': 'warn',
|
|
55
|
+
'no-undefined-server-variable': 'error',
|
|
56
|
+
'no-servers-empty-enum': 'error',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RuleSet, OasVersion } from '../oas-types';
|
|
2
|
+
import { LintConfig } from './config';
|
|
3
|
+
export declare function initRules<T extends Function, P extends RuleSet<T>>(rules: P[], config: LintConfig, type: 'rules' | 'preprocessors' | 'decorators', oasVersion: OasVersion): {
|
|
4
|
+
severity: import("..").ProblemSeverity | "off";
|
|
5
|
+
ruleId: string;
|
|
6
|
+
visitor: any;
|
|
7
|
+
}[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initRules = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
function initRules(rules, config, type, oasVersion) {
|
|
6
|
+
return rules
|
|
7
|
+
.flatMap((ruleset) => Object.keys(ruleset).map((ruleId) => {
|
|
8
|
+
const rule = ruleset[ruleId];
|
|
9
|
+
const ruleSettings = type === 'rules'
|
|
10
|
+
? config.getRuleSettings(ruleId, oasVersion)
|
|
11
|
+
: type === 'preprocessors'
|
|
12
|
+
? config.getPreprocessorSettings(ruleId, oasVersion)
|
|
13
|
+
: config.getDecoratorSettings(ruleId, oasVersion);
|
|
14
|
+
if (ruleSettings.severity === 'off') {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const visitors = rule(ruleSettings);
|
|
18
|
+
if (Array.isArray(visitors)) {
|
|
19
|
+
return visitors.map((visitor) => ({
|
|
20
|
+
severity: ruleSettings.severity,
|
|
21
|
+
ruleId,
|
|
22
|
+
visitor: visitor,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
severity: ruleSettings.severity,
|
|
27
|
+
ruleId,
|
|
28
|
+
visitor: visitors, // note: actually it is only one visitor object
|
|
29
|
+
};
|
|
30
|
+
}))
|
|
31
|
+
.flatMap(visitor => visitor)
|
|
32
|
+
.filter(utils_1.notUndefined);
|
|
33
|
+
}
|
|
34
|
+
exports.initRules = initRules;
|