@redocly/openapi-core 1.18.1 → 1.20.0
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/CHANGELOG.md +22 -0
- package/__tests__/utils.ts +14 -7
- package/lib/benchmark/benches/lint-with-many-rules.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +7 -3
- package/lib/benchmark/benches/lint-with-nested-rule.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +7 -3
- package/lib/benchmark/benches/lint-with-no-rules.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +7 -3
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +19 -15
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +18 -14
- package/lib/benchmark/benches/recommended-oas3.bench.js +2 -2
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +2 -2
- package/lib/benchmark/utils.d.ts +3 -3
- package/lib/benchmark/utils.js +10 -7
- package/lib/bundle.d.ts +2 -2
- package/lib/bundle.js +127 -120
- package/lib/config/all.js +13 -1
- package/lib/config/builtIn.js +18 -17
- package/lib/config/config-resolvers.d.ts +1 -1
- package/lib/config/config-resolvers.js +241 -158
- package/lib/config/config.d.ts +4 -3
- package/lib/config/config.js +53 -34
- package/lib/config/load.d.ts +1 -1
- package/lib/config/load.js +105 -117
- package/lib/config/minimal.js +13 -0
- package/lib/config/recommended-strict.js +14 -1
- package/lib/config/recommended.js +14 -1
- package/lib/config/rules.d.ts +3 -3
- package/lib/config/rules.js +1 -2
- package/lib/config/types.d.ts +17 -4
- package/lib/config/utils.d.ts +3 -1
- package/lib/config/utils.js +78 -49
- package/lib/decorators/async3/index.d.ts +1 -0
- package/lib/decorators/async3/index.js +4 -0
- package/lib/decorators/common/filters/filter-helper.d.ts +1 -1
- package/lib/decorators/common/filters/filter-helper.js +2 -3
- package/lib/decorators/common/filters/filter-in.d.ts +1 -1
- package/lib/decorators/common/filters/filter-in.js +1 -1
- package/lib/decorators/common/filters/filter-out.d.ts +1 -1
- package/lib/decorators/common/filters/filter-out.js +1 -1
- package/lib/decorators/common/info-description-override.d.ts +1 -1
- package/lib/decorators/common/info-override.d.ts +1 -1
- package/lib/decorators/common/info-override.js +1 -12
- package/lib/decorators/common/media-type-examples-override.d.ts +1 -1
- package/lib/decorators/common/media-type-examples-override.js +8 -2
- package/lib/decorators/common/operation-description-override.d.ts +1 -1
- package/lib/decorators/common/registry-dependencies.d.ts +1 -1
- package/lib/decorators/common/remove-x-internal.d.ts +1 -1
- package/lib/decorators/common/remove-x-internal.js +4 -5
- package/lib/decorators/common/tag-description-override.d.ts +1 -1
- package/lib/decorators/oas2/index.d.ts +1 -1
- package/lib/decorators/oas2/remove-unused-components.js +1 -2
- package/lib/decorators/oas3/index.d.ts +1 -1
- package/lib/decorators/oas3/remove-unused-components.js +1 -2
- package/lib/env.d.ts +0 -1
- package/lib/env.js +1 -1
- package/lib/format/codeframes.d.ts +1 -1
- package/lib/format/codeframes.js +10 -8
- package/lib/format/format.d.ts +1 -1
- package/lib/format/format.js +24 -16
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -4
- package/lib/js-yaml/index.d.ts +1 -1
- package/lib/js-yaml/index.js +1 -1
- package/lib/lint.d.ts +3 -1
- package/lib/lint.js +92 -99
- package/lib/logger.js +2 -2
- package/lib/oas-types.d.ts +9 -5
- package/lib/oas-types.js +22 -12
- package/lib/redocly/domains.d.ts +1 -1
- package/lib/redocly/domains.js +6 -6
- package/lib/redocly/index.d.ts +1 -1
- package/lib/redocly/index.js +60 -73
- package/lib/redocly/registry-api.js +64 -82
- package/lib/ref-utils.d.ts +2 -2
- package/lib/ref-utils.js +14 -13
- package/lib/resolve.d.ts +2 -2
- package/lib/resolve.js +186 -205
- package/lib/rules/ajv.d.ts +1 -1
- package/lib/rules/ajv.js +10 -8
- package/lib/rules/arazzo/index.js +2 -0
- package/lib/rules/async2/channels-kebab-case.d.ts +1 -1
- package/lib/rules/async2/index.js +2 -0
- package/lib/rules/async2/no-channel-trailing-slash.d.ts +1 -1
- package/lib/rules/async3/channels-kebab-case.d.ts +2 -0
- package/lib/rules/async3/channels-kebab-case.js +19 -0
- package/lib/rules/async3/index.d.ts +3 -0
- package/lib/rules/async3/index.js +24 -0
- package/lib/rules/async3/no-channel-trailing-slash.d.ts +2 -0
- package/lib/rules/async3/no-channel-trailing-slash.js +16 -0
- package/lib/rules/common/assertions/asserts.d.ts +2 -2
- package/lib/rules/common/assertions/asserts.js +5 -5
- package/lib/rules/common/assertions/index.d.ts +4 -4
- package/lib/rules/common/assertions/utils.d.ts +1 -1
- package/lib/rules/common/assertions/utils.js +43 -28
- package/lib/rules/common/info-contact.d.ts +1 -1
- package/lib/rules/common/info-license-strict.d.ts +2 -0
- package/lib/rules/common/info-license-strict.js +26 -0
- package/lib/rules/common/info-license-url.d.ts +1 -1
- package/lib/rules/common/info-license.d.ts +1 -1
- package/lib/rules/common/no-ambiguous-paths.d.ts +1 -1
- package/lib/rules/common/no-enum-type-mismatch.d.ts +1 -1
- package/lib/rules/common/no-http-verbs-in-paths.d.ts +1 -1
- package/lib/rules/common/no-identical-paths.d.ts +1 -1
- package/lib/rules/common/no-invalid-parameter-examples.js +1 -2
- package/lib/rules/common/no-invalid-schema-examples.js +1 -2
- package/lib/rules/common/no-path-trailing-slash.d.ts +1 -1
- package/lib/rules/common/no-required-schema-properties-undefined.d.ts +1 -1
- package/lib/rules/common/no-required-schema-properties-undefined.js +1 -2
- package/lib/rules/common/operation-2xx-response.d.ts +1 -1
- package/lib/rules/common/operation-4xx-response.d.ts +1 -1
- package/lib/rules/common/operation-description.d.ts +1 -1
- package/lib/rules/common/operation-operationId-unique.d.ts +1 -1
- package/lib/rules/common/operation-operationId-url-safe.d.ts +1 -1
- package/lib/rules/common/operation-operationId-url-safe.js +1 -0
- package/lib/rules/common/operation-operationId.d.ts +1 -1
- package/lib/rules/common/operation-parameters-unique.d.ts +1 -1
- package/lib/rules/common/operation-singular-tag.d.ts +1 -1
- package/lib/rules/common/operation-summary.d.ts +1 -1
- package/lib/rules/common/operation-tag-defined.d.ts +1 -1
- package/lib/rules/common/operation-tag-defined.js +1 -2
- package/lib/rules/common/parameter-description.d.ts +1 -1
- package/lib/rules/common/path-declaration-must-exist.d.ts +1 -1
- package/lib/rules/common/path-excludes-patterns.d.ts +1 -1
- package/lib/rules/common/path-http-verbs-order.d.ts +1 -1
- package/lib/rules/common/path-http-verbs-order.js +1 -1
- package/lib/rules/common/path-not-include-query.d.ts +1 -1
- package/lib/rules/common/path-params-defined.d.ts +1 -1
- package/lib/rules/common/path-segment-plural.d.ts +1 -1
- package/lib/rules/common/paths-kebab-case.d.ts +1 -1
- package/lib/rules/common/required-string-property-missing-min-length.d.ts +1 -1
- package/lib/rules/common/required-string-property-missing-min-length.js +2 -2
- package/lib/rules/common/response-contains-header.d.ts +1 -1
- package/lib/rules/common/response-contains-header.js +2 -2
- package/lib/rules/common/security-defined.d.ts +1 -1
- package/lib/rules/common/security-defined.js +3 -7
- package/lib/rules/common/spec-strict-refs.d.ts +1 -1
- package/lib/rules/common/spec.d.ts +2 -2
- package/lib/rules/common/spec.js +6 -7
- package/lib/rules/common/tag-description.d.ts +1 -1
- package/lib/rules/common/tags-alphabetical.d.ts +1 -1
- package/lib/rules/no-unresolved-refs.d.ts +3 -3
- package/lib/rules/no-unresolved-refs.js +3 -4
- package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas2/index.d.ts +1 -1
- package/lib/rules/oas2/index.js +2 -0
- package/lib/rules/oas2/response-contains-property.d.ts +1 -1
- package/lib/rules/oas2/response-contains-property.js +1 -2
- package/lib/rules/oas3/array-parameter-serialization.d.ts +1 -1
- package/lib/rules/oas3/array-parameter-serialization.js +1 -2
- package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas3/component-name-unique.d.ts +1 -1
- package/lib/rules/oas3/component-name-unique.js +2 -4
- package/lib/rules/oas3/index.d.ts +1 -1
- package/lib/rules/oas3/index.js +2 -0
- package/lib/rules/oas3/no-empty-servers.d.ts +1 -1
- package/lib/rules/oas3/no-example-value-and-externalValue.d.ts +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.d.ts +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +1 -2
- package/lib/rules/oas3/no-server-example.com.d.ts +1 -1
- package/lib/rules/oas3/no-server-example.com.js +1 -0
- package/lib/rules/oas3/no-server-trailing-slash.d.ts +1 -1
- package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +1 -1
- package/lib/rules/oas3/no-server-variables-empty-enum.js +1 -2
- package/lib/rules/oas3/no-undefined-server-variable.d.ts +1 -1
- package/lib/rules/oas3/no-undefined-server-variable.js +2 -3
- package/lib/rules/oas3/no-unused-components.d.ts +1 -1
- package/lib/rules/oas3/no-unused-components.js +1 -2
- package/lib/rules/oas3/response-contains-property.d.ts +1 -1
- package/lib/rules/oas3/response-contains-property.js +1 -2
- package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +1 -1
- package/lib/rules/other/stats.d.ts +3 -3
- package/lib/rules/other/stats.js +5 -3
- package/lib/rules/spot/parameters-no-body-inside-in.d.ts +2 -0
- package/lib/rules/spot/parameters-no-body-inside-in.js +18 -0
- package/lib/rules/utils.d.ts +4 -2
- package/lib/rules/utils.js +41 -13
- package/lib/types/arazzo.d.ts +1 -2275
- package/lib/types/arazzo.js +246 -309
- package/lib/types/asyncapi2.d.ts +17 -0
- package/lib/types/{asyncapi.js → asyncapi2.js} +59 -53
- package/lib/types/asyncapi3.d.ts +2 -0
- package/lib/types/asyncapi3.js +347 -0
- package/lib/types/index.js +19 -10
- package/lib/types/json-schema-adapter.d.ts +1 -1
- package/lib/types/json-schema-adapter.js +4 -18
- package/lib/types/oas2.js +6 -6
- package/lib/types/oas3.d.ts +4 -0
- package/lib/types/oas3.js +19 -19
- package/lib/types/oas3_1.d.ts +3 -0
- package/lib/types/oas3_1.js +20 -14
- package/lib/types/redocly-yaml.d.ts +8 -6
- package/lib/types/redocly-yaml.js +135 -36
- package/lib/typings/arazzo.d.ts +145 -27
- package/lib/typings/asyncapi3.d.ts +53 -0
- package/lib/typings/asyncapi3.js +2 -0
- package/lib/typings/common.d.ts +1 -1
- package/lib/typings/swagger.d.ts +2 -2
- package/lib/utils.d.ts +4 -3
- package/lib/utils.js +55 -72
- package/lib/visitors.d.ts +29 -1
- package/lib/visitors.js +21 -8
- package/lib/walk.d.ts +3 -3
- package/lib/walk.js +30 -23
- package/package.json +3 -3
- package/src/__tests__/bundle.test.ts +144 -2
- package/src/__tests__/lint.test.ts +29 -21
- package/src/__tests__/walk.test.ts +25 -25
- package/src/benchmark/benches/lint-with-many-rules.bench.ts +7 -1
- package/src/benchmark/benches/lint-with-nested-rule.bench.ts +7 -1
- package/src/benchmark/benches/lint-with-no-rules.bench.ts +8 -1
- package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +18 -13
- package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +17 -11
- package/src/benchmark/fork.js +4 -0
- package/src/benchmark/utils.ts +6 -5
- package/src/bundle.ts +19 -4
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +32 -2
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +24 -0
- package/src/config/__tests__/config-resolvers.test.ts +82 -0
- package/src/config/__tests__/config.test.ts +11 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-commonjs-export-function.yaml +2 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-esm.yaml +2 -0
- package/src/config/__tests__/fixtures/resolve-config/plugin-esm.mjs +10 -0
- package/src/config/__tests__/fixtures/resolve-config/plugin-with-export-function.cjs +10 -0
- package/src/config/__tests__/resolve-plugins.test.ts +4 -1
- package/src/config/all.ts +13 -1
- package/src/config/builtIn.ts +9 -8
- package/src/config/config-resolvers.ts +92 -21
- package/src/config/config.ts +31 -13
- package/src/config/load.ts +2 -2
- package/src/config/minimal.ts +13 -0
- package/src/config/recommended-strict.ts +14 -1
- package/src/config/recommended.ts +14 -1
- package/src/config/rules.ts +12 -4
- package/src/config/types.ts +34 -5
- package/src/config/utils.ts +28 -2
- package/src/decorators/__tests__/filter-in.test.ts +29 -26
- package/src/decorators/__tests__/filter-out.test.ts +32 -23
- package/src/decorators/__tests__/media-type-examples-override.test.ts +45 -45
- package/src/decorators/__tests__/remove-x-internal.test.ts +8 -5
- package/src/decorators/async3/index.ts +1 -0
- package/src/decorators/common/filters/filter-helper.ts +2 -1
- package/src/decorators/common/filters/filter-in.ts +2 -1
- package/src/decorators/common/filters/filter-out.ts +2 -1
- package/src/decorators/common/info-description-override.ts +3 -2
- package/src/decorators/common/info-override.ts +1 -1
- package/src/decorators/common/media-type-examples-override.ts +4 -3
- package/src/decorators/common/operation-description-override.ts +5 -4
- package/src/decorators/common/registry-dependencies.ts +2 -2
- package/src/decorators/common/remove-x-internal.ts +5 -4
- package/src/decorators/common/tag-description-override.ts +3 -2
- package/src/decorators/oas2/__tests__/remove-unused-components.test.ts +3 -3
- package/src/decorators/oas2/index.ts +2 -1
- package/src/decorators/oas2/remove-unused-components.ts +1 -1
- package/src/decorators/oas3/__tests__/remove-unused-components.test.ts +4 -4
- package/src/decorators/oas3/index.ts +2 -1
- package/src/decorators/oas3/remove-unused-components.ts +1 -1
- package/src/format/codeframes.ts +2 -1
- package/src/format/format.ts +9 -4
- package/src/index.ts +2 -1
- package/src/js-yaml/index.ts +3 -1
- package/src/lint.ts +28 -4
- package/src/logger.ts +2 -2
- package/src/oas-types.ts +41 -22
- package/src/redocly/domains.ts +1 -1
- package/src/redocly/index.ts +3 -3
- package/src/redocly/registry-api.ts +5 -3
- package/src/ref-utils.ts +4 -2
- package/src/resolve.ts +6 -4
- package/src/rules/__tests__/no-unresolved-refs.test.ts +21 -7
- package/src/rules/ajv.ts +2 -1
- package/src/rules/arazzo/__tests__/parameters-no-body-inside-in.test.ts +76 -0
- package/src/rules/arazzo/index.ts +6 -3
- package/src/rules/async2/__tests__/channels-kebab-case.test.ts +9 -5
- package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +3 -3
- package/src/rules/async2/channels-kebab-case.ts +2 -2
- package/src/rules/async2/index.ts +9 -6
- package/src/rules/async2/no-channel-trailing-slash.ts +2 -2
- package/src/rules/async3/__tests__/channels-kebab-case.test.ts +145 -0
- package/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts +96 -0
- package/src/rules/async3/channels-kebab-case.ts +19 -0
- package/src/rules/async3/index.ts +26 -0
- package/src/rules/async3/no-channel-trailing-slash.ts +16 -0
- package/src/rules/common/__tests__/info-license-strict.test.ts +141 -0
- package/src/rules/common/__tests__/info-license.test.ts +2 -2
- package/src/rules/common/__tests__/license-url.test.ts +2 -2
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +5 -5
- package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-invalid-parameter-examples.test.ts +1 -1
- package/src/rules/common/__tests__/no-invalid-schema-examples.test.ts +1 -1
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +4 -4
- package/src/rules/common/__tests__/no-required-schema-properties-undefined.test.ts +11 -11
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +8 -6
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +9 -7
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +2 -2
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -1
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +4 -4
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +2 -2
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +2 -2
- package/src/rules/common/__tests__/path-not-include-query.test.ts +2 -2
- package/src/rules/common/__tests__/path-params-defined.test.ts +5 -5
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +6 -4
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +8 -8
- package/src/rules/common/__tests__/security-defined.test.ts +14 -8
- package/src/rules/common/__tests__/spec-strict-refs.test.ts +1 -1
- package/src/rules/common/__tests__/spec.test.ts +10 -10
- package/src/rules/common/__tests__/tag-description.test.ts +2 -2
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +6 -4
- package/src/rules/common/assertions/asserts.ts +5 -9
- package/src/rules/common/assertions/index.ts +12 -4
- package/src/rules/common/assertions/utils.ts +4 -2
- package/src/rules/common/info-contact.ts +2 -1
- package/src/rules/common/info-license-strict.ts +24 -0
- package/src/rules/common/info-license-url.ts +2 -1
- package/src/rules/common/info-license.ts +2 -1
- package/src/rules/common/no-ambiguous-paths.ts +4 -4
- package/src/rules/common/no-enum-type-mismatch.ts +5 -4
- package/src/rules/common/no-http-verbs-in-paths.ts +5 -4
- package/src/rules/common/no-identical-paths.ts +4 -4
- package/src/rules/common/no-invalid-parameter-examples.ts +3 -2
- package/src/rules/common/no-path-trailing-slash.ts +2 -2
- package/src/rules/common/no-required-schema-properties-undefined.ts +5 -4
- package/src/rules/common/operation-2xx-response.ts +3 -2
- package/src/rules/common/operation-4xx-response.ts +3 -2
- package/src/rules/common/operation-description.ts +5 -4
- package/src/rules/common/operation-operationId-unique.ts +4 -4
- package/src/rules/common/operation-operationId-url-safe.ts +5 -4
- package/src/rules/common/operation-operationId.ts +5 -4
- package/src/rules/common/operation-parameters-unique.ts +4 -4
- package/src/rules/common/operation-singular-tag.ts +4 -4
- package/src/rules/common/operation-summary.ts +5 -4
- package/src/rules/common/operation-tag-defined.ts +4 -4
- package/src/rules/common/parameter-description.ts +4 -4
- package/src/rules/common/path-declaration-must-exist.ts +2 -2
- package/src/rules/common/path-excludes-patterns.ts +4 -4
- package/src/rules/common/path-http-verbs-order.ts +4 -4
- package/src/rules/common/path-not-include-query.ts +2 -2
- package/src/rules/common/path-params-defined.ts +4 -4
- package/src/rules/common/path-segment-plural.ts +3 -2
- package/src/rules/common/paths-kebab-case.ts +2 -2
- package/src/rules/common/required-string-property-missing-min-length.ts +4 -4
- package/src/rules/common/response-contains-header.ts +5 -4
- package/src/rules/common/scalar-property-missing-example.ts +2 -1
- package/src/rules/common/security-defined.ts +5 -5
- package/src/rules/common/spec-strict-refs.ts +2 -1
- package/src/rules/common/spec.ts +4 -3
- package/src/rules/common/tag-description.ts +2 -1
- package/src/rules/common/tags-alphabetical.ts +4 -4
- package/src/rules/no-unresolved-refs.ts +4 -3
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -5
- package/src/rules/oas2/__tests__/response-contains-header.test.ts +14 -8
- package/src/rules/oas2/__tests__/response-contains-property.test.ts +14 -8
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +3 -1
- package/src/rules/oas2/boolean-parameter-prefixes.ts +1 -1
- package/src/rules/oas2/index.ts +8 -6
- package/src/rules/oas2/request-mime-type.ts +2 -1
- package/src/rules/oas2/response-contains-property.ts +3 -2
- package/src/rules/oas2/response-mime-type.ts +2 -1
- package/src/rules/oas3/__tests__/array-parameter-serialization.test.ts +18 -6
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -5
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +6 -6
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +2 -2
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +34 -24
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -1
- package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +3 -3
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +34 -22
- package/src/rules/oas3/__tests__/response-contains-property.test.ts +34 -20
- package/src/rules/oas3/__tests__/spec/spec.test.ts +12 -3
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +9 -3
- package/src/rules/oas3/__tests__/utils/lint-document-for-test.ts +1 -1
- package/src/rules/oas3/array-parameter-serialization.ts +3 -2
- package/src/rules/oas3/boolean-parameter-prefixes.ts +1 -1
- package/src/rules/oas3/component-name-unique.ts +3 -3
- package/src/rules/oas3/index.ts +42 -38
- package/src/rules/oas3/no-empty-servers.ts +1 -1
- package/src/rules/oas3/no-example-value-and-externalValue.ts +1 -1
- package/src/rules/oas3/no-invalid-media-type-examples.ts +6 -4
- package/src/rules/oas3/no-server-example.com.ts +2 -1
- package/src/rules/oas3/no-server-trailing-slash.ts +1 -1
- package/src/rules/oas3/no-server-variables-empty-enum.ts +2 -2
- package/src/rules/oas3/no-undefined-server-variable.ts +1 -1
- package/src/rules/oas3/no-unused-components.ts +2 -2
- package/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts +2 -1
- package/src/rules/oas3/request-mime-type.ts +2 -1
- package/src/rules/oas3/response-contains-property.ts +3 -2
- package/src/rules/oas3/response-mime-type.ts +2 -1
- package/src/rules/oas3/spec-components-invalid-map-name.ts +3 -3
- package/src/rules/other/stats.ts +8 -6
- package/src/rules/spot/parameters-no-body-inside-in.ts +17 -0
- package/src/rules/utils.ts +41 -4
- package/src/types/arazzo.ts +257 -334
- package/src/types/{asyncapi.ts → asyncapi2.ts} +41 -35
- package/src/types/asyncapi3.ts +383 -0
- package/src/types/json-schema-adapter.ts +2 -2
- package/src/types/oas3.ts +4 -4
- package/src/types/oas3_1.ts +5 -4
- package/src/types/redocly-yaml.ts +21 -4
- package/src/typings/arazzo.ts +169 -41
- package/src/typings/asyncapi3.ts +61 -0
- package/src/typings/common.ts +1 -0
- package/src/typings/swagger.ts +2 -2
- package/src/utils.ts +5 -3
- package/src/visitors.ts +58 -1
- package/src/walk.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/types/asyncapi.d.ts +0 -2
package/lib/format/format.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getTotals = getTotals;
|
|
4
|
+
exports.formatProblems = formatProblems;
|
|
4
5
|
const path = require("path");
|
|
5
6
|
const logger_1 = require("../logger");
|
|
6
7
|
const output_1 = require("../output");
|
|
7
|
-
const coreVersion = require('../../package.json').version;
|
|
8
8
|
const codeframes_1 = require("./codeframes");
|
|
9
9
|
const env_1 = require("../env");
|
|
10
10
|
const ref_utils_1 = require("../ref-utils");
|
|
11
|
+
const coreVersion = require('../../package.json').version;
|
|
11
12
|
const ERROR_MESSAGE = {
|
|
12
13
|
INVALID_SEVERITY_LEVEL: 'Invalid severity level; accepted values: error or warn',
|
|
13
14
|
};
|
|
@@ -51,7 +52,6 @@ function getTotals(problems) {
|
|
|
51
52
|
ignored,
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
|
-
exports.getTotals = getTotals;
|
|
55
55
|
function formatProblems(problems, opts) {
|
|
56
56
|
const { maxProblems = 100, cwd = env_1.isBrowser ? '' : process.cwd(), format = 'codeframe', color = logger_1.colorOptions.enabled, totals = getTotals(problems), version = coreVersion, } = opts;
|
|
57
57
|
logger_1.colorOptions.enabled = color; // force colors if specified
|
|
@@ -158,17 +158,27 @@ function formatProblems(problems, opts) {
|
|
|
158
158
|
totals,
|
|
159
159
|
version,
|
|
160
160
|
problems: problems.map((p) => {
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
const problem = {
|
|
162
|
+
...p,
|
|
163
|
+
location: p.location.map((location) => ({
|
|
164
|
+
...location,
|
|
165
|
+
source: {
|
|
163
166
|
ref: (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef)
|
|
164
167
|
? location.source.absoluteRef
|
|
165
168
|
: path.relative(cwd, location.source.absoluteRef),
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
},
|
|
170
|
+
})),
|
|
171
|
+
from: p.from
|
|
172
|
+
? {
|
|
173
|
+
...p.from,
|
|
174
|
+
source: {
|
|
175
|
+
ref: (0, ref_utils_1.isAbsoluteUrl)(p.from?.source.absoluteRef)
|
|
176
|
+
? p.from?.source.absoluteRef
|
|
177
|
+
: path.relative(cwd, p.from?.source.absoluteRef || cwd),
|
|
178
|
+
},
|
|
179
|
+
}
|
|
180
|
+
: undefined,
|
|
181
|
+
};
|
|
172
182
|
if (env_1.env.FORMAT_JSON_WITH_CODEFRAMES) {
|
|
173
183
|
const location = p.location[0]; // TODO: support multiple locations
|
|
174
184
|
const loc = (0, codeframes_1.getLineColLocation)(location);
|
|
@@ -228,7 +238,6 @@ function formatProblems(problems, opts) {
|
|
|
228
238
|
output_1.output.write(`<error line="${line}" column="${col}" severity="${severity}" message="${message}" source="${source}" />\n`);
|
|
229
239
|
}
|
|
230
240
|
}
|
|
231
|
-
exports.formatProblems = formatProblems;
|
|
232
241
|
function formatSummary(problems) {
|
|
233
242
|
const counts = {};
|
|
234
243
|
for (const problem of problems) {
|
|
@@ -274,7 +283,7 @@ const groupByFiles = (problems) => {
|
|
|
274
283
|
ruleIdPad: 0,
|
|
275
284
|
locationPad: 0,
|
|
276
285
|
};
|
|
277
|
-
const mappedProblem =
|
|
286
|
+
const mappedProblem = { ...problem, location: problem.location.map(codeframes_1.getLineColLocation) };
|
|
278
287
|
fileGroups[absoluteRef].fileProblems.push(mappedProblem);
|
|
279
288
|
fileGroups[absoluteRef].ruleIdPad = Math.max(problem.ruleId.length, fileGroups[absoluteRef].ruleIdPad);
|
|
280
289
|
fileGroups[absoluteRef].locationPad = Math.max(Math.max(...mappedProblem.location.map((loc) => `${loc.start.line}:${loc.start.col}`.length)), fileGroups[absoluteRef].locationPad);
|
|
@@ -301,7 +310,6 @@ function xmlEscape(s) {
|
|
|
301
310
|
});
|
|
302
311
|
}
|
|
303
312
|
function outputForGithubActions(problems, cwd) {
|
|
304
|
-
var _a, _b;
|
|
305
313
|
for (const problem of problems) {
|
|
306
314
|
for (const location of problem.location.map(codeframes_1.getLineColLocation)) {
|
|
307
315
|
let command;
|
|
@@ -322,8 +330,8 @@ function outputForGithubActions(problems, cwd) {
|
|
|
322
330
|
: path.relative(cwd, location.source.absoluteRef),
|
|
323
331
|
line: location.start.line,
|
|
324
332
|
col: location.start.col,
|
|
325
|
-
endLine:
|
|
326
|
-
endColumn:
|
|
333
|
+
endLine: location.end?.line,
|
|
334
|
+
endColumn: location.end?.col,
|
|
327
335
|
};
|
|
328
336
|
output_1.output.write(`::${command} ${formatProperties(properties)}::${escapeMessage(message)}\n`);
|
|
329
337
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export { Oas3_1Types } from './types/oas3_1';
|
|
|
3
3
|
export { ArazzoTypes } from './types/arazzo';
|
|
4
4
|
export { Oas3Types } from './types/oas3';
|
|
5
5
|
export { Oas2Types } from './types/oas2';
|
|
6
|
-
export { AsyncApi2Types } from './types/
|
|
6
|
+
export { AsyncApi2Types } from './types/asyncapi2';
|
|
7
|
+
export { AsyncApi3Types } from './types/asyncapi3';
|
|
7
8
|
export { ConfigTypes } from './types/redocly-yaml';
|
|
8
9
|
export type { Oas3Definition, Oas3_1Definition, Oas3Components, Oas3PathItem, Oas3Paths, Oas3ComponentName, Oas3Schema, Oas3_1Schema, Oas3Tag, Oas3_1Webhooks, Referenced, OasRef, } from './typings/openapi';
|
|
9
10
|
export type { Oas2Definition } from './typings/swagger';
|
package/lib/index.js
CHANGED
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
exports.bundleFromString = exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = void 0;
|
|
17
|
+
exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.getTypes = exports.detectSpec = exports.SpecVersion = exports.getMajorSpecVersion = exports.SpecMajorVersion = exports.isAbsoluteUrl = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.RedoclyClient = exports.createConfig = exports.CONFIG_FILE_NAMES = exports.findConfig = exports.getConfig = exports.loadConfig = exports.transformConfig = exports.getMergedConfig = exports.IGNORE_FILE = exports.StyleguideConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.AsyncApi3Types = exports.AsyncApi2Types = exports.Oas2Types = exports.Oas3Types = exports.ArazzoTypes = exports.Oas3_1Types = exports.pause = exports.getProxyAgent = exports.isTruthy = exports.doesYamlFileExist = exports.slash = exports.readFileFromUrl = void 0;
|
|
18
|
+
exports.bundleFromString = exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = void 0;
|
|
19
19
|
var utils_1 = require("./utils");
|
|
20
20
|
Object.defineProperty(exports, "readFileFromUrl", { enumerable: true, get: function () { return utils_1.readFileFromUrl; } });
|
|
21
21
|
Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return utils_1.slash; } });
|
|
@@ -31,8 +31,10 @@ var oas3_1 = require("./types/oas3");
|
|
|
31
31
|
Object.defineProperty(exports, "Oas3Types", { enumerable: true, get: function () { return oas3_1.Oas3Types; } });
|
|
32
32
|
var oas2_1 = require("./types/oas2");
|
|
33
33
|
Object.defineProperty(exports, "Oas2Types", { enumerable: true, get: function () { return oas2_1.Oas2Types; } });
|
|
34
|
-
var
|
|
35
|
-
Object.defineProperty(exports, "AsyncApi2Types", { enumerable: true, get: function () { return
|
|
34
|
+
var asyncapi2_1 = require("./types/asyncapi2");
|
|
35
|
+
Object.defineProperty(exports, "AsyncApi2Types", { enumerable: true, get: function () { return asyncapi2_1.AsyncApi2Types; } });
|
|
36
|
+
var asyncapi3_1 = require("./types/asyncapi3");
|
|
37
|
+
Object.defineProperty(exports, "AsyncApi3Types", { enumerable: true, get: function () { return asyncapi3_1.AsyncApi3Types; } });
|
|
36
38
|
var redocly_yaml_1 = require("./types/redocly-yaml");
|
|
37
39
|
Object.defineProperty(exports, "ConfigTypes", { enumerable: true, get: function () { return redocly_yaml_1.ConfigTypes; } });
|
|
38
40
|
var types_1 = require("./types");
|
package/lib/js-yaml/index.d.ts
CHANGED
package/lib/js-yaml/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = js_yaml_1.JSON_SCHEMA.extend({
|
|
|
9
9
|
implicit: [js_yaml_1.types.merge],
|
|
10
10
|
explicit: [js_yaml_1.types.binary, js_yaml_1.types.omap, js_yaml_1.types.pairs, js_yaml_1.types.set],
|
|
11
11
|
});
|
|
12
|
-
const parseYaml = (str, opts) => (0, js_yaml_1.load)(str,
|
|
12
|
+
const parseYaml = (str, opts) => (0, js_yaml_1.load)(str, { schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP, ...opts });
|
|
13
13
|
exports.parseYaml = parseYaml;
|
|
14
14
|
const stringifyYaml = (obj, opts) => (0, js_yaml_1.dump)(obj, opts);
|
|
15
15
|
exports.stringifyYaml = stringifyYaml;
|
package/lib/lint.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { BaseResolver } from './resolve';
|
|
2
|
-
import { StyleguideConfig, Config } from './config';
|
|
2
|
+
import type { StyleguideConfig, Config } from './config';
|
|
3
3
|
import type { Document, ResolvedRefMap } from './resolve';
|
|
4
4
|
import type { ProblemSeverity } from './walk';
|
|
5
5
|
import type { NodeType } from './types';
|
|
6
|
+
import type { CollectFn } from './utils';
|
|
6
7
|
export declare function lint(opts: {
|
|
7
8
|
ref: string;
|
|
8
9
|
config: Config;
|
|
9
10
|
externalRefResolver?: BaseResolver;
|
|
11
|
+
collectSpecData?: CollectFn;
|
|
10
12
|
}): Promise<import("./walk").NormalizedProblem[]>;
|
|
11
13
|
export declare function lintFromString(opts: {
|
|
12
14
|
source: string;
|
package/lib/lint.js
CHANGED
|
@@ -1,125 +1,118 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
3
|
+
exports.lint = lint;
|
|
4
|
+
exports.lintFromString = lintFromString;
|
|
5
|
+
exports.lintDocument = lintDocument;
|
|
6
|
+
exports.lintConfig = lintConfig;
|
|
7
|
+
const config_1 = require("@redocly/config");
|
|
13
8
|
const resolve_1 = require("./resolve");
|
|
14
9
|
const visitors_1 = require("./visitors");
|
|
15
10
|
const walk_1 = require("./walk");
|
|
16
|
-
const
|
|
11
|
+
const config_2 = require("./config");
|
|
17
12
|
const types_1 = require("./types");
|
|
18
13
|
const ajv_1 = require("./rules/ajv");
|
|
19
14
|
const oas_types_1 = require("./oas-types");
|
|
20
15
|
const redocly_yaml_1 = require("./types/redocly-yaml");
|
|
21
16
|
const spec_1 = require("./rules/common/spec");
|
|
22
17
|
const no_unresolved_refs_1 = require("./rules/no-unresolved-refs");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
async function lint(opts) {
|
|
19
|
+
const { ref, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
|
|
20
|
+
const document = (await externalRefResolver.resolveDocument(null, ref, true));
|
|
21
|
+
opts.collectSpecData?.(document.parsed);
|
|
22
|
+
return lintDocument({
|
|
23
|
+
document,
|
|
24
|
+
...opts,
|
|
25
|
+
externalRefResolver,
|
|
26
|
+
config: opts.config.styleguide,
|
|
29
27
|
});
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
async function lintFromString(opts) {
|
|
30
|
+
const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
|
|
31
|
+
const document = (0, resolve_1.makeDocumentFromString)(source, absoluteRef || '/');
|
|
32
|
+
return lintDocument({
|
|
33
|
+
document,
|
|
34
|
+
...opts,
|
|
35
|
+
externalRefResolver,
|
|
36
|
+
config: opts.config.styleguide,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (preprocessors.length > 0) {
|
|
61
|
-
// Make additional pass to resolve refs defined in preprocessors.
|
|
62
|
-
(0, walk_1.walkDocument)({
|
|
63
|
-
document,
|
|
64
|
-
rootType: types.Root,
|
|
65
|
-
normalizedVisitors: (0, visitors_1.normalizeVisitors)(preprocessors, types),
|
|
66
|
-
resolvedRefMap,
|
|
67
|
-
ctx,
|
|
68
|
-
});
|
|
69
|
-
resolvedRefMap = yield (0, resolve_1.resolveDocument)({
|
|
70
|
-
rootDocument: document,
|
|
71
|
-
rootType: types.Root,
|
|
72
|
-
externalRefResolver,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const normalizedVisitors = (0, visitors_1.normalizeVisitors)(regularRules, types);
|
|
39
|
+
async function lintDocument(opts) {
|
|
40
|
+
(0, ajv_1.releaseAjvInstance)(); // FIXME: preprocessors can modify nodes which are then cached to ajv-instance by absolute path
|
|
41
|
+
const { document, customTypes, externalRefResolver, config } = opts;
|
|
42
|
+
const specVersion = (0, oas_types_1.detectSpec)(document.parsed);
|
|
43
|
+
const specMajorVersion = (0, oas_types_1.getMajorSpecVersion)(specVersion);
|
|
44
|
+
const rules = config.getRulesForOasVersion(specMajorVersion);
|
|
45
|
+
const types = (0, types_1.normalizeTypes)(config.extendTypes(customTypes ?? (0, oas_types_1.getTypes)(specVersion), specVersion), config);
|
|
46
|
+
const ctx = {
|
|
47
|
+
problems: [],
|
|
48
|
+
oasVersion: specVersion,
|
|
49
|
+
visitorsData: {},
|
|
50
|
+
};
|
|
51
|
+
const preprocessors = (0, config_2.initRules)(rules, config, 'preprocessors', specVersion);
|
|
52
|
+
const regularRules = (0, config_2.initRules)(rules, config, 'rules', specVersion);
|
|
53
|
+
let resolvedRefMap = await (0, resolve_1.resolveDocument)({
|
|
54
|
+
rootDocument: document,
|
|
55
|
+
rootType: types.Root,
|
|
56
|
+
externalRefResolver,
|
|
57
|
+
});
|
|
58
|
+
if (preprocessors.length > 0) {
|
|
59
|
+
// Make additional pass to resolve refs defined in preprocessors.
|
|
76
60
|
(0, walk_1.walkDocument)({
|
|
77
61
|
document,
|
|
78
62
|
rootType: types.Root,
|
|
79
|
-
normalizedVisitors,
|
|
63
|
+
normalizedVisitors: (0, visitors_1.normalizeVisitors)(preprocessors, types),
|
|
80
64
|
resolvedRefMap,
|
|
81
65
|
ctx,
|
|
82
66
|
});
|
|
83
|
-
|
|
67
|
+
resolvedRefMap = await (0, resolve_1.resolveDocument)({
|
|
68
|
+
rootDocument: document,
|
|
69
|
+
rootType: types.Root,
|
|
70
|
+
externalRefResolver,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const normalizedVisitors = (0, visitors_1.normalizeVisitors)(regularRules, types);
|
|
74
|
+
(0, walk_1.walkDocument)({
|
|
75
|
+
document,
|
|
76
|
+
rootType: types.Root,
|
|
77
|
+
normalizedVisitors,
|
|
78
|
+
resolvedRefMap,
|
|
79
|
+
ctx,
|
|
84
80
|
});
|
|
81
|
+
return ctx.problems.map((problem) => config.addProblemToIgnore(problem));
|
|
85
82
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
(yield (0, resolve_1.resolveDocument)({
|
|
111
|
-
rootDocument: document,
|
|
112
|
-
rootType: types.ConfigRoot,
|
|
113
|
-
externalRefResolver,
|
|
114
|
-
}));
|
|
115
|
-
(0, walk_1.walkDocument)({
|
|
116
|
-
document,
|
|
83
|
+
async function lintConfig(opts) {
|
|
84
|
+
const { document, severity, externalRefResolver = new resolve_1.BaseResolver(), config } = opts;
|
|
85
|
+
const ctx = {
|
|
86
|
+
problems: [],
|
|
87
|
+
oasVersion: oas_types_1.SpecVersion.OAS3_0,
|
|
88
|
+
visitorsData: {},
|
|
89
|
+
};
|
|
90
|
+
const types = (0, types_1.normalizeTypes)(opts.externalConfigTypes || (0, redocly_yaml_1.createConfigTypes)(config_1.rootRedoclyConfigSchema, config), { doNotResolveExamples: config.styleguide.doNotResolveExamples });
|
|
91
|
+
const rules = [
|
|
92
|
+
{
|
|
93
|
+
severity: severity || 'error',
|
|
94
|
+
ruleId: 'configuration spec',
|
|
95
|
+
visitor: (0, spec_1.Spec)({ severity: 'error' }),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
severity: severity || 'error',
|
|
99
|
+
ruleId: 'configuration no-unresolved-refs',
|
|
100
|
+
visitor: (0, no_unresolved_refs_1.NoUnresolvedRefs)({ severity: 'error' }),
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
const normalizedVisitors = (0, visitors_1.normalizeVisitors)(rules, types);
|
|
104
|
+
const resolvedRefMap = opts.resolvedRefMap ||
|
|
105
|
+
(await (0, resolve_1.resolveDocument)({
|
|
106
|
+
rootDocument: document,
|
|
117
107
|
rootType: types.ConfigRoot,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
externalRefResolver,
|
|
109
|
+
}));
|
|
110
|
+
(0, walk_1.walkDocument)({
|
|
111
|
+
document,
|
|
112
|
+
rootType: types.ConfigRoot,
|
|
113
|
+
normalizedVisitors,
|
|
114
|
+
resolvedRefMap,
|
|
115
|
+
ctx,
|
|
123
116
|
});
|
|
117
|
+
return ctx.problems;
|
|
124
118
|
}
|
|
125
|
-
exports.lintConfig = lintConfig;
|
package/lib/logger.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logger = exports.colorize = exports.colorOptions = void 0;
|
|
4
4
|
const colorette = require("colorette");
|
|
5
|
-
var colorette_1 = require("colorette");
|
|
6
|
-
Object.defineProperty(exports, "colorOptions", { enumerable: true, get: function () { return colorette_1.options; } });
|
|
7
5
|
const env_1 = require("./env");
|
|
8
6
|
const utils_1 = require("./utils");
|
|
7
|
+
var colorette_1 = require("colorette");
|
|
8
|
+
Object.defineProperty(exports, "colorOptions", { enumerable: true, get: function () { return colorette_1.options; } });
|
|
9
9
|
exports.colorize = new Proxy(colorette, {
|
|
10
10
|
get(target, prop) {
|
|
11
11
|
if (env_1.isBrowser) {
|
package/lib/oas-types.d.ts
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export type RuleSet<T> = Record<string, T>;
|
|
1
|
+
import type { BuiltInAsync2RuleId, BuiltInAsync3RuleId, BuiltInCommonOASRuleId, BuiltInArazzoRuleId, BuiltInOAS2RuleId, BuiltInOAS3RuleId } from './types/redocly-yaml';
|
|
2
|
+
import type { Oas3Rule, Oas3Preprocessor, Oas2Rule, Oas2Preprocessor, Async2Preprocessor, Async2Rule, Async3Preprocessor, Async3Rule, ArazzoPreprocessor, ArazzoRule } from './visitors';
|
|
4
3
|
export declare enum SpecVersion {
|
|
5
4
|
OAS2 = "oas2",
|
|
6
5
|
OAS3_0 = "oas3_0",
|
|
7
6
|
OAS3_1 = "oas3_1",
|
|
8
7
|
Async2 = "async2",
|
|
8
|
+
Async3 = "async3",
|
|
9
9
|
Arazzo = "arazzo"
|
|
10
10
|
}
|
|
11
11
|
export declare enum SpecMajorVersion {
|
|
12
12
|
OAS2 = "oas2",
|
|
13
13
|
OAS3 = "oas3",
|
|
14
14
|
Async2 = "async2",
|
|
15
|
+
Async3 = "async3",
|
|
15
16
|
Arazzo = "arazzo"
|
|
16
17
|
}
|
|
17
18
|
export type RuleMap<Key extends string, RuleConfig, T> = Record<T extends 'built-in' ? Key : string, RuleConfig>;
|
|
18
19
|
export type Oas3RuleSet<T = undefined> = RuleMap<BuiltInCommonOASRuleId | BuiltInOAS3RuleId | 'assertions', Oas3Rule, T>;
|
|
19
20
|
export type Oas2RuleSet<T = undefined> = RuleMap<BuiltInCommonOASRuleId | BuiltInOAS2RuleId | 'assertions', Oas2Rule, T>;
|
|
20
21
|
export type Async2RuleSet<T = undefined> = RuleMap<BuiltInAsync2RuleId | 'assertions', Async2Rule, T>;
|
|
22
|
+
export type Async3RuleSet<T = undefined> = RuleMap<BuiltInAsync3RuleId | 'assertions', Async3Rule, T>;
|
|
21
23
|
export type ArazzoRuleSet<T = undefined> = RuleMap<BuiltInArazzoRuleId | 'assertions', ArazzoRule, T>;
|
|
22
24
|
export type Oas3PreprocessorsSet = Record<string, Oas3Preprocessor>;
|
|
23
25
|
export type Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>;
|
|
24
26
|
export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>;
|
|
27
|
+
export type Async3PreprocessorsSet = Record<string, Async3Preprocessor>;
|
|
25
28
|
export type ArazzoPreprocessorsSet = Record<string, ArazzoPreprocessor>;
|
|
26
29
|
export type Oas3DecoratorsSet = Record<string, Oas3Preprocessor>;
|
|
27
30
|
export type Oas2DecoratorsSet = Record<string, Oas2Preprocessor>;
|
|
28
31
|
export type Async2DecoratorsSet = Record<string, Async2Preprocessor>;
|
|
32
|
+
export type Async3DecoratorsSet = Record<string, Async3Preprocessor>;
|
|
29
33
|
export type ArazzoDecoratorsSet = Record<string, ArazzoPreprocessor>;
|
|
30
|
-
export declare function detectSpec(root:
|
|
34
|
+
export declare function detectSpec(root: unknown): SpecVersion;
|
|
31
35
|
export declare function getMajorSpecVersion(version: SpecVersion): SpecMajorVersion;
|
|
32
|
-
export declare function getTypes(spec: SpecVersion): Record<string, import("./types").NodeType> | Record<"Root" | "Tag" | "
|
|
36
|
+
export declare function getTypes(spec: SpecVersion): Record<string, import("./types").NodeType> | Record<"Root" | "Tag" | "TagList" | "ExternalDocs" | "SecurityRequirement" | "SecurityRequirementList" | "Info" | "Contact" | "License" | "Paths" | "PathItem" | "Parameter" | "ParameterList" | "ParameterItems" | "Operation" | "Example" | "ExamplesMap" | "Examples" | "Header" | "Responses" | "Response" | "Schema" | "Xml" | "SchemaProperties" | "NamedSchemas" | "NamedResponses" | "NamedParameters" | "NamedSecuritySchemes" | "SecurityScheme" | "TagGroup" | "TagGroups" | "EnumDescriptions" | "Logo" | "XCodeSample" | "XCodeSampleList" | "XServer" | "XServerList", import("./types").NodeType> | Record<"Root" | "Tag" | "TagList" | "ExternalDocs" | "SecurityRequirement" | "SecurityRequirementList" | "Info" | "Contact" | "License" | "Paths" | "PathItem" | "Parameter" | "ParameterList" | "Operation" | "Example" | "ExamplesMap" | "Header" | "Responses" | "Response" | "Schema" | "Xml" | "SchemaProperties" | "NamedSchemas" | "NamedResponses" | "NamedParameters" | "NamedSecuritySchemes" | "SecurityScheme" | "TagGroup" | "TagGroups" | "EnumDescriptions" | "Logo" | "XCodeSample" | "XCodeSampleList" | "Server" | "ServerList" | "ServerVariable" | "ServerVariablesMap" | "Callback" | "CallbacksMap" | "RequestBody" | "MediaTypesMap" | "MediaType" | "Encoding" | "EncodingMap" | "HeadersMap" | "Link" | "LinksMap" | "DiscriminatorMapping" | "Discriminator" | "Components" | "NamedExamples" | "NamedRequestBodies" | "NamedHeaders" | "NamedLinks" | "NamedCallbacks" | "ImplicitFlow" | "PasswordFlow" | "ClientCredentials" | "AuthorizationCode" | "OAuth2Flows" | "XUsePkce" | "WebhooksMap", import("./types").NodeType> | Record<"Root" | "Info" | "License" | "Operation" | "Schema" | "SchemaProperties" | "SecurityScheme" | "Components" | "PatternProperties" | "NamedPathItems" | "DependentRequired", import("./types").NodeType>;
|
package/lib/oas-types.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SpecMajorVersion = exports.SpecVersion = void 0;
|
|
4
|
+
exports.detectSpec = detectSpec;
|
|
5
|
+
exports.getMajorSpecVersion = getMajorSpecVersion;
|
|
6
|
+
exports.getTypes = getTypes;
|
|
4
7
|
const oas2_1 = require("./types/oas2");
|
|
5
8
|
const oas3_1 = require("./types/oas3");
|
|
6
9
|
const oas3_1_1 = require("./types/oas3_1");
|
|
7
|
-
const
|
|
10
|
+
const asyncapi2_1 = require("./types/asyncapi2");
|
|
11
|
+
const asyncapi3_1 = require("./types/asyncapi3");
|
|
8
12
|
const arazzo_1 = require("./types/arazzo");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
9
14
|
var SpecVersion;
|
|
10
15
|
(function (SpecVersion) {
|
|
11
16
|
SpecVersion["OAS2"] = "oas2";
|
|
12
17
|
SpecVersion["OAS3_0"] = "oas3_0";
|
|
13
18
|
SpecVersion["OAS3_1"] = "oas3_1";
|
|
14
19
|
SpecVersion["Async2"] = "async2";
|
|
20
|
+
SpecVersion["Async3"] = "async3";
|
|
15
21
|
SpecVersion["Arazzo"] = "arazzo";
|
|
16
22
|
})(SpecVersion || (exports.SpecVersion = SpecVersion = {}));
|
|
17
23
|
var SpecMajorVersion;
|
|
@@ -19,47 +25,50 @@ var SpecMajorVersion;
|
|
|
19
25
|
SpecMajorVersion["OAS2"] = "oas2";
|
|
20
26
|
SpecMajorVersion["OAS3"] = "oas3";
|
|
21
27
|
SpecMajorVersion["Async2"] = "async2";
|
|
28
|
+
SpecMajorVersion["Async3"] = "async3";
|
|
22
29
|
SpecMajorVersion["Arazzo"] = "arazzo";
|
|
23
30
|
})(SpecMajorVersion || (exports.SpecMajorVersion = SpecMajorVersion = {}));
|
|
24
31
|
const typesMap = {
|
|
25
32
|
[SpecVersion.OAS2]: oas2_1.Oas2Types,
|
|
26
33
|
[SpecVersion.OAS3_0]: oas3_1.Oas3Types,
|
|
27
34
|
[SpecVersion.OAS3_1]: oas3_1_1.Oas3_1Types,
|
|
28
|
-
[SpecVersion.Async2]:
|
|
35
|
+
[SpecVersion.Async2]: asyncapi2_1.AsyncApi2Types,
|
|
36
|
+
[SpecVersion.Async3]: asyncapi3_1.AsyncApi3Types,
|
|
29
37
|
[SpecVersion.Arazzo]: arazzo_1.ArazzoTypes,
|
|
30
38
|
};
|
|
31
39
|
function detectSpec(root) {
|
|
32
|
-
if (
|
|
40
|
+
if (!(0, utils_1.isPlainObject)(root)) {
|
|
33
41
|
throw new Error(`Document must be JSON object, got ${typeof root}`);
|
|
34
42
|
}
|
|
35
43
|
if (root.openapi && typeof root.openapi !== 'string') {
|
|
36
44
|
throw new Error(`Invalid OpenAPI version: should be a string but got "${typeof root.openapi}"`);
|
|
37
45
|
}
|
|
38
|
-
if (root.openapi && root.openapi.startsWith('3.0')) {
|
|
46
|
+
if (typeof root.openapi === 'string' && root.openapi.startsWith('3.0')) {
|
|
39
47
|
return SpecVersion.OAS3_0;
|
|
40
48
|
}
|
|
41
|
-
if (root.openapi && root.openapi.startsWith('3.1')) {
|
|
49
|
+
if (typeof root.openapi === 'string' && root.openapi.startsWith('3.1')) {
|
|
42
50
|
return SpecVersion.OAS3_1;
|
|
43
51
|
}
|
|
44
52
|
if (root.swagger && root.swagger === '2.0') {
|
|
45
53
|
return SpecVersion.OAS2;
|
|
46
54
|
}
|
|
47
|
-
// if not detected yet
|
|
48
55
|
if (root.openapi || root.swagger) {
|
|
49
56
|
throw new Error(`Unsupported OpenAPI version: ${root.openapi || root.swagger}`);
|
|
50
57
|
}
|
|
51
|
-
if (root.asyncapi && root.asyncapi.startsWith('2.')) {
|
|
58
|
+
if (typeof root.asyncapi === 'string' && root.asyncapi.startsWith('2.')) {
|
|
52
59
|
return SpecVersion.Async2;
|
|
53
60
|
}
|
|
61
|
+
if (typeof root.asyncapi === 'string' && root.asyncapi.startsWith('3.')) {
|
|
62
|
+
return SpecVersion.Async3;
|
|
63
|
+
}
|
|
54
64
|
if (root.asyncapi) {
|
|
55
65
|
throw new Error(`Unsupported AsyncAPI version: ${root.asyncapi}`);
|
|
56
66
|
}
|
|
57
|
-
if (root.arazzo && root.arazzo.startsWith('1.')) {
|
|
67
|
+
if (typeof root.arazzo === 'string' && root.arazzo.startsWith('1.')) {
|
|
58
68
|
return SpecVersion.Arazzo;
|
|
59
69
|
}
|
|
60
70
|
throw new Error(`Unsupported specification`);
|
|
61
71
|
}
|
|
62
|
-
exports.detectSpec = detectSpec;
|
|
63
72
|
function getMajorSpecVersion(version) {
|
|
64
73
|
if (version === SpecVersion.OAS2) {
|
|
65
74
|
return SpecMajorVersion.OAS2;
|
|
@@ -67,6 +76,9 @@ function getMajorSpecVersion(version) {
|
|
|
67
76
|
else if (version === SpecVersion.Async2) {
|
|
68
77
|
return SpecMajorVersion.Async2;
|
|
69
78
|
}
|
|
79
|
+
else if (version === SpecVersion.Async3) {
|
|
80
|
+
return SpecMajorVersion.Async3;
|
|
81
|
+
}
|
|
70
82
|
else if (version === SpecVersion.Arazzo) {
|
|
71
83
|
return SpecMajorVersion.Arazzo;
|
|
72
84
|
}
|
|
@@ -74,8 +86,6 @@ function getMajorSpecVersion(version) {
|
|
|
74
86
|
return SpecMajorVersion.OAS3;
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
|
-
exports.getMajorSpecVersion = getMajorSpecVersion;
|
|
78
89
|
function getTypes(spec) {
|
|
79
90
|
return typesMap[spec];
|
|
80
91
|
}
|
|
81
|
-
exports.getTypes = getTypes;
|
package/lib/redocly/domains.d.ts
CHANGED
package/lib/redocly/domains.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AVAILABLE_REGIONS = exports.DOMAINS = exports.DEFAULT_REGION = void 0;
|
|
4
|
+
exports.getDomains = getDomains;
|
|
5
|
+
exports.setRedoclyDomain = setRedoclyDomain;
|
|
6
|
+
exports.getRedoclyDomain = getRedoclyDomain;
|
|
7
|
+
exports.isRedoclyRegistryURL = isRedoclyRegistryURL;
|
|
4
8
|
let redoclyDomain = 'redocly.com';
|
|
5
9
|
exports.DEFAULT_REGION = 'us';
|
|
6
10
|
exports.DOMAINS = getDomains();
|
|
@@ -12,7 +16,7 @@ function getDomains() {
|
|
|
12
16
|
};
|
|
13
17
|
// FIXME: temporary fix for our lab environments
|
|
14
18
|
const domain = redoclyDomain;
|
|
15
|
-
if (domain
|
|
19
|
+
if (domain?.endsWith('.redocly.host')) {
|
|
16
20
|
domains[domain.split('.')[0]] = domain;
|
|
17
21
|
}
|
|
18
22
|
if (domain === 'redoc.online') {
|
|
@@ -20,15 +24,12 @@ function getDomains() {
|
|
|
20
24
|
}
|
|
21
25
|
return domains;
|
|
22
26
|
}
|
|
23
|
-
exports.getDomains = getDomains;
|
|
24
27
|
function setRedoclyDomain(domain) {
|
|
25
28
|
redoclyDomain = domain;
|
|
26
29
|
}
|
|
27
|
-
exports.setRedoclyDomain = setRedoclyDomain;
|
|
28
30
|
function getRedoclyDomain() {
|
|
29
31
|
return redoclyDomain;
|
|
30
32
|
}
|
|
31
|
-
exports.getRedoclyDomain = getRedoclyDomain;
|
|
32
33
|
function isRedoclyRegistryURL(link) {
|
|
33
34
|
const domain = getRedoclyDomain() || exports.DOMAINS[exports.DEFAULT_REGION];
|
|
34
35
|
const legacyDomain = domain === 'redocly.com' ? 'redoc.ly' : domain;
|
|
@@ -38,4 +39,3 @@ function isRedoclyRegistryURL(link) {
|
|
|
38
39
|
}
|
|
39
40
|
return true;
|
|
40
41
|
}
|
|
41
|
-
exports.isRedoclyRegistryURL = isRedoclyRegistryURL;
|
package/lib/redocly/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RegistryApi } from './registry-api';
|
|
2
|
-
import { RegionalToken, RegionalTokenWithValidity } from './redocly-client-types';
|
|
2
|
+
import type { RegionalToken, RegionalTokenWithValidity } from './redocly-client-types';
|
|
3
3
|
import type { AccessTokens, Region } from '../config/types';
|
|
4
4
|
export declare const TOKEN_FILENAME = ".redocly-config.json";
|
|
5
5
|
export declare class RedoclyClient {
|