@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
package/lib/bundle.js
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
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.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.OasVersion = void 0;
|
|
13
|
+
const isEqual = require("lodash.isequal");
|
|
14
|
+
const resolve_1 = require("./resolve");
|
|
15
|
+
const visitors_1 = require("./visitors");
|
|
16
|
+
const oas3_1 = require("./types/oas3");
|
|
17
|
+
const oas2_1 = require("./types/oas2");
|
|
18
|
+
const oas3_1_1 = require("./types/oas3_1");
|
|
19
|
+
const types_1 = require("./types");
|
|
20
|
+
const walk_1 = require("./walk");
|
|
21
|
+
const oas_types_1 = require("./oas-types");
|
|
22
|
+
const ref_utils_1 = require("./ref-utils");
|
|
23
|
+
const rules_1 = require("./config/rules");
|
|
24
|
+
const no_unresolved_refs_1 = require("./rules/no-unresolved-refs");
|
|
25
|
+
const utils_1 = require("./utils");
|
|
26
|
+
const redocly_1 = require("./redocly");
|
|
27
|
+
const remove_unused_components_1 = require("./rules/oas2/remove-unused-components");
|
|
28
|
+
const remove_unused_components_2 = require("./rules/oas3/remove-unused-components");
|
|
29
|
+
var OasVersion;
|
|
30
|
+
(function (OasVersion) {
|
|
31
|
+
OasVersion["Version2"] = "oas2";
|
|
32
|
+
OasVersion["Version3_0"] = "oas3_0";
|
|
33
|
+
OasVersion["Version3_1"] = "oas3_1";
|
|
34
|
+
})(OasVersion = exports.OasVersion || (exports.OasVersion = {}));
|
|
35
|
+
function bundle(opts) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { ref, doc, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve), base = null, } = opts;
|
|
38
|
+
if (!(ref || doc)) {
|
|
39
|
+
throw new Error('Document or reference is required.\n');
|
|
40
|
+
}
|
|
41
|
+
const document = doc !== undefined ? doc : yield externalRefResolver.resolveDocument(base, ref, true);
|
|
42
|
+
if (document instanceof Error) {
|
|
43
|
+
throw document;
|
|
44
|
+
}
|
|
45
|
+
return bundleDocument(Object.assign(Object.assign({ document }, opts), { config: opts.config.lint, externalRefResolver }));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
exports.bundle = bundle;
|
|
49
|
+
function bundleDocument(opts) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { document, config, customTypes, externalRefResolver, dereference = false, skipRedoclyRegistryRefs = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts;
|
|
52
|
+
const oasVersion = oas_types_1.detectOpenAPI(document.parsed);
|
|
53
|
+
const oasMajorVersion = oas_types_1.openAPIMajor(oasVersion);
|
|
54
|
+
const rules = config.getRulesForOasVersion(oasMajorVersion);
|
|
55
|
+
const types = types_1.normalizeTypes(config.extendTypes((customTypes !== null && customTypes !== void 0 ? customTypes : oasMajorVersion === oas_types_1.OasMajorVersion.Version3)
|
|
56
|
+
? oasVersion === OasVersion.Version3_1
|
|
57
|
+
? oas3_1_1.Oas3_1Types
|
|
58
|
+
: oas3_1.Oas3Types
|
|
59
|
+
: oas2_1.Oas2Types, oasVersion), config);
|
|
60
|
+
const preprocessors = rules_1.initRules(rules, config, 'preprocessors', oasVersion);
|
|
61
|
+
const decorators = rules_1.initRules(rules, config, 'decorators', oasVersion);
|
|
62
|
+
const ctx = {
|
|
63
|
+
problems: [],
|
|
64
|
+
oasVersion: oasVersion,
|
|
65
|
+
refTypes: new Map(),
|
|
66
|
+
visitorsData: {},
|
|
67
|
+
};
|
|
68
|
+
if (removeUnusedComponents) {
|
|
69
|
+
decorators.push({
|
|
70
|
+
severity: 'error',
|
|
71
|
+
ruleId: 'remove-unused-components',
|
|
72
|
+
visitor: oasMajorVersion === oas_types_1.OasMajorVersion.Version2
|
|
73
|
+
? remove_unused_components_1.RemoveUnusedComponents({})
|
|
74
|
+
: remove_unused_components_2.RemoveUnusedComponents({})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const resolvedRefMap = yield resolve_1.resolveDocument({
|
|
78
|
+
rootDocument: document,
|
|
79
|
+
rootType: types.DefinitionRoot,
|
|
80
|
+
externalRefResolver,
|
|
81
|
+
});
|
|
82
|
+
const bundleVisitor = visitors_1.normalizeVisitors([
|
|
83
|
+
...preprocessors,
|
|
84
|
+
{
|
|
85
|
+
severity: 'error',
|
|
86
|
+
ruleId: 'bundler',
|
|
87
|
+
visitor: makeBundleVisitor(oasMajorVersion, dereference, skipRedoclyRegistryRefs, document, resolvedRefMap, keepUrlRefs),
|
|
88
|
+
},
|
|
89
|
+
...decorators,
|
|
90
|
+
], types);
|
|
91
|
+
walk_1.walkDocument({
|
|
92
|
+
document,
|
|
93
|
+
rootType: types.DefinitionRoot,
|
|
94
|
+
normalizedVisitors: bundleVisitor,
|
|
95
|
+
resolvedRefMap,
|
|
96
|
+
ctx,
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
bundle: document,
|
|
100
|
+
problems: ctx.problems.map((problem) => config.addProblemToIgnore(problem)),
|
|
101
|
+
fileDependencies: externalRefResolver.getFiles(),
|
|
102
|
+
rootType: types.DefinitionRoot,
|
|
103
|
+
refTypes: ctx.refTypes,
|
|
104
|
+
visitorsData: ctx.visitorsData,
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
exports.bundleDocument = bundleDocument;
|
|
109
|
+
function mapTypeToComponent(typeName, version) {
|
|
110
|
+
switch (version) {
|
|
111
|
+
case oas_types_1.OasMajorVersion.Version3:
|
|
112
|
+
switch (typeName) {
|
|
113
|
+
case 'Schema':
|
|
114
|
+
return 'schemas';
|
|
115
|
+
case 'Parameter':
|
|
116
|
+
return 'parameters';
|
|
117
|
+
case 'Response':
|
|
118
|
+
return 'responses';
|
|
119
|
+
case 'Example':
|
|
120
|
+
return 'examples';
|
|
121
|
+
case 'RequestBody':
|
|
122
|
+
return 'requestBodies';
|
|
123
|
+
case 'Header':
|
|
124
|
+
return 'headers';
|
|
125
|
+
case 'SecuritySchema':
|
|
126
|
+
return 'securitySchemes';
|
|
127
|
+
case 'Link':
|
|
128
|
+
return 'links';
|
|
129
|
+
case 'Callback':
|
|
130
|
+
return 'callbacks';
|
|
131
|
+
default:
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
case oas_types_1.OasMajorVersion.Version2:
|
|
135
|
+
switch (typeName) {
|
|
136
|
+
case 'Schema':
|
|
137
|
+
return 'definitions';
|
|
138
|
+
case 'Parameter':
|
|
139
|
+
return 'parameters';
|
|
140
|
+
case 'Response':
|
|
141
|
+
return 'responses';
|
|
142
|
+
default:
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.mapTypeToComponent = mapTypeToComponent;
|
|
148
|
+
// function oas3Move
|
|
149
|
+
function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDocument, resolvedRefMap, keepUrlRefs) {
|
|
150
|
+
let components;
|
|
151
|
+
const visitor = {
|
|
152
|
+
ref: {
|
|
153
|
+
leave(node, ctx, resolved) {
|
|
154
|
+
if (!resolved.location || resolved.node === undefined) {
|
|
155
|
+
no_unresolved_refs_1.reportUnresolvedRef(resolved, ctx.report, ctx.location);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (resolved.location.source === rootDocument.source &&
|
|
159
|
+
resolved.location.source === ctx.location.source &&
|
|
160
|
+
ctx.type.name !== 'scalar' &&
|
|
161
|
+
!dereference) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// do not bundle registry URL before push, otherwise we can't record dependencies
|
|
165
|
+
if (skipRedoclyRegistryRefs && redocly_1.isRedoclyRegistryURL(node.$ref)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (keepUrlRefs && ref_utils_1.isAbsoluteUrl(node.$ref)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const componentType = mapTypeToComponent(ctx.type.name, version);
|
|
172
|
+
if (!componentType) {
|
|
173
|
+
replaceRef(node, resolved, ctx);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
if (dereference) {
|
|
177
|
+
saveComponent(componentType, resolved, ctx);
|
|
178
|
+
replaceRef(node, resolved, ctx);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
node.$ref = saveComponent(componentType, resolved, ctx);
|
|
182
|
+
resolveBundledComponent(node, resolved, ctx);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
DefinitionRoot: {
|
|
188
|
+
enter(root) {
|
|
189
|
+
if (version === oas_types_1.OasMajorVersion.Version3) {
|
|
190
|
+
components = root.components = root.components || {};
|
|
191
|
+
}
|
|
192
|
+
else if (version === oas_types_1.OasMajorVersion.Version2) {
|
|
193
|
+
components = root;
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
if (version === oas_types_1.OasMajorVersion.Version3) {
|
|
199
|
+
visitor.DiscriminatorMapping = {
|
|
200
|
+
leave(mapping, ctx) {
|
|
201
|
+
for (const name of Object.keys(mapping)) {
|
|
202
|
+
const $ref = mapping[name];
|
|
203
|
+
const resolved = ctx.resolve({ $ref });
|
|
204
|
+
if (!resolved.location || resolved.node === undefined) {
|
|
205
|
+
no_unresolved_refs_1.reportUnresolvedRef(resolved, ctx.report, ctx.location.child(name));
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const componentType = mapTypeToComponent('Schema', version);
|
|
209
|
+
if (dereference) {
|
|
210
|
+
saveComponent(componentType, resolved, ctx);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
mapping[name] = saveComponent(componentType, resolved, ctx);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function resolveBundledComponent(node, resolved, ctx) {
|
|
220
|
+
const newRefId = resolve_1.makeRefId(ctx.location.source.absoluteRef, node.$ref);
|
|
221
|
+
resolvedRefMap.set(newRefId, {
|
|
222
|
+
document: rootDocument,
|
|
223
|
+
isRemote: false,
|
|
224
|
+
node: resolved.node,
|
|
225
|
+
nodePointer: node.$ref,
|
|
226
|
+
resolved: true,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function replaceRef(ref, resolved, ctx) {
|
|
230
|
+
if (!utils_1.isPlainObject(resolved.node)) {
|
|
231
|
+
ctx.parent[ctx.key] = resolved.node;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
// @ts-ignore
|
|
235
|
+
delete ref.$ref;
|
|
236
|
+
Object.assign(ref, resolved.node);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function saveComponent(componentType, target, ctx) {
|
|
240
|
+
components[componentType] = components[componentType] || {};
|
|
241
|
+
const name = getComponentName(target, componentType, ctx);
|
|
242
|
+
components[componentType][name] = target.node;
|
|
243
|
+
if (version === oas_types_1.OasMajorVersion.Version3) {
|
|
244
|
+
return `#/components/${componentType}/${name}`;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
return `#/${componentType}/${name}`;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function isEqualOrEqualRef(node, target, ctx) {
|
|
251
|
+
var _a;
|
|
252
|
+
if (ref_utils_1.isRef(node) &&
|
|
253
|
+
((_a = ctx.resolve(node).location) === null || _a === void 0 ? void 0 : _a.absolutePointer) === target.location.absolutePointer) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
return isEqual(node, target.node);
|
|
257
|
+
}
|
|
258
|
+
function getComponentName(target, componentType, ctx) {
|
|
259
|
+
const [fileRef, pointer] = [target.location.source.absoluteRef, target.location.pointer];
|
|
260
|
+
const componentsGroup = components[componentType];
|
|
261
|
+
let name = '';
|
|
262
|
+
const refParts = pointer.slice(2).split('/').filter(Boolean); // slice(2) removes "#/"
|
|
263
|
+
while (refParts.length > 0) {
|
|
264
|
+
name = refParts.pop() + (name ? `-${name}` : '');
|
|
265
|
+
if (!componentsGroup ||
|
|
266
|
+
!componentsGroup[name] ||
|
|
267
|
+
isEqualOrEqualRef(componentsGroup[name], target, ctx)) {
|
|
268
|
+
return name;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
name = ref_utils_1.refBaseName(fileRef) + (name ? `_${name}` : '');
|
|
272
|
+
if (!componentsGroup[name] || isEqualOrEqualRef(componentsGroup[name], target, ctx)) {
|
|
273
|
+
return name;
|
|
274
|
+
}
|
|
275
|
+
const prevName = name;
|
|
276
|
+
let serialId = 2;
|
|
277
|
+
while (componentsGroup[name] && !isEqualOrEqualRef(componentsGroup[name], target, ctx)) {
|
|
278
|
+
name = `${prevName}-${serialId}`;
|
|
279
|
+
serialId++;
|
|
280
|
+
}
|
|
281
|
+
if (!componentsGroup[name]) {
|
|
282
|
+
ctx.report({
|
|
283
|
+
message: `Two schemas are referenced with the same name but different content. Renamed ${prevName} to ${name}.`,
|
|
284
|
+
location: ctx.location,
|
|
285
|
+
forceSeverity: 'warn',
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
return name;
|
|
289
|
+
}
|
|
290
|
+
return visitor;
|
|
291
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
rules: {
|
|
5
|
+
'info-description': 'error',
|
|
6
|
+
'info-contact': 'error',
|
|
7
|
+
'info-license': 'error',
|
|
8
|
+
'info-license-url': 'error',
|
|
9
|
+
'tag-description': 'error',
|
|
10
|
+
'tags-alphabetical': 'error',
|
|
11
|
+
'parameter-description': 'error',
|
|
12
|
+
'no-identical-paths': 'error',
|
|
13
|
+
'no-ambiguous-paths': 'error',
|
|
14
|
+
'no-path-trailing-slash': 'error',
|
|
15
|
+
'path-segment-plural': 'error',
|
|
16
|
+
'path-declaration-must-exist': 'error',
|
|
17
|
+
'path-not-include-query': 'error',
|
|
18
|
+
'path-parameters-defined': 'error',
|
|
19
|
+
'operation-description': 'error',
|
|
20
|
+
'operation-2xx-response': 'error',
|
|
21
|
+
'operation-4xx-response': 'error',
|
|
22
|
+
'assertions': 'error',
|
|
23
|
+
'operation-operationId': 'error',
|
|
24
|
+
'operation-summary': 'error',
|
|
25
|
+
'operation-operationId-unique': 'error',
|
|
26
|
+
'operation-operationId-url-safe': 'error',
|
|
27
|
+
'operation-parameters-unique': 'error',
|
|
28
|
+
'operation-tag-defined': 'error',
|
|
29
|
+
'operation-security-defined': 'error',
|
|
30
|
+
'operation-singular-tag': 'error',
|
|
31
|
+
'no-unresolved-refs': 'error',
|
|
32
|
+
'no-enum-type-mismatch': 'error',
|
|
33
|
+
'boolean-parameter-prefixes': 'error',
|
|
34
|
+
'paths-kebab-case': 'error',
|
|
35
|
+
'no-http-verbs-in-paths': 'error',
|
|
36
|
+
'path-excludes-patterns': {
|
|
37
|
+
severity: 'error',
|
|
38
|
+
patterns: [],
|
|
39
|
+
},
|
|
40
|
+
'request-mime-type': 'error',
|
|
41
|
+
spec: 'error',
|
|
42
|
+
'no-invalid-schema-examples': 'error',
|
|
43
|
+
'no-invalid-parameter-examples': 'error',
|
|
44
|
+
'scalar-property-missing-example': 'error',
|
|
45
|
+
},
|
|
46
|
+
oas3_0Rules: {
|
|
47
|
+
'no-invalid-media-type-examples': 'error',
|
|
48
|
+
'no-server-example.com': 'error',
|
|
49
|
+
'no-server-trailing-slash': 'error',
|
|
50
|
+
'no-empty-servers': 'error',
|
|
51
|
+
'no-example-value-and-externalValue': 'error',
|
|
52
|
+
'no-unused-components': 'error',
|
|
53
|
+
'no-undefined-server-variable': 'error',
|
|
54
|
+
'no-servers-empty-enum': 'error',
|
|
55
|
+
},
|
|
56
|
+
oas3_1Rules: {
|
|
57
|
+
'no-server-example.com': 'error',
|
|
58
|
+
'no-server-trailing-slash': 'error',
|
|
59
|
+
'no-empty-servers': 'error',
|
|
60
|
+
'no-example-value-and-externalValue': 'error',
|
|
61
|
+
'no-unused-components': 'error',
|
|
62
|
+
'no-undefined-server-variable': 'error',
|
|
63
|
+
'no-servers-empty-enum': 'error',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultPlugin = exports.builtInConfigs = void 0;
|
|
4
|
+
const recommended_1 = require("./recommended");
|
|
5
|
+
const all_1 = require("./all");
|
|
6
|
+
const minimal_1 = require("./minimal");
|
|
7
|
+
const oas3_1 = require("../rules/oas3");
|
|
8
|
+
const oas2_1 = require("../rules/oas2");
|
|
9
|
+
const oas3_2 = require("../rules/oas3");
|
|
10
|
+
const oas2_2 = require("../rules/oas2");
|
|
11
|
+
const oas3_3 = require("../decorators/oas3");
|
|
12
|
+
const oas2_3 = require("../decorators/oas2");
|
|
13
|
+
exports.builtInConfigs = {
|
|
14
|
+
recommended: recommended_1.default,
|
|
15
|
+
minimal: minimal_1.default,
|
|
16
|
+
all: all_1.default,
|
|
17
|
+
'redocly-registry': {
|
|
18
|
+
decorators: { 'registry-dependencies': 'on' }
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.defaultPlugin = {
|
|
22
|
+
id: '',
|
|
23
|
+
rules: {
|
|
24
|
+
oas3: oas3_1.rules,
|
|
25
|
+
oas2: oas2_1.rules,
|
|
26
|
+
},
|
|
27
|
+
preprocessors: {
|
|
28
|
+
oas3: oas3_2.preprocessors,
|
|
29
|
+
oas2: oas2_2.preprocessors,
|
|
30
|
+
},
|
|
31
|
+
decorators: {
|
|
32
|
+
oas3: oas3_3.decorators,
|
|
33
|
+
oas2: oas2_3.decorators,
|
|
34
|
+
},
|
|
35
|
+
configs: exports.builtInConfigs,
|
|
36
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseResolver } from '../resolve';
|
|
2
|
+
import type { LintRawConfig, Plugin, RawConfig, ResolvedApi, ResolvedLintConfig } from './types';
|
|
3
|
+
import { Config } from './config';
|
|
4
|
+
export declare function resolveConfig(rawConfig: RawConfig, configPath?: string): Promise<Config>;
|
|
5
|
+
export declare function resolvePlugins(plugins: (string | Plugin)[] | null, configPath?: string): Plugin[];
|
|
6
|
+
export declare function resolveApis({ rawConfig, configPath, resolver, }: {
|
|
7
|
+
rawConfig: RawConfig;
|
|
8
|
+
configPath?: string;
|
|
9
|
+
resolver?: BaseResolver;
|
|
10
|
+
}): Promise<Record<string, ResolvedApi>>;
|
|
11
|
+
export declare function resolveLint(lintOpts: {
|
|
12
|
+
lintConfig?: LintRawConfig;
|
|
13
|
+
configPath?: string;
|
|
14
|
+
resolver?: BaseResolver;
|
|
15
|
+
}, parentConfigPaths?: string[], extendPaths?: string[]): Promise<ResolvedLintConfig>;
|
|
16
|
+
export declare function resolvePreset(presetName: string, plugins: Plugin[]): ResolvedLintConfig;
|
|
@@ -0,0 +1,242 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.resolvePreset = exports.resolveLint = exports.resolveApis = exports.resolvePlugins = exports.resolveConfig = void 0;
|
|
24
|
+
const path = require("path");
|
|
25
|
+
const colorette_1 = require("colorette");
|
|
26
|
+
const ref_utils_1 = require("../ref-utils");
|
|
27
|
+
const resolve_1 = require("../resolve");
|
|
28
|
+
const builtIn_1 = require("./builtIn");
|
|
29
|
+
const utils_1 = require("./utils");
|
|
30
|
+
const utils_2 = require("../utils");
|
|
31
|
+
const config_1 = require("./config");
|
|
32
|
+
function resolveConfig(rawConfig, configPath) {
|
|
33
|
+
var _a, _b, _c, _d, _e;
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
if ((_b = (_a = rawConfig.lint) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_2.isNotString)) {
|
|
36
|
+
throw new Error(`Error configuration format not detected in extends value must contain strings`);
|
|
37
|
+
}
|
|
38
|
+
const resolver = new resolve_1.BaseResolver(utils_1.getResolveConfig(rawConfig.resolve));
|
|
39
|
+
const configExtends = (_d = (_c = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.lint) === null || _c === void 0 ? void 0 : _c.extends) !== null && _d !== void 0 ? _d : ['recommended'];
|
|
40
|
+
const recommendedFallback = !((_e = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.lint) === null || _e === void 0 ? void 0 : _e.extends);
|
|
41
|
+
const lintConfig = Object.assign(Object.assign({}, rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.lint), { extends: configExtends, recommendedFallback });
|
|
42
|
+
const apis = yield resolveApis({
|
|
43
|
+
rawConfig: Object.assign(Object.assign({}, rawConfig), { lint: lintConfig }),
|
|
44
|
+
configPath,
|
|
45
|
+
resolver,
|
|
46
|
+
});
|
|
47
|
+
const lint = yield resolveLint({
|
|
48
|
+
lintConfig,
|
|
49
|
+
configPath,
|
|
50
|
+
resolver,
|
|
51
|
+
});
|
|
52
|
+
return new config_1.Config(Object.assign(Object.assign({}, rawConfig), { apis,
|
|
53
|
+
lint }), configPath);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.resolveConfig = resolveConfig;
|
|
57
|
+
function resolvePlugins(plugins, configPath = '') {
|
|
58
|
+
if (!plugins)
|
|
59
|
+
return [];
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
|
|
62
|
+
const seenPluginIds = new Map();
|
|
63
|
+
return plugins
|
|
64
|
+
.map((p) => {
|
|
65
|
+
if (utils_2.isString(p) && ref_utils_1.isAbsoluteUrl(p)) {
|
|
66
|
+
throw new Error(colorette_1.red(`We don't support remote plugins yet.`));
|
|
67
|
+
}
|
|
68
|
+
// TODO: resolve npm packages similar to eslint
|
|
69
|
+
const pluginModule = utils_2.isString(p)
|
|
70
|
+
? requireFunc(path.resolve(path.dirname(configPath), p))
|
|
71
|
+
: p;
|
|
72
|
+
const id = pluginModule.id;
|
|
73
|
+
if (typeof id !== 'string') {
|
|
74
|
+
throw new Error(colorette_1.red(`Plugin must define \`id\` property in ${colorette_1.blue(p.toString())}.`));
|
|
75
|
+
}
|
|
76
|
+
if (seenPluginIds.has(id)) {
|
|
77
|
+
const pluginPath = seenPluginIds.get(id);
|
|
78
|
+
throw new Error(colorette_1.red(`Plugin "id" must be unique. Plugin ${colorette_1.blue(p.toString())} uses id "${colorette_1.blue(id)}" already seen in ${colorette_1.blue(pluginPath)}`));
|
|
79
|
+
}
|
|
80
|
+
seenPluginIds.set(id, p.toString());
|
|
81
|
+
const plugin = Object.assign(Object.assign({ id }, (pluginModule.configs ? { configs: pluginModule.configs } : {})), (pluginModule.typeExtension ? { typeExtension: pluginModule.typeExtension } : {}));
|
|
82
|
+
if (pluginModule.rules) {
|
|
83
|
+
if (!pluginModule.rules.oas3 && !pluginModule.rules.oas2) {
|
|
84
|
+
throw new Error(`Plugin rules must have \`oas3\` or \`oas2\` rules "${p}.`);
|
|
85
|
+
}
|
|
86
|
+
plugin.rules = {};
|
|
87
|
+
if (pluginModule.rules.oas3) {
|
|
88
|
+
plugin.rules.oas3 = utils_1.prefixRules(pluginModule.rules.oas3, id);
|
|
89
|
+
}
|
|
90
|
+
if (pluginModule.rules.oas2) {
|
|
91
|
+
plugin.rules.oas2 = utils_1.prefixRules(pluginModule.rules.oas2, id);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (pluginModule.preprocessors) {
|
|
95
|
+
if (!pluginModule.preprocessors.oas3 && !pluginModule.preprocessors.oas2) {
|
|
96
|
+
throw new Error(`Plugin \`preprocessors\` must have \`oas3\` or \`oas2\` preprocessors "${p}.`);
|
|
97
|
+
}
|
|
98
|
+
plugin.preprocessors = {};
|
|
99
|
+
if (pluginModule.preprocessors.oas3) {
|
|
100
|
+
plugin.preprocessors.oas3 = utils_1.prefixRules(pluginModule.preprocessors.oas3, id);
|
|
101
|
+
}
|
|
102
|
+
if (pluginModule.preprocessors.oas2) {
|
|
103
|
+
plugin.preprocessors.oas2 = utils_1.prefixRules(pluginModule.preprocessors.oas2, id);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (pluginModule.decorators) {
|
|
107
|
+
if (!pluginModule.decorators.oas3 && !pluginModule.decorators.oas2) {
|
|
108
|
+
throw new Error(`Plugin \`decorators\` must have \`oas3\` or \`oas2\` decorators "${p}.`);
|
|
109
|
+
}
|
|
110
|
+
plugin.decorators = {};
|
|
111
|
+
if (pluginModule.decorators.oas3) {
|
|
112
|
+
plugin.decorators.oas3 = utils_1.prefixRules(pluginModule.decorators.oas3, id);
|
|
113
|
+
}
|
|
114
|
+
if (pluginModule.decorators.oas2) {
|
|
115
|
+
plugin.decorators.oas2 = utils_1.prefixRules(pluginModule.decorators.oas2, id);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return plugin;
|
|
119
|
+
})
|
|
120
|
+
.filter(utils_2.notUndefined);
|
|
121
|
+
}
|
|
122
|
+
exports.resolvePlugins = resolvePlugins;
|
|
123
|
+
function resolveApis({ rawConfig, configPath = '', resolver, }) {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const { apis = {}, lint: lintConfig = {} } = rawConfig;
|
|
127
|
+
let resolvedApis = {};
|
|
128
|
+
for (const [apiName, apiContent] of Object.entries(apis || {})) {
|
|
129
|
+
if ((_b = (_a = apiContent.lint) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_2.isNotString)) {
|
|
130
|
+
throw new Error(`Error configuration format not detected in extends value must contain strings`);
|
|
131
|
+
}
|
|
132
|
+
const rawLintConfig = getMergedLintRawConfig(lintConfig, apiContent.lint);
|
|
133
|
+
const apiLint = yield resolveLint({
|
|
134
|
+
lintConfig: rawLintConfig,
|
|
135
|
+
configPath,
|
|
136
|
+
resolver,
|
|
137
|
+
});
|
|
138
|
+
resolvedApis[apiName] = Object.assign(Object.assign({}, apiContent), { lint: apiLint });
|
|
139
|
+
}
|
|
140
|
+
return resolvedApis;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
exports.resolveApis = resolveApis;
|
|
144
|
+
function resolveAndMergeNestedLint({ lintConfig, configPath = '', resolver = new resolve_1.BaseResolver(), }, parentConfigPaths = [], extendPaths = []) {
|
|
145
|
+
var _a, _b, _c;
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
if (parentConfigPaths.includes(configPath)) {
|
|
148
|
+
throw new Error(`Circular dependency in config file: "${configPath}"`);
|
|
149
|
+
}
|
|
150
|
+
const plugins = utils_1.getUniquePlugins(resolvePlugins([...((lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.plugins) || []), builtIn_1.defaultPlugin], configPath));
|
|
151
|
+
const pluginPaths = (_a = lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.plugins) === null || _a === void 0 ? void 0 : _a.filter(utils_2.isString).map((p) => path.resolve(path.dirname(configPath), p));
|
|
152
|
+
const resolvedConfigPath = ref_utils_1.isAbsoluteUrl(configPath)
|
|
153
|
+
? configPath
|
|
154
|
+
: configPath && path.resolve(configPath);
|
|
155
|
+
const extendConfigs = yield Promise.all(((_b = lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.extends) === null || _b === void 0 ? void 0 : _b.map((presetItem) => __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
if (!ref_utils_1.isAbsoluteUrl(presetItem) && !path.extname(presetItem)) {
|
|
157
|
+
return resolvePreset(presetItem, plugins);
|
|
158
|
+
}
|
|
159
|
+
const pathItem = ref_utils_1.isAbsoluteUrl(presetItem)
|
|
160
|
+
? presetItem
|
|
161
|
+
: ref_utils_1.isAbsoluteUrl(configPath)
|
|
162
|
+
? new URL(presetItem, configPath).href
|
|
163
|
+
: path.resolve(path.dirname(configPath), presetItem);
|
|
164
|
+
const extendedLintConfig = yield loadExtendLintConfig(pathItem, resolver);
|
|
165
|
+
return yield resolveAndMergeNestedLint({
|
|
166
|
+
lintConfig: extendedLintConfig,
|
|
167
|
+
configPath: pathItem,
|
|
168
|
+
resolver: resolver,
|
|
169
|
+
}, [...parentConfigPaths, resolvedConfigPath], extendPaths);
|
|
170
|
+
}))) || []);
|
|
171
|
+
const _d = utils_1.mergeExtends([
|
|
172
|
+
...extendConfigs,
|
|
173
|
+
Object.assign(Object.assign({}, lintConfig), { plugins, extends: undefined, extendPaths: [...parentConfigPaths, resolvedConfigPath], pluginPaths }),
|
|
174
|
+
]), { plugins: mergedPlugins = [] } = _d, lint = __rest(_d, ["plugins"]);
|
|
175
|
+
return Object.assign(Object.assign({}, lint), { extendPaths: (_c = lint.extendPaths) === null || _c === void 0 ? void 0 : _c.filter((path) => path && !ref_utils_1.isAbsoluteUrl(path)), plugins: utils_1.getUniquePlugins(mergedPlugins), recommendedFallback: lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.recommendedFallback, doNotResolveExamples: lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.doNotResolveExamples });
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function resolveLint(lintOpts, parentConfigPaths = [], extendPaths = []) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const resolvedLint = yield resolveAndMergeNestedLint(lintOpts, parentConfigPaths, extendPaths);
|
|
181
|
+
return Object.assign(Object.assign({}, resolvedLint), { rules: resolvedLint.rules && groupLintAssertionRules(resolvedLint.rules) });
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
exports.resolveLint = resolveLint;
|
|
185
|
+
function resolvePreset(presetName, plugins) {
|
|
186
|
+
var _a;
|
|
187
|
+
const { pluginId, configName } = utils_1.parsePresetName(presetName);
|
|
188
|
+
const plugin = plugins.find((p) => p.id === pluginId);
|
|
189
|
+
if (!plugin) {
|
|
190
|
+
throw new Error(`Invalid config ${colorette_1.red(presetName)}: plugin ${pluginId} is not included.`);
|
|
191
|
+
}
|
|
192
|
+
const preset = (_a = plugin.configs) === null || _a === void 0 ? void 0 : _a[configName];
|
|
193
|
+
if (!preset) {
|
|
194
|
+
throw new Error(pluginId
|
|
195
|
+
? `Invalid config ${colorette_1.red(presetName)}: plugin ${pluginId} doesn't export config with name ${configName}.`
|
|
196
|
+
: `Invalid config ${colorette_1.red(presetName)}: there is no such built-in config.`);
|
|
197
|
+
}
|
|
198
|
+
return preset;
|
|
199
|
+
}
|
|
200
|
+
exports.resolvePreset = resolvePreset;
|
|
201
|
+
function loadExtendLintConfig(filePath, resolver) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
try {
|
|
204
|
+
const fileSource = yield resolver.loadExternalRef(filePath);
|
|
205
|
+
const rawConfig = utils_1.transformConfig(utils_2.parseYaml(fileSource.body));
|
|
206
|
+
if (!rawConfig.lint) {
|
|
207
|
+
throw new Error(`Lint configuration format not detected: "${filePath}"`);
|
|
208
|
+
}
|
|
209
|
+
return rawConfig.lint;
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
throw new Error(`Failed to load "${filePath}": ${error.message}`);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function getMergedLintRawConfig(configLint, apiLint) {
|
|
217
|
+
const resultLint = Object.assign(Object.assign(Object.assign({}, configLint), apiLint), { rules: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.rules), apiLint === null || apiLint === void 0 ? void 0 : apiLint.rules), oas2Rules: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas2Rules), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas2Rules), oas3_0Rules: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_0Rules), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_0Rules), oas3_1Rules: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_1Rules), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_1Rules), preprocessors: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.preprocessors), apiLint === null || apiLint === void 0 ? void 0 : apiLint.preprocessors), oas2Preprocessors: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas2Preprocessors), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas2Preprocessors), oas3_0Preprocessors: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_0Preprocessors), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_0Preprocessors), oas3_1Preprocessors: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_1Preprocessors), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_1Preprocessors), decorators: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.decorators), apiLint === null || apiLint === void 0 ? void 0 : apiLint.decorators), oas2Decorators: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas2Decorators), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas2Decorators), oas3_0Decorators: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_0Decorators), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_0Decorators), oas3_1Decorators: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_1Decorators), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_1Decorators), recommendedFallback: (apiLint === null || apiLint === void 0 ? void 0 : apiLint.extends) ? false : configLint.recommendedFallback });
|
|
218
|
+
return resultLint;
|
|
219
|
+
}
|
|
220
|
+
function groupLintAssertionRules(rules) {
|
|
221
|
+
if (!rules) {
|
|
222
|
+
return rules;
|
|
223
|
+
}
|
|
224
|
+
// Create a new record to avoid mutating original
|
|
225
|
+
const transformedRules = {};
|
|
226
|
+
// Collect assertion rules
|
|
227
|
+
const assertions = [];
|
|
228
|
+
for (const [ruleKey, rule] of Object.entries(rules)) {
|
|
229
|
+
if (ruleKey.startsWith('assert/') && typeof rule === 'object' && rule !== null) {
|
|
230
|
+
const assertion = rule;
|
|
231
|
+
assertions.push(Object.assign(Object.assign({}, assertion), { assertionId: ruleKey.replace('assert/', '') }));
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
// If it's not an assertion, keep it as is
|
|
235
|
+
transformedRules[ruleKey] = rule;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (assertions.length > 0) {
|
|
239
|
+
transformedRules.assertions = assertions;
|
|
240
|
+
}
|
|
241
|
+
return transformedRules;
|
|
242
|
+
}
|