@redocly/openapi-core 1.0.0-beta.98 → 1.0.0-rc.1
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 +6 -6
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +0 -1
- package/lib/benchmark/benches/recommended-oas3.bench.js +1 -1
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +1 -1
- package/lib/benchmark/utils.d.ts +2 -2
- package/lib/benchmark/utils.js +2 -2
- package/lib/bundle.d.ts +12 -15
- package/lib/bundle.js +38 -15
- package/lib/config/all.d.ts +2 -2
- package/lib/config/all.js +17 -6
- package/lib/config/builtIn.d.ts +2 -2
- package/lib/config/builtIn.js +2 -2
- package/lib/config/config-resolvers.d.ts +5 -5
- package/lib/config/config-resolvers.js +121 -66
- package/lib/config/config.d.ts +12 -18
- package/lib/config/config.js +42 -26
- package/lib/config/load.d.ts +16 -3
- package/lib/config/load.js +36 -14
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/minimal.js +10 -6
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.js +10 -6
- package/lib/config/rules.d.ts +7 -4
- package/lib/config/rules.js +5 -4
- package/lib/config/types.d.ts +72 -23
- package/lib/config/types.js +13 -0
- package/lib/config/utils.d.ts +6 -5
- package/lib/config/utils.js +110 -32
- package/lib/decorators/common/filters/filter-helper.d.ts +3 -0
- package/lib/decorators/common/filters/filter-helper.js +67 -0
- package/lib/decorators/common/filters/filter-in.d.ts +2 -0
- package/lib/decorators/common/filters/filter-in.js +17 -0
- package/lib/decorators/common/filters/filter-out.d.ts +2 -0
- package/lib/decorators/common/filters/filter-out.js +17 -0
- package/lib/decorators/common/info-override.d.ts +2 -0
- package/lib/decorators/common/info-override.js +28 -0
- package/lib/decorators/common/media-type-examples-override.d.ts +2 -0
- package/lib/decorators/common/media-type-examples-override.js +53 -0
- package/lib/decorators/common/registry-dependencies.js +2 -2
- package/lib/decorators/common/remove-x-internal.js +2 -2
- package/lib/decorators/oas2/index.d.ts +3 -0
- package/lib/decorators/oas2/index.js +7 -1
- package/lib/decorators/oas3/index.d.ts +4 -0
- package/lib/decorators/oas3/index.js +9 -1
- package/lib/env.d.ts +3 -0
- package/lib/env.js +8 -0
- package/lib/format/codeframes.js +16 -10
- package/lib/format/format.d.ts +1 -1
- package/lib/format/format.js +64 -32
- package/lib/index.d.ts +6 -6
- package/lib/index.js +7 -2
- package/lib/js-yaml/index.js +2 -6
- package/lib/lint.d.ts +4 -2
- package/lib/lint.js +36 -11
- package/lib/logger.d.ts +10 -0
- package/lib/logger.js +31 -0
- package/lib/output.d.ts +3 -0
- package/lib/output.js +9 -0
- package/lib/redocly/index.js +10 -9
- package/lib/redocly/registry-api-types.d.ts +28 -28
- package/lib/redocly/registry-api.d.ts +3 -3
- package/lib/redocly/registry-api.js +10 -2
- package/lib/ref-utils.d.ts +1 -0
- package/lib/ref-utils.js +8 -2
- package/lib/resolve.d.ts +1 -1
- package/lib/resolve.js +33 -3
- package/lib/rules/ajv.d.ts +2 -2
- package/lib/rules/ajv.js +12 -12
- package/lib/rules/common/assertions/asserts.d.ts +29 -4
- package/lib/rules/common/assertions/asserts.js +227 -97
- package/lib/rules/common/assertions/index.d.ts +27 -2
- package/lib/rules/common/assertions/index.js +9 -37
- package/lib/rules/common/assertions/utils.d.ts +16 -8
- package/lib/rules/common/assertions/utils.js +160 -76
- package/lib/rules/common/info-license-url.d.ts +1 -1
- package/lib/rules/common/info-license-url.js +5 -10
- package/lib/rules/common/info-license.d.ts +2 -0
- package/lib/rules/common/info-license.js +17 -0
- package/lib/rules/common/no-ambiguous-paths.js +1 -1
- package/lib/rules/common/no-enum-type-mismatch.js +1 -3
- package/lib/rules/common/no-identical-paths.js +4 -4
- package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
- package/lib/rules/common/no-invalid-schema-examples.js +3 -3
- package/lib/rules/common/operation-2xx-response.js +15 -9
- package/lib/rules/common/operation-4xx-response.js +15 -9
- package/lib/rules/common/operation-operationId.js +2 -2
- package/lib/rules/common/operation-tag-defined.js +1 -1
- package/lib/rules/common/path-not-include-query.js +2 -2
- package/lib/rules/common/path-params-defined.js +7 -2
- package/lib/rules/common/paths-kebab-case.js +4 -1
- package/lib/rules/common/required-string-property-missing-min-length.d.ts +2 -0
- package/lib/rules/common/required-string-property-missing-min-length.js +37 -0
- package/lib/rules/common/response-contains-header.d.ts +2 -0
- package/lib/rules/common/response-contains-header.js +29 -0
- package/lib/rules/common/scalar-property-missing-example.d.ts +2 -0
- package/lib/rules/common/scalar-property-missing-example.js +42 -0
- package/lib/rules/common/security-defined.d.ts +2 -0
- package/lib/rules/common/{operation-security-defined.js → security-defined.js} +25 -6
- package/lib/rules/common/spec-strict-refs.d.ts +2 -0
- package/lib/rules/common/spec-strict-refs.js +30 -0
- package/lib/rules/common/spec.js +41 -18
- package/lib/rules/common/tags-alphabetical.js +1 -1
- package/lib/rules/oas2/index.d.ts +6 -2
- package/lib/rules/oas2/index.js +16 -8
- package/lib/rules/oas2/remove-unused-components.js +6 -6
- package/lib/rules/oas2/request-mime-type.d.ts +1 -1
- package/lib/rules/oas2/request-mime-type.js +1 -1
- 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 +1 -1
- package/lib/rules/oas2/response-mime-type.js +1 -1
- package/lib/rules/oas3/component-name-unique.d.ts +2 -0
- package/lib/rules/oas3/component-name-unique.js +124 -0
- package/lib/rules/oas3/index.js +24 -10
- package/lib/rules/oas3/no-empty-servers.js +2 -2
- package/lib/rules/oas3/no-invalid-media-type-examples.js +2 -2
- package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +2 -0
- package/lib/rules/oas3/{no-servers-empty-enum.js → no-server-variables-empty-enum.js} +5 -5
- package/lib/rules/oas3/no-unused-components.js +2 -2
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts +5 -0
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +36 -0
- package/lib/rules/oas3/remove-unused-components.js +6 -6
- package/lib/rules/oas3/request-mime-type.d.ts +1 -1
- package/lib/rules/oas3/request-mime-type.js +1 -1
- 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 +1 -1
- package/lib/rules/oas3/response-mime-type.js +1 -1
- package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +2 -0
- package/lib/rules/oas3/spec-components-invalid-map-name.js +62 -0
- package/lib/rules/other/stats.d.ts +2 -2
- package/lib/rules/other/stats.js +45 -16
- package/lib/rules/utils.d.ts +5 -2
- package/lib/rules/utils.js +54 -6
- package/lib/types/config-external-schemas.d.ts +2193 -0
- package/lib/types/config-external-schemas.js +805 -0
- package/lib/types/index.d.ts +3 -2
- package/lib/types/index.js +9 -1
- package/lib/types/oas2.js +91 -15
- package/lib/types/oas3.js +139 -49
- package/lib/types/oas3_1.js +32 -26
- package/lib/types/redocly-yaml.js +414 -58
- package/lib/typings/openapi.d.ts +3 -2
- package/lib/utils.d.ts +15 -3
- package/lib/utils.js +73 -7
- package/lib/visitors.d.ts +20 -16
- package/lib/visitors.js +28 -3
- package/lib/walk.d.ts +11 -19
- package/lib/walk.js +74 -53
- package/package.json +5 -6
- package/__tests__/__snapshots__/bundle.test.ts.snap +0 -229
- package/__tests__/bundle.test.ts +0 -132
- package/__tests__/codeframes.test.ts +0 -531
- package/__tests__/fixtures/extension.js +0 -24
- package/__tests__/fixtures/refs/definitions.yaml +0 -3
- package/__tests__/fixtures/refs/examples.yaml +0 -8
- package/__tests__/fixtures/refs/external-request-body.yaml +0 -13
- package/__tests__/fixtures/refs/externalref.yaml +0 -35
- package/__tests__/fixtures/refs/hosted.yaml +0 -35
- package/__tests__/fixtures/refs/openapi-with-external-refs-conflicting-names.yaml +0 -21
- package/__tests__/fixtures/refs/openapi-with-external-refs.yaml +0 -33
- package/__tests__/fixtures/refs/param-b.yaml +0 -1
- package/__tests__/fixtures/refs/param-c.yaml +0 -1
- package/__tests__/fixtures/refs/rename.yaml +0 -1
- package/__tests__/fixtures/refs/requestBody.yaml +0 -9
- package/__tests__/fixtures/refs/schema-a.yaml +0 -1
- package/__tests__/fixtures/refs/simple.yaml +0 -1
- package/__tests__/fixtures/refs/vendor.schema.yaml +0 -20
- package/__tests__/fixtures/resolve/External.yaml +0 -10
- package/__tests__/fixtures/resolve/External2.yaml +0 -4
- package/__tests__/fixtures/resolve/description.md +0 -3
- package/__tests__/fixtures/resolve/externalInfo.yaml +0 -4
- package/__tests__/fixtures/resolve/externalLicense.yaml +0 -1
- package/__tests__/fixtures/resolve/openapi-with-back.yaml +0 -13
- package/__tests__/fixtures/resolve/openapi-with-md-description.yaml +0 -5
- package/__tests__/fixtures/resolve/openapi.yaml +0 -28
- package/__tests__/fixtures/resolve/schemas/type-a.yaml +0 -10
- package/__tests__/fixtures/resolve/schemas/type-b.yaml +0 -6
- package/__tests__/fixtures/resolve/transitive/a.yaml +0 -1
- package/__tests__/fixtures/resolve/transitive/components.yaml +0 -5
- package/__tests__/fixtures/resolve/transitive/schemas.yaml +0 -3
- package/__tests__/lint.test.ts +0 -17
- package/__tests__/login.test.ts +0 -17
- package/__tests__/normalizeVisitors.test.ts +0 -151
- package/__tests__/ref-utils.test.ts +0 -120
- package/__tests__/resolve-http.test.ts +0 -77
- package/__tests__/resolve.test.ts +0 -405
- package/__tests__/utils.ts +0 -86
- package/__tests__/walk.test.ts +0 -1485
- package/lib/rules/common/info-description.d.ts +0 -2
- package/lib/rules/common/info-description.js +0 -12
- package/lib/rules/common/license-url.d.ts +0 -2
- package/lib/rules/common/license-url.js +0 -12
- package/lib/rules/common/operation-security-defined.d.ts +0 -2
- package/lib/rules/oas3/no-servers-empty-enum.d.ts +0 -2
- package/src/__tests__/js-yaml.test.ts +0 -71
- package/src/__tests__/lint.test.ts +0 -182
- package/src/__tests__/utils.test.ts +0 -74
- package/src/benchmark/benches/lint-with-many-rules.bench.ts +0 -35
- package/src/benchmark/benches/lint-with-nested-rule.bench.ts +0 -39
- package/src/benchmark/benches/lint-with-no-rules.bench.ts +0 -20
- package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +0 -36
- package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +0 -32
- package/src/benchmark/benches/rebilly.yaml +0 -32267
- package/src/benchmark/benches/recommended-oas3.bench.ts +0 -22
- package/src/benchmark/benches/resolve-with-no-external.bench.ts +0 -23
- package/src/benchmark/benchmark.js +0 -307
- package/src/benchmark/colors.js +0 -29
- package/src/benchmark/fork.js +0 -83
- package/src/benchmark/utils.ts +0 -36
- package/src/bundle.ts +0 -371
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +0 -157
- package/src/config/__tests__/config-resolvers.test.ts +0 -429
- package/src/config/__tests__/config.test.ts +0 -244
- package/src/config/__tests__/fixtures/plugin-config.yaml +0 -3
- package/src/config/__tests__/fixtures/plugin.js +0 -56
- package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +0 -12
- package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +0 -67
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-circular.yaml +0 -8
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +0 -19
- package/src/config/__tests__/fixtures/resolve-config/local-config.yaml +0 -10
- package/src/config/__tests__/fixtures/resolve-config/plugin.js +0 -66
- package/src/config/__tests__/fixtures/resolve-remote-configs/nested-remote-config.yaml +0 -4
- package/src/config/__tests__/fixtures/resolve-remote-configs/remote-config.yaml +0 -5
- package/src/config/__tests__/load.test.ts +0 -83
- package/src/config/__tests__/resolve-plugins.test.ts +0 -27
- package/src/config/all.ts +0 -65
- package/src/config/builtIn.ts +0 -37
- package/src/config/config-resolvers.ts +0 -359
- package/src/config/config.ts +0 -312
- package/src/config/index.ts +0 -7
- package/src/config/load.ts +0 -84
- package/src/config/minimal.ts +0 -58
- package/src/config/recommended.ts +0 -58
- package/src/config/rules.ts +0 -46
- package/src/config/types.ts +0 -168
- package/src/config/utils.ts +0 -208
- package/src/decorators/__tests__/remove-x-internal.test.ts +0 -316
- package/src/decorators/common/info-description-override.ts +0 -24
- package/src/decorators/common/operation-description-override.ts +0 -30
- package/src/decorators/common/registry-dependencies.ts +0 -25
- package/src/decorators/common/remove-x-internal.ts +0 -59
- package/src/decorators/common/tag-description-override.ts +0 -25
- package/src/decorators/oas2/index.ts +0 -14
- package/src/decorators/oas3/index.ts +0 -14
- package/src/format/codeframes.ts +0 -210
- package/src/format/format.ts +0 -339
- package/src/index.ts +0 -68
- package/src/js-yaml/index.ts +0 -18
- package/src/lint.ts +0 -125
- package/src/oas-types.ts +0 -62
- package/src/redocly/__tests__/redocly-client.test.ts +0 -140
- package/src/redocly/index.ts +0 -182
- package/src/redocly/redocly-client-types.ts +0 -10
- package/src/redocly/registry-api-types.ts +0 -32
- package/src/redocly/registry-api.ts +0 -134
- package/src/ref-utils.ts +0 -79
- package/src/resolve.ts +0 -378
- package/src/rules/__tests__/fixtures/invalid-yaml.yaml +0 -1
- package/src/rules/__tests__/fixtures/ref.yaml +0 -1
- package/src/rules/__tests__/no-unresolved-refs.test.ts +0 -168
- package/src/rules/ajv.ts +0 -103
- package/src/rules/common/__tests__/info-description.test.ts +0 -102
- package/src/rules/common/__tests__/info-license.test.ts +0 -62
- package/src/rules/common/__tests__/license-url.test.ts +0 -63
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +0 -96
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +0 -209
- package/src/rules/common/__tests__/no-identical-paths.test.ts +0 -58
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +0 -85
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +0 -91
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +0 -107
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +0 -76
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +0 -45
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +0 -167
- package/src/rules/common/__tests__/operation-security-defined.test.ts +0 -69
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +0 -72
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +0 -95
- package/src/rules/common/__tests__/path-not-include-query.test.ts +0 -64
- package/src/rules/common/__tests__/path-params-defined.test.ts +0 -133
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +0 -108
- package/src/rules/common/__tests__/spec.test.ts +0 -62
- package/src/rules/common/__tests__/tag-description.test.ts +0 -65
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +0 -64
- package/src/rules/common/assertions/__tests__/asserts.test.ts +0 -231
- package/src/rules/common/assertions/__tests__/index.test.ts +0 -65
- package/src/rules/common/assertions/__tests__/utils.test.ts +0 -89
- package/src/rules/common/assertions/asserts.ts +0 -137
- package/src/rules/common/assertions/index.ts +0 -75
- package/src/rules/common/assertions/utils.ts +0 -167
- package/src/rules/common/info-contact.ts +0 -15
- package/src/rules/common/info-description.ts +0 -10
- package/src/rules/common/info-license-url.ts +0 -15
- package/src/rules/common/license-url.ts +0 -10
- package/src/rules/common/no-ambiguous-paths.ts +0 -50
- package/src/rules/common/no-enum-type-mismatch.ts +0 -49
- package/src/rules/common/no-http-verbs-in-paths.ts +0 -36
- package/src/rules/common/no-identical-paths.ts +0 -24
- package/src/rules/common/no-invalid-parameter-examples.ts +0 -36
- package/src/rules/common/no-invalid-schema-examples.ts +0 -27
- package/src/rules/common/no-path-trailing-slash.ts +0 -15
- package/src/rules/common/operation-2xx-response.ts +0 -16
- package/src/rules/common/operation-4xx-response.ts +0 -17
- package/src/rules/common/operation-description.ts +0 -13
- package/src/rules/common/operation-operationId-unique.ts +0 -21
- package/src/rules/common/operation-operationId-url-safe.ts +0 -19
- package/src/rules/common/operation-operationId.ts +0 -17
- package/src/rules/common/operation-parameters-unique.ts +0 -48
- package/src/rules/common/operation-security-defined.ts +0 -45
- package/src/rules/common/operation-singular-tag.ts +0 -17
- package/src/rules/common/operation-summary.ts +0 -13
- package/src/rules/common/operation-tag-defined.ts +0 -26
- package/src/rules/common/parameter-description.ts +0 -22
- package/src/rules/common/path-declaration-must-exist.ts +0 -15
- package/src/rules/common/path-excludes-patterns.ts +0 -23
- package/src/rules/common/path-http-verbs-order.ts +0 -30
- package/src/rules/common/path-not-include-query.ts +0 -17
- package/src/rules/common/path-params-defined.ts +0 -58
- package/src/rules/common/path-segment-plural.ts +0 -31
- package/src/rules/common/paths-kebab-case.ts +0 -16
- package/src/rules/common/spec.ts +0 -143
- package/src/rules/common/tag-description.ts +0 -10
- package/src/rules/common/tags-alphabetical.ts +0 -20
- package/src/rules/no-unresolved-refs.ts +0 -51
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +0 -110
- package/src/rules/oas2/__tests__/spec/fixtures/description.md +0 -1
- package/src/rules/oas2/__tests__/spec/info.test.ts +0 -355
- package/src/rules/oas2/__tests__/spec/operation.test.ts +0 -123
- package/src/rules/oas2/__tests__/spec/paths.test.ts +0 -245
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +0 -31
- package/src/rules/oas2/__tests__/spec/utils.ts +0 -32
- package/src/rules/oas2/boolean-parameter-prefixes.ts +0 -26
- package/src/rules/oas2/index.ts +0 -83
- package/src/rules/oas2/remove-unused-components.ts +0 -76
- package/src/rules/oas2/request-mime-type.ts +0 -17
- package/src/rules/oas2/response-mime-type.ts +0 -17
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +0 -111
- package/src/rules/oas3/__tests__/fixtures/common.yaml +0 -11
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +0 -205
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +0 -65
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +0 -392
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +0 -60
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +0 -79
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +0 -131
- package/src/rules/oas3/__tests__/spec/callbacks.test.ts +0 -41
- package/src/rules/oas3/__tests__/spec/fixtures/description.md +0 -1
- package/src/rules/oas3/__tests__/spec/info.test.ts +0 -391
- package/src/rules/oas3/__tests__/spec/operation.test.ts +0 -253
- package/src/rules/oas3/__tests__/spec/paths.test.ts +0 -284
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +0 -77
- package/src/rules/oas3/__tests__/spec/servers.test.ts +0 -499
- package/src/rules/oas3/__tests__/spec/spec.test.ts +0 -288
- package/src/rules/oas3/__tests__/spec/utils.ts +0 -32
- package/src/rules/oas3/boolean-parameter-prefixes.ts +0 -28
- package/src/rules/oas3/index.ts +0 -99
- package/src/rules/oas3/no-empty-servers.ts +0 -22
- package/src/rules/oas3/no-example-value-and-externalValue.ts +0 -14
- package/src/rules/oas3/no-invalid-media-type-examples.ts +0 -41
- package/src/rules/oas3/no-server-example.com.ts +0 -14
- package/src/rules/oas3/no-server-trailing-slash.ts +0 -15
- package/src/rules/oas3/no-servers-empty-enum.ts +0 -67
- package/src/rules/oas3/no-undefined-server-variable.ts +0 -30
- package/src/rules/oas3/no-unused-components.ts +0 -75
- package/src/rules/oas3/remove-unused-components.ts +0 -84
- package/src/rules/oas3/request-mime-type.ts +0 -31
- package/src/rules/oas3/response-mime-type.ts +0 -31
- package/src/rules/other/stats.ts +0 -44
- package/src/rules/utils.ts +0 -123
- package/src/types/index.ts +0 -138
- package/src/types/oas2.ts +0 -397
- package/src/types/oas3.ts +0 -506
- package/src/types/oas3_1.ts +0 -251
- package/src/types/redocly-yaml.ts +0 -637
- package/src/typings/common.ts +0 -9
- package/src/typings/openapi.ts +0 -297
- package/src/typings/swagger.ts +0 -236
- package/src/utils.ts +0 -190
- package/src/visitors.ts +0 -448
- package/src/walk.ts +0 -416
- package/tsconfig.json +0 -8
- package/tsconfig.tsbuildinfo +0 -1
package/lib/config/utils.js
CHANGED
|
@@ -11,10 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.getUniquePlugins = exports.getResolveConfig = exports.transformConfig = exports.getMergedConfig = exports.mergeExtends = exports.prefixRules = exports.transformApiDefinitionsToApis = exports.parsePresetName = void 0;
|
|
15
|
-
const colorette_1 = require("colorette");
|
|
14
|
+
exports.getUniquePlugins = exports.getResolveConfig = exports.transformConfig = exports.checkForDeprecatedFields = exports.getMergedConfig = exports.mergeExtends = exports.prefixRules = exports.transformApiDefinitionsToApis = exports.parsePresetName = void 0;
|
|
16
15
|
const utils_1 = require("../utils");
|
|
17
16
|
const config_1 = require("./config");
|
|
17
|
+
const logger_1 = require("../logger");
|
|
18
18
|
function parsePresetName(presetName) {
|
|
19
19
|
if (presetName.indexOf('/') > -1) {
|
|
20
20
|
const [pluginId, configName] = presetName.split('/');
|
|
@@ -25,14 +25,59 @@ function parsePresetName(presetName) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.parsePresetName = parsePresetName;
|
|
28
|
-
function transformApiDefinitionsToApis(apiDefinitions
|
|
29
|
-
|
|
28
|
+
function transformApiDefinitionsToApis(apiDefinitions) {
|
|
29
|
+
if (!apiDefinitions)
|
|
30
|
+
return undefined;
|
|
31
|
+
const apis = {};
|
|
30
32
|
for (const [apiName, apiPath] of Object.entries(apiDefinitions)) {
|
|
31
33
|
apis[apiName] = { root: apiPath };
|
|
32
34
|
}
|
|
33
35
|
return apis;
|
|
34
36
|
}
|
|
35
37
|
exports.transformApiDefinitionsToApis = transformApiDefinitionsToApis;
|
|
38
|
+
function extractFlatConfig(_a) {
|
|
39
|
+
var _b;
|
|
40
|
+
var { plugins, extends: _extends, rules, oas2Rules, oas3_0Rules, oas3_1Rules, preprocessors, oas2Preprocessors, oas3_0Preprocessors, oas3_1Preprocessors, decorators, oas2Decorators, oas3_0Decorators, oas3_1Decorators } = _a, rawConfigRest = __rest(_a, ["plugins", "extends", "rules", "oas2Rules", "oas3_0Rules", "oas3_1Rules", "preprocessors", "oas2Preprocessors", "oas3_0Preprocessors", "oas3_1Preprocessors", "decorators", "oas2Decorators", "oas3_0Decorators", "oas3_1Decorators"]);
|
|
41
|
+
const styleguideConfig = {
|
|
42
|
+
plugins,
|
|
43
|
+
extends: _extends,
|
|
44
|
+
rules,
|
|
45
|
+
oas2Rules,
|
|
46
|
+
oas3_0Rules,
|
|
47
|
+
oas3_1Rules,
|
|
48
|
+
preprocessors,
|
|
49
|
+
oas2Preprocessors,
|
|
50
|
+
oas3_0Preprocessors,
|
|
51
|
+
oas3_1Preprocessors,
|
|
52
|
+
decorators,
|
|
53
|
+
oas2Decorators,
|
|
54
|
+
oas3_0Decorators,
|
|
55
|
+
oas3_1Decorators,
|
|
56
|
+
doNotResolveExamples: (_b = rawConfigRest.resolve) === null || _b === void 0 ? void 0 : _b.doNotResolveExamples,
|
|
57
|
+
};
|
|
58
|
+
if ((rawConfigRest.lint && rawConfigRest.styleguide) ||
|
|
59
|
+
(Object.values(styleguideConfig).some(utils_1.isDefined) &&
|
|
60
|
+
(rawConfigRest.lint || rawConfigRest.styleguide))) {
|
|
61
|
+
throw new Error(`Do not use 'lint', 'styleguide' and flat syntax together. \nSee more about the configuration in the docs: https://redocly.com/docs/cli/configuration/ \n`);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
styleguideConfig: Object.values(styleguideConfig).some(utils_1.isDefined)
|
|
65
|
+
? styleguideConfig
|
|
66
|
+
: undefined,
|
|
67
|
+
rawConfigRest,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function transformApis(legacyApis) {
|
|
71
|
+
if (!legacyApis)
|
|
72
|
+
return undefined;
|
|
73
|
+
const apis = {};
|
|
74
|
+
for (let _a of Object.entries(legacyApis)) {
|
|
75
|
+
const [apiName, _b] = _a, { lint } = _b, apiContent = __rest(_b, ["lint"]);
|
|
76
|
+
const { styleguideConfig, rawConfigRest } = extractFlatConfig(apiContent);
|
|
77
|
+
apis[apiName] = Object.assign({ styleguide: styleguideConfig || lint }, rawConfigRest);
|
|
78
|
+
}
|
|
79
|
+
return apis;
|
|
80
|
+
}
|
|
36
81
|
function prefixRules(rules, prefix) {
|
|
37
82
|
if (!prefix)
|
|
38
83
|
return rules;
|
|
@@ -61,9 +106,9 @@ function mergeExtends(rulesConfList) {
|
|
|
61
106
|
pluginPaths: [],
|
|
62
107
|
extendPaths: [],
|
|
63
108
|
};
|
|
64
|
-
for (
|
|
109
|
+
for (const rulesConf of rulesConfList) {
|
|
65
110
|
if (rulesConf.extends) {
|
|
66
|
-
throw new Error(
|
|
111
|
+
throw new Error(`'extends' is not supported in shared configs yet: ${JSON.stringify(rulesConf, null, 2)}.`);
|
|
67
112
|
}
|
|
68
113
|
Object.assign(result.rules, rulesConf.rules);
|
|
69
114
|
Object.assign(result.oas2Rules, rulesConf.oas2Rules);
|
|
@@ -93,46 +138,79 @@ function mergeExtends(rulesConfList) {
|
|
|
93
138
|
return result;
|
|
94
139
|
}
|
|
95
140
|
exports.mergeExtends = mergeExtends;
|
|
96
|
-
function getMergedConfig(config,
|
|
97
|
-
var _a, _b, _c, _d, _e, _f;
|
|
141
|
+
function getMergedConfig(config, apiName) {
|
|
142
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
98
143
|
const extendPaths = [
|
|
99
|
-
...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.
|
|
100
|
-
(_b = (_a = config.rawConfig) === null || _a === void 0 ? void 0 : _a.
|
|
144
|
+
...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.styleguide) === null || _a === void 0 ? void 0 : _a.extendPaths; }),
|
|
145
|
+
(_b = (_a = config.rawConfig) === null || _a === void 0 ? void 0 : _a.styleguide) === null || _b === void 0 ? void 0 : _b.extendPaths,
|
|
101
146
|
]
|
|
102
147
|
.flat()
|
|
103
|
-
.filter(
|
|
148
|
+
.filter(utils_1.isTruthy);
|
|
104
149
|
const pluginPaths = [
|
|
105
|
-
...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.
|
|
106
|
-
(_d = (_c = config.rawConfig) === null || _c === void 0 ? void 0 : _c.
|
|
150
|
+
...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.styleguide) === null || _a === void 0 ? void 0 : _a.pluginPaths; }),
|
|
151
|
+
(_d = (_c = config.rawConfig) === null || _c === void 0 ? void 0 : _c.styleguide) === null || _d === void 0 ? void 0 : _d.pluginPaths,
|
|
107
152
|
]
|
|
108
153
|
.flat()
|
|
109
|
-
.filter(
|
|
110
|
-
return
|
|
111
|
-
? new config_1.Config(Object.assign(Object.assign({}, config.rawConfig), {
|
|
112
|
-
? config.apis[
|
|
113
|
-
: config.rawConfig.
|
|
114
|
-
pluginPaths }),
|
|
154
|
+
.filter(utils_1.isTruthy);
|
|
155
|
+
return apiName
|
|
156
|
+
? new config_1.Config(Object.assign(Object.assign({}, config.rawConfig), { styleguide: Object.assign(Object.assign({}, (config.apis[apiName]
|
|
157
|
+
? config.apis[apiName].styleguide
|
|
158
|
+
: config.rawConfig.styleguide)), { extendPaths,
|
|
159
|
+
pluginPaths }), theme: Object.assign(Object.assign({}, config.rawConfig.theme), (_e = config.apis[apiName]) === null || _e === void 0 ? void 0 : _e.theme), files: [...config.files, ...((_h = (_g = (_f = config.apis) === null || _f === void 0 ? void 0 : _f[apiName]) === null || _g === void 0 ? void 0 : _g.files) !== null && _h !== void 0 ? _h : [])] }), config.configFile)
|
|
115
160
|
: config;
|
|
116
161
|
}
|
|
117
162
|
exports.getMergedConfig = getMergedConfig;
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
163
|
+
function checkForDeprecatedFields(deprecatedField, updatedField, rawConfig, updatedObject) {
|
|
164
|
+
const isDeprecatedFieldInApis = rawConfig.apis &&
|
|
165
|
+
Object.values(rawConfig.apis).some((api) => api[deprecatedField]);
|
|
166
|
+
if (rawConfig[deprecatedField] && updatedField === null) {
|
|
167
|
+
utils_1.showWarningForDeprecatedField(deprecatedField);
|
|
121
168
|
}
|
|
122
|
-
if (rawConfig[
|
|
123
|
-
|
|
124
|
-
throw new Error("Do not use 'referenceDocs' field. Use 'features.openapi' instead.\n");
|
|
169
|
+
if (rawConfig[deprecatedField] && updatedField && rawConfig[updatedField]) {
|
|
170
|
+
utils_1.showErrorForDeprecatedField(deprecatedField, updatedField);
|
|
125
171
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
process.stderr.write(`The ${colorette_1.yellow('apiDefinitions')} field is deprecated. Use ${colorette_1.green('apis')} instead. Read more about this change: https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties\n`);
|
|
172
|
+
if (rawConfig[deprecatedField] && updatedObject && rawConfig[updatedObject]) {
|
|
173
|
+
utils_1.showErrorForDeprecatedField(deprecatedField, updatedField, updatedObject);
|
|
129
174
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
175
|
+
if (rawConfig[deprecatedField] || isDeprecatedFieldInApis) {
|
|
176
|
+
utils_1.showWarningForDeprecatedField(deprecatedField, updatedField, updatedObject);
|
|
132
177
|
}
|
|
133
|
-
|
|
178
|
+
}
|
|
179
|
+
exports.checkForDeprecatedFields = checkForDeprecatedFields;
|
|
180
|
+
function transformConfig(rawConfig) {
|
|
181
|
+
var _a, _b;
|
|
182
|
+
const migratedFields = [
|
|
183
|
+
['apiDefinitions', 'apis', undefined],
|
|
184
|
+
['referenceDocs', 'openapi', 'theme'],
|
|
185
|
+
['lint', undefined, undefined],
|
|
186
|
+
['styleguide', undefined, undefined],
|
|
187
|
+
['features.openapi', 'openapi', 'theme'],
|
|
188
|
+
];
|
|
189
|
+
for (const [deprecatedField, updatedField, updatedObject] of migratedFields) {
|
|
190
|
+
checkForDeprecatedFields(deprecatedField, updatedField, rawConfig, updatedObject);
|
|
191
|
+
}
|
|
192
|
+
const { apis, apiDefinitions, referenceDocs, lint } = rawConfig, rest = __rest(rawConfig, ["apis", "apiDefinitions", "referenceDocs", "lint"]);
|
|
193
|
+
const { styleguideConfig, rawConfigRest } = extractFlatConfig(rest);
|
|
194
|
+
const transformedConfig = Object.assign({ theme: {
|
|
195
|
+
openapi: Object.assign(Object.assign(Object.assign({}, referenceDocs), rawConfig['features.openapi']), (_a = rawConfig.theme) === null || _a === void 0 ? void 0 : _a.openapi),
|
|
196
|
+
mockServer: Object.assign(Object.assign({}, rawConfig['features.mockServer']), (_b = rawConfig.theme) === null || _b === void 0 ? void 0 : _b.mockServer),
|
|
197
|
+
}, apis: transformApis(apis) || transformApiDefinitionsToApis(apiDefinitions), styleguide: styleguideConfig || lint }, rawConfigRest);
|
|
198
|
+
showDeprecationMessages(transformedConfig);
|
|
199
|
+
return transformedConfig;
|
|
134
200
|
}
|
|
135
201
|
exports.transformConfig = transformConfig;
|
|
202
|
+
function showDeprecationMessages(config) {
|
|
203
|
+
var _a, _b;
|
|
204
|
+
let allRules = Object.assign({}, (_a = config.styleguide) === null || _a === void 0 ? void 0 : _a.rules);
|
|
205
|
+
for (const api of Object.values(config.apis || {})) {
|
|
206
|
+
allRules = Object.assign(Object.assign({}, allRules), (_b = api === null || api === void 0 ? void 0 : api.styleguide) === null || _b === void 0 ? void 0 : _b.rules);
|
|
207
|
+
}
|
|
208
|
+
for (const ruleKey of Object.keys(allRules)) {
|
|
209
|
+
if (ruleKey.startsWith('assert/')) {
|
|
210
|
+
logger_1.logger.warn(`\nThe 'assert/' syntax in ${ruleKey} is deprecated. Update your configuration to use 'rule/' instead. Examples and more information: https://redocly.com/docs/cli/rules/configurable-rules/\n`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
136
214
|
function getResolveConfig(resolve) {
|
|
137
215
|
var _a, _b;
|
|
138
216
|
return {
|
|
@@ -152,7 +230,7 @@ function getUniquePlugins(plugins) {
|
|
|
152
230
|
seen.add(p.id);
|
|
153
231
|
}
|
|
154
232
|
else if (p.id) {
|
|
155
|
-
|
|
233
|
+
logger_1.logger.warn(`Duplicate plugin id "${logger_1.colorize.red(p.id)}".\n`);
|
|
156
234
|
}
|
|
157
235
|
}
|
|
158
236
|
return results;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIfMatchByStrategy = exports.filter = void 0;
|
|
4
|
+
const ref_utils_1 = require("../../../ref-utils");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
|
+
function filter(node, ctx, criteria) {
|
|
7
|
+
const { parent, key } = ctx;
|
|
8
|
+
let didDelete = false;
|
|
9
|
+
if (Array.isArray(node)) {
|
|
10
|
+
for (let i = 0; i < node.length; i++) {
|
|
11
|
+
if (ref_utils_1.isRef(node[i])) {
|
|
12
|
+
const resolved = ctx.resolve(node[i]);
|
|
13
|
+
if (criteria(resolved.node)) {
|
|
14
|
+
node.splice(i, 1);
|
|
15
|
+
didDelete = true;
|
|
16
|
+
i--;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (criteria(node[i])) {
|
|
20
|
+
node.splice(i, 1);
|
|
21
|
+
didDelete = true;
|
|
22
|
+
i--;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (utils_1.isPlainObject(node)) {
|
|
27
|
+
for (const key of Object.keys(node)) {
|
|
28
|
+
node = node;
|
|
29
|
+
if (ref_utils_1.isRef(node[key])) {
|
|
30
|
+
const resolved = ctx.resolve(node[key]);
|
|
31
|
+
if (criteria(resolved.node)) {
|
|
32
|
+
delete node[key];
|
|
33
|
+
didDelete = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (criteria(node[key])) {
|
|
37
|
+
delete node[key];
|
|
38
|
+
didDelete = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (didDelete && (utils_1.isEmptyObject(node) || utils_1.isEmptyArray(node))) {
|
|
43
|
+
delete parent[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.filter = filter;
|
|
47
|
+
function checkIfMatchByStrategy(nodeValue, decoratorValue, strategy) {
|
|
48
|
+
if (nodeValue === undefined || decoratorValue === undefined) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (!Array.isArray(decoratorValue) && !Array.isArray(nodeValue)) {
|
|
52
|
+
return nodeValue === decoratorValue;
|
|
53
|
+
}
|
|
54
|
+
decoratorValue = toArrayIfNeeded(decoratorValue);
|
|
55
|
+
nodeValue = toArrayIfNeeded(nodeValue);
|
|
56
|
+
if (strategy === 'any') {
|
|
57
|
+
return decoratorValue.some((item) => nodeValue.includes(item));
|
|
58
|
+
}
|
|
59
|
+
if (strategy === 'all') {
|
|
60
|
+
return decoratorValue.every((item) => nodeValue.includes(item));
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
exports.checkIfMatchByStrategy = checkIfMatchByStrategy;
|
|
65
|
+
function toArrayIfNeeded(value) {
|
|
66
|
+
return Array.isArray(value) ? value : [value];
|
|
67
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterIn = void 0;
|
|
4
|
+
const filter_helper_1 = require("./filter-helper");
|
|
5
|
+
const DEFAULT_STRATEGY = 'any';
|
|
6
|
+
const FilterIn = ({ property, value, matchStrategy }) => {
|
|
7
|
+
const strategy = matchStrategy || DEFAULT_STRATEGY;
|
|
8
|
+
const filterInCriteria = (item) => (item === null || item === void 0 ? void 0 : item[property]) && !filter_helper_1.checkIfMatchByStrategy(item === null || item === void 0 ? void 0 : item[property], value, strategy);
|
|
9
|
+
return {
|
|
10
|
+
any: {
|
|
11
|
+
enter: (node, ctx) => {
|
|
12
|
+
filter_helper_1.filter(node, ctx, filterInCriteria);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.FilterIn = FilterIn;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterOut = void 0;
|
|
4
|
+
const filter_helper_1 = require("./filter-helper");
|
|
5
|
+
const DEFAULT_STRATEGY = 'any';
|
|
6
|
+
const FilterOut = ({ property, value, matchStrategy }) => {
|
|
7
|
+
const strategy = matchStrategy || DEFAULT_STRATEGY;
|
|
8
|
+
const filterOutCriteria = (item) => filter_helper_1.checkIfMatchByStrategy(item === null || item === void 0 ? void 0 : item[property], value, strategy);
|
|
9
|
+
return {
|
|
10
|
+
any: {
|
|
11
|
+
enter: (node, ctx) => {
|
|
12
|
+
filter_helper_1.filter(node, ctx, filterOutCriteria);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.FilterOut = FilterOut;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.InfoOverride = void 0;
|
|
15
|
+
const InfoOverride = (newInfo) => {
|
|
16
|
+
return {
|
|
17
|
+
Info: {
|
|
18
|
+
leave(info) {
|
|
19
|
+
if (typeof newInfo !== 'object' || Array.isArray(newInfo) || newInfo === null) {
|
|
20
|
+
throw new Error(`"info-override" decorator should be called with an object`);
|
|
21
|
+
}
|
|
22
|
+
const { severity: _ } = newInfo, rest = __rest(newInfo, ["severity"]);
|
|
23
|
+
Object.assign(info, rest);
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.InfoOverride = InfoOverride;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MediaTypeExamplesOverride = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const ref_utils_1 = require("../../ref-utils");
|
|
6
|
+
const MediaTypeExamplesOverride = ({ operationIds }) => {
|
|
7
|
+
return {
|
|
8
|
+
Operation: {
|
|
9
|
+
enter(operation, ctx) {
|
|
10
|
+
const operationId = operation.operationId;
|
|
11
|
+
if (!operationId) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const properties = operationIds[operationId];
|
|
15
|
+
if (!properties) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (properties.responses && operation.responses) {
|
|
19
|
+
for (const responseCode of Object.keys(properties.responses)) {
|
|
20
|
+
const resolvedResponse = checkAndResolveRef(operation.responses[responseCode], ctx.resolve);
|
|
21
|
+
if (!resolvedResponse) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
resolvedResponse.content = resolvedResponse.content ? resolvedResponse.content : {};
|
|
25
|
+
Object.keys(properties.responses[responseCode]).forEach((mimeType) => {
|
|
26
|
+
resolvedResponse.content[mimeType] = Object.assign(Object.assign({}, resolvedResponse.content[mimeType]), { examples: utils_1.yamlAndJsonSyncReader(properties.responses[responseCode][mimeType]) });
|
|
27
|
+
});
|
|
28
|
+
operation.responses[responseCode] = resolvedResponse;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (properties.request && operation.requestBody) {
|
|
32
|
+
const resolvedRequest = checkAndResolveRef(operation.requestBody, ctx.resolve);
|
|
33
|
+
if (!resolvedRequest) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
resolvedRequest.content = resolvedRequest.content ? resolvedRequest.content : {};
|
|
37
|
+
Object.keys(properties.request).forEach((mimeType) => {
|
|
38
|
+
resolvedRequest.content[mimeType] = Object.assign(Object.assign({}, resolvedRequest.content[mimeType]), { examples: utils_1.yamlAndJsonSyncReader(properties.request[mimeType]) });
|
|
39
|
+
});
|
|
40
|
+
operation.requestBody = resolvedRequest;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.MediaTypeExamplesOverride = MediaTypeExamplesOverride;
|
|
47
|
+
function checkAndResolveRef(node, resolver) {
|
|
48
|
+
if (!ref_utils_1.isRef(node)) {
|
|
49
|
+
return node;
|
|
50
|
+
}
|
|
51
|
+
const resolved = resolver(node);
|
|
52
|
+
return resolved.error ? undefined : JSON.parse(JSON.stringify(resolved.node));
|
|
53
|
+
}
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RegistryDependencies = void 0;
|
|
4
4
|
const redocly_1 = require("../../redocly");
|
|
5
5
|
const RegistryDependencies = () => {
|
|
6
|
-
|
|
6
|
+
const registryDependencies = new Set();
|
|
7
7
|
return {
|
|
8
|
-
|
|
8
|
+
Root: {
|
|
9
9
|
leave(_, ctx) {
|
|
10
10
|
const data = ctx.getVisitorData();
|
|
11
11
|
data.links = Array.from(registryDependencies);
|
|
@@ -4,5 +4,8 @@ export declare const decorators: {
|
|
|
4
4
|
'operation-description-override': Oas2Decorator;
|
|
5
5
|
'tag-description-override': Oas2Decorator;
|
|
6
6
|
'info-description-override': Oas2Decorator;
|
|
7
|
+
'info-override': Oas2Decorator;
|
|
7
8
|
'remove-x-internal': Oas2Decorator;
|
|
9
|
+
'filter-in': Oas2Decorator;
|
|
10
|
+
'filter-out': Oas2Decorator;
|
|
8
11
|
};
|
|
@@ -5,11 +5,17 @@ const registry_dependencies_1 = require("../common/registry-dependencies");
|
|
|
5
5
|
const operation_description_override_1 = require("../common/operation-description-override");
|
|
6
6
|
const tag_description_override_1 = require("../common/tag-description-override");
|
|
7
7
|
const info_description_override_1 = require("../common/info-description-override");
|
|
8
|
+
const info_override_1 = require("../common/info-override");
|
|
8
9
|
const remove_x_internal_1 = require("../common/remove-x-internal");
|
|
10
|
+
const filter_in_1 = require("../common/filters/filter-in");
|
|
11
|
+
const filter_out_1 = require("../common/filters/filter-out");
|
|
9
12
|
exports.decorators = {
|
|
10
13
|
'registry-dependencies': registry_dependencies_1.RegistryDependencies,
|
|
11
14
|
'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
|
|
12
15
|
'tag-description-override': tag_description_override_1.TagDescriptionOverride,
|
|
13
16
|
'info-description-override': info_description_override_1.InfoDescriptionOverride,
|
|
14
|
-
'
|
|
17
|
+
'info-override': info_override_1.InfoOverride,
|
|
18
|
+
'remove-x-internal': remove_x_internal_1.RemoveXInternal,
|
|
19
|
+
'filter-in': filter_in_1.FilterIn,
|
|
20
|
+
'filter-out': filter_out_1.FilterOut,
|
|
15
21
|
};
|
|
@@ -4,5 +4,9 @@ export declare const decorators: {
|
|
|
4
4
|
'operation-description-override': Oas3Decorator;
|
|
5
5
|
'tag-description-override': Oas3Decorator;
|
|
6
6
|
'info-description-override': Oas3Decorator;
|
|
7
|
+
'info-override': Oas3Decorator;
|
|
7
8
|
'remove-x-internal': Oas3Decorator;
|
|
9
|
+
'filter-in': Oas3Decorator;
|
|
10
|
+
'filter-out': Oas3Decorator;
|
|
11
|
+
'media-type-examples-override': Oas3Decorator;
|
|
8
12
|
};
|
|
@@ -5,11 +5,19 @@ const registry_dependencies_1 = require("../common/registry-dependencies");
|
|
|
5
5
|
const operation_description_override_1 = require("../common/operation-description-override");
|
|
6
6
|
const tag_description_override_1 = require("../common/tag-description-override");
|
|
7
7
|
const info_description_override_1 = require("../common/info-description-override");
|
|
8
|
+
const info_override_1 = require("../common/info-override");
|
|
8
9
|
const remove_x_internal_1 = require("../common/remove-x-internal");
|
|
10
|
+
const filter_in_1 = require("../common/filters/filter-in");
|
|
11
|
+
const filter_out_1 = require("../common/filters/filter-out");
|
|
12
|
+
const media_type_examples_override_1 = require("../common/media-type-examples-override");
|
|
9
13
|
exports.decorators = {
|
|
10
14
|
'registry-dependencies': registry_dependencies_1.RegistryDependencies,
|
|
11
15
|
'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
|
|
12
16
|
'tag-description-override': tag_description_override_1.TagDescriptionOverride,
|
|
13
17
|
'info-description-override': info_description_override_1.InfoDescriptionOverride,
|
|
14
|
-
'
|
|
18
|
+
'info-override': info_override_1.InfoOverride,
|
|
19
|
+
'remove-x-internal': remove_x_internal_1.RemoveXInternal,
|
|
20
|
+
'filter-in': filter_in_1.FilterIn,
|
|
21
|
+
'filter-out': filter_out_1.FilterOut,
|
|
22
|
+
'media-type-examples-override': media_type_examples_override_1.MediaTypeExamplesOverride,
|
|
15
23
|
};
|
package/lib/env.d.ts
ADDED
package/lib/env.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.env = exports.isBrowser = void 0;
|
|
4
|
+
exports.isBrowser =
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
typeof window !== 'undefined' || typeof self !== 'undefined' || typeof process === 'undefined'; // main and worker thread
|
|
8
|
+
exports.env = exports.isBrowser ? {} : process.env || {};
|
package/lib/format/codeframes.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAstNodeByPointer = exports.getLineColLocation = exports.getCodeframe = void 0;
|
|
4
|
-
const colorette_1 = require("colorette");
|
|
5
4
|
const yamlAst = require("yaml-ast-parser");
|
|
6
5
|
const ref_utils_1 = require("../ref-utils");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
7
|
const MAX_LINE_LENGTH = 150;
|
|
8
8
|
const MAX_CODEFRAME_LINES = 3;
|
|
9
9
|
// TODO: temporary
|
|
@@ -11,7 +11,7 @@ function parsePointer(pointer) {
|
|
|
11
11
|
return pointer.substr(2).split('/').map(ref_utils_1.unescapePointer);
|
|
12
12
|
}
|
|
13
13
|
function getCodeframe(location, color) {
|
|
14
|
-
|
|
14
|
+
logger_1.colorOptions.enabled = color;
|
|
15
15
|
const { start, end = { line: start.line, col: start.col + 1 }, source } = location;
|
|
16
16
|
const lines = source.getLines();
|
|
17
17
|
const startLineNum = start.line;
|
|
@@ -28,16 +28,22 @@ function getCodeframe(location, color) {
|
|
|
28
28
|
const line = lines[i - 1] || '';
|
|
29
29
|
if (line !== '')
|
|
30
30
|
currentPad = padSize(line);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
prefixedLines.push([`${i}`, markLine(line, startIdx, endIdx,
|
|
31
|
+
const startIdx = i === startLineNum ? start.col - 1 : currentPad;
|
|
32
|
+
const endIdx = i === endLineNum ? end.col - 1 : line.length;
|
|
33
|
+
prefixedLines.push([`${i}`, markLine(line, startIdx, endIdx, logger_1.colorize.red)]);
|
|
34
34
|
if (!color)
|
|
35
35
|
prefixedLines.push(['', underlineLine(line, startIdx, endIdx)]);
|
|
36
36
|
}
|
|
37
37
|
if (skipLines > 0) {
|
|
38
|
-
prefixedLines.push([
|
|
38
|
+
prefixedLines.push([
|
|
39
|
+
`…`,
|
|
40
|
+
`${whitespace(currentPad)}${logger_1.colorize.gray(`< ${skipLines} more lines >`)}`,
|
|
41
|
+
]);
|
|
39
42
|
// print last line
|
|
40
|
-
prefixedLines.push([
|
|
43
|
+
prefixedLines.push([
|
|
44
|
+
`${endLineNum}`,
|
|
45
|
+
markLine(lines[endLineNum - 1], -1, end.col - 1, logger_1.colorize.red),
|
|
46
|
+
]);
|
|
41
47
|
if (!color)
|
|
42
48
|
prefixedLines.push(['', underlineLine(lines[endLineNum - 1], -1, end.col - 1)]);
|
|
43
49
|
}
|
|
@@ -48,7 +54,7 @@ function getCodeframe(location, color) {
|
|
|
48
54
|
[`${endLineNum + 1}`, markLine(lines[endLineNum - 1 + 1])],
|
|
49
55
|
[`${endLineNum + 2}`, markLine(lines[endLineNum - 1 + 2])],
|
|
50
56
|
]);
|
|
51
|
-
function markLine(line, startIdx = -1, endIdx = +Infinity, variant =
|
|
57
|
+
function markLine(line, startIdx = -1, endIdx = +Infinity, variant = logger_1.colorize.gray) {
|
|
52
58
|
if (!color)
|
|
53
59
|
return line;
|
|
54
60
|
if (!line)
|
|
@@ -66,14 +72,14 @@ function printPrefixedLines(lines) {
|
|
|
66
72
|
const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
|
|
67
73
|
const dedentLen = Math.min(...existingLines.map(([_, line]) => (line === '' ? Infinity : padSize(line))));
|
|
68
74
|
return existingLines
|
|
69
|
-
.map(([prefix, line]) =>
|
|
75
|
+
.map(([prefix, line]) => logger_1.colorize.gray(leftPad(padLen, prefix) + ' |') +
|
|
70
76
|
(line ? ' ' + limitLineLength(line.substring(dedentLen)) : ''))
|
|
71
77
|
.join('\n');
|
|
72
78
|
}
|
|
73
79
|
function limitLineLength(line, maxLen = MAX_LINE_LENGTH) {
|
|
74
80
|
const overflowLen = line.length - maxLen;
|
|
75
81
|
if (overflowLen > 0) {
|
|
76
|
-
const charsMoreText =
|
|
82
|
+
const charsMoreText = logger_1.colorize.gray(`...<${overflowLen} chars>`);
|
|
77
83
|
return line.substring(0, maxLen - charsMoreText.length) + charsMoreText;
|
|
78
84
|
}
|
|
79
85
|
else {
|
package/lib/format/format.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare type Totals = {
|
|
|
4
4
|
warnings: number;
|
|
5
5
|
ignored: number;
|
|
6
6
|
};
|
|
7
|
-
export declare type OutputFormat = 'codeframe' | 'stylish' | 'json' | 'checkstyle' | 'codeclimate';
|
|
7
|
+
export declare type OutputFormat = 'codeframe' | 'stylish' | 'json' | 'checkstyle' | 'codeclimate' | 'summary';
|
|
8
8
|
export declare function getTotals(problems: (NormalizedProblem & {
|
|
9
9
|
ignored?: boolean;
|
|
10
10
|
})[]): Totals;
|