|
1 | 1 | import { performance } from "node:perf_hooks";
|
2 | 2 | import type { Readable } from "node:stream";
|
3 | 3 | import { createConfig } from "@redocly/openapi-core";
|
| 4 | +import type { RawGovernanceConfig } from "@redocly/openapi-core/lib/config/config"; |
4 | 5 | import type ts from "typescript";
|
5 | 6 | import { validateAndBundle } from "./lib/redoc.js";
|
6 | 7 | import { debug, resolveRef, scanDiscriminators } from "./lib/utils.js";
|
@@ -51,14 +52,13 @@ export default async function openapiTS(
|
51 | 52 |
|
52 | 53 | const redoc =
|
53 | 54 | options.redocly ??
|
54 |
| - (await createConfig( |
55 |
| - { |
56 |
| - rules: { |
57 |
| - "operation-operationId-unique": { severity: "error" }, // throw error on duplicate operationIDs |
58 |
| - }, |
| 55 | + (await createConfig({ |
| 56 | + ...REDOCLY_MINIMAL_CONFIG, |
| 57 | + rules: { |
| 58 | + ...REDOCLY_MINIMAL_CONFIG.rules, |
| 59 | + "operation-operationId-unique": { severity: "error" }, // throw error on duplicate operationIDs |
59 | 60 | },
|
60 |
| - { extends: ["minimal"] }, |
61 |
| - )); |
| 61 | + })); |
62 | 62 |
|
63 | 63 | const schema = await validateAndBundle(source, {
|
64 | 64 | redoc,
|
@@ -102,3 +102,220 @@ export default async function openapiTS(
|
102 | 102 |
|
103 | 103 | return result;
|
104 | 104 | }
|
| 105 | + |
| 106 | +export const REDOCLY_MINIMAL_CONFIG: RawGovernanceConfig<"built-in"> = { |
| 107 | + rules: { |
| 108 | + struct: "error", |
| 109 | + "no-unresolved-refs": "error", |
| 110 | + }, |
| 111 | + oas2Rules: { |
| 112 | + "boolean-parameter-prefixes": "off", |
| 113 | + "info-contact": "off", |
| 114 | + "info-license": "off", |
| 115 | + "info-license-strict": "off", |
| 116 | + "no-path-trailing-slash": "warn", |
| 117 | + "no-identical-paths": "warn", |
| 118 | + "no-ambiguous-paths": "warn", |
| 119 | + "no-invalid-schema-examples": "off", |
| 120 | + "no-invalid-parameter-examples": "off", |
| 121 | + "no-http-verbs-in-paths": "off", |
| 122 | + "no-enum-type-mismatch": "warn", |
| 123 | + "no-required-schema-properties-undefined": "warn", |
| 124 | + "no-schema-type-mismatch": "warn", |
| 125 | + "operation-summary": "warn", |
| 126 | + "operation-operationId": "warn", |
| 127 | + "operation-operationId-unique": "warn", |
| 128 | + "operation-operationId-url-safe": "warn", |
| 129 | + "operation-description": "off", |
| 130 | + "operation-2xx-response": "warn", |
| 131 | + "operation-4xx-response": "off", |
| 132 | + "operation-parameters-unique": "warn", |
| 133 | + "operation-tag-defined": "off", |
| 134 | + "operation-singular-tag": "off", |
| 135 | + "parameter-description": "off", |
| 136 | + "path-declaration-must-exist": "warn", |
| 137 | + "path-not-include-query": "warn", |
| 138 | + "path-parameters-defined": "warn", |
| 139 | + "paths-kebab-case": "off", |
| 140 | + "path-http-verbs-order": "off", |
| 141 | + "path-params-defined": "off", |
| 142 | + "path-segment-plural": "off", |
| 143 | + "required-string-property-missing-min-length": "off", |
| 144 | + "response-contains-header": "off", |
| 145 | + "request-mime-type": "off", |
| 146 | + "response-contains-property": "off", |
| 147 | + "response-mime-type": "off", |
| 148 | + "security-defined": "warn", |
| 149 | + "spec-strict-refs": "off", |
| 150 | + "scalar-property-missing-example": "off", |
| 151 | + "tag-description": "warn", |
| 152 | + "tags-alphabetical": "off", |
| 153 | + "no-duplicated-tag-names": "off", |
| 154 | + }, |
| 155 | + oas3_0Rules: { |
| 156 | + "array-parameter-serialization": "off", |
| 157 | + "boolean-parameter-prefixes": "off", |
| 158 | + "component-name-unique": "off", |
| 159 | + "info-contact": "off", |
| 160 | + "info-license": "off", |
| 161 | + "info-license-strict": "off", |
| 162 | + "no-ambiguous-paths": "warn", |
| 163 | + "no-path-trailing-slash": "warn", |
| 164 | + "no-identical-paths": "warn", |
| 165 | + "no-invalid-schema-examples": "off", |
| 166 | + "no-invalid-parameter-examples": "off", |
| 167 | + "no-http-verbs-in-paths": "off", |
| 168 | + "no-enum-type-mismatch": "warn", |
| 169 | + "no-required-schema-properties-undefined": "warn", |
| 170 | + "no-schema-type-mismatch": "warn", |
| 171 | + "no-invalid-media-type-examples": { |
| 172 | + severity: "warn", |
| 173 | + allowAdditionalProperties: false, |
| 174 | + }, |
| 175 | + "no-server-example.com": "warn", |
| 176 | + "no-server-trailing-slash": "error", |
| 177 | + "no-empty-servers": "warn", |
| 178 | + "no-example-value-and-externalValue": "warn", |
| 179 | + "no-unused-components": "warn", |
| 180 | + "no-undefined-server-variable": "warn", |
| 181 | + "no-server-variables-empty-enum": "error", |
| 182 | + "nullable-type-sibling": "warn", |
| 183 | + "operation-summary": "warn", |
| 184 | + "operation-operationId": "warn", |
| 185 | + "operation-operationId-unique": "warn", |
| 186 | + "operation-operationId-url-safe": "warn", |
| 187 | + "operation-description": "off", |
| 188 | + "operation-2xx-response": "warn", |
| 189 | + "operation-4xx-response": "off", |
| 190 | + "operation-4xx-problem-details-rfc7807": "off", |
| 191 | + "operation-parameters-unique": "warn", |
| 192 | + "operation-tag-defined": "off", |
| 193 | + "operation-singular-tag": "off", |
| 194 | + "parameter-description": "off", |
| 195 | + "path-declaration-must-exist": "warn", |
| 196 | + "path-not-include-query": "warn", |
| 197 | + "path-parameters-defined": "warn", |
| 198 | + "paths-kebab-case": "off", |
| 199 | + "path-http-verbs-order": "off", |
| 200 | + "path-params-defined": "off", |
| 201 | + "path-segment-plural": "off", |
| 202 | + "required-string-property-missing-min-length": "off", |
| 203 | + "response-contains-header": "off", |
| 204 | + "request-mime-type": "off", |
| 205 | + "response-contains-property": "off", |
| 206 | + "response-mime-type": "off", |
| 207 | + "security-defined": "warn", |
| 208 | + "spec-strict-refs": "off", |
| 209 | + "scalar-property-missing-example": "off", |
| 210 | + "spec-components-invalid-map-name": "warn", |
| 211 | + "tag-description": "warn", |
| 212 | + "tags-alphabetical": "off", |
| 213 | + "no-duplicated-tag-names": "off", |
| 214 | + }, |
| 215 | + oas3_1Rules: { |
| 216 | + "array-parameter-serialization": "off", |
| 217 | + "boolean-parameter-prefixes": "off", |
| 218 | + "component-name-unique": "off", |
| 219 | + "info-contact": "off", |
| 220 | + "info-license": "off", |
| 221 | + "info-license-strict": "off", |
| 222 | + "no-path-trailing-slash": "warn", |
| 223 | + "no-identical-paths": "warn", |
| 224 | + "no-ambiguous-paths": "warn", |
| 225 | + "no-invalid-schema-examples": "off", |
| 226 | + "no-invalid-parameter-examples": "off", |
| 227 | + "no-http-verbs-in-paths": "off", |
| 228 | + "no-enum-type-mismatch": "warn", |
| 229 | + "no-required-schema-properties-undefined": "warn", |
| 230 | + "no-schema-type-mismatch": "warn", |
| 231 | + "no-invalid-media-type-examples": "warn", |
| 232 | + "no-server-example.com": "warn", |
| 233 | + "no-server-trailing-slash": "error", |
| 234 | + "no-empty-servers": "warn", |
| 235 | + "no-example-value-and-externalValue": "warn", |
| 236 | + "no-unused-components": "warn", |
| 237 | + "no-undefined-server-variable": "warn", |
| 238 | + "no-server-variables-empty-enum": "error", |
| 239 | + "operation-summary": "warn", |
| 240 | + "operation-operationId": "warn", |
| 241 | + "operation-operationId-unique": "warn", |
| 242 | + "operation-operationId-url-safe": "warn", |
| 243 | + "operation-description": "off", |
| 244 | + "operation-2xx-response": "warn", |
| 245 | + "operation-4xx-response": "off", |
| 246 | + "operation-4xx-problem-details-rfc7807": "off", |
| 247 | + "operation-parameters-unique": "warn", |
| 248 | + "operation-tag-defined": "off", |
| 249 | + "operation-singular-tag": "off", |
| 250 | + "parameter-description": "off", |
| 251 | + "path-declaration-must-exist": "warn", |
| 252 | + "path-not-include-query": "warn", |
| 253 | + "path-parameters-defined": "warn", |
| 254 | + "paths-kebab-case": "off", |
| 255 | + "path-http-verbs-order": "off", |
| 256 | + "path-params-defined": "off", |
| 257 | + "path-segment-plural": "off", |
| 258 | + "required-string-property-missing-min-length": "off", |
| 259 | + "response-contains-header": "off", |
| 260 | + "request-mime-type": "off", |
| 261 | + "response-contains-property": "off", |
| 262 | + "response-mime-type": "off", |
| 263 | + "security-defined": "warn", |
| 264 | + "spec-strict-refs": "off", |
| 265 | + "scalar-property-missing-example": "off", |
| 266 | + "spec-components-invalid-map-name": "warn", |
| 267 | + "tag-description": "warn", |
| 268 | + "tags-alphabetical": "off", |
| 269 | + "no-duplicated-tag-names": "off", |
| 270 | + }, |
| 271 | + async2Rules: { |
| 272 | + "channels-kebab-case": "off", |
| 273 | + "info-contact": "off", |
| 274 | + "info-license-strict": "off", |
| 275 | + "no-channel-trailing-slash": "off", |
| 276 | + "operation-operationId": "warn", |
| 277 | + "tag-description": "warn", |
| 278 | + "tags-alphabetical": "off", |
| 279 | + "no-duplicated-tag-names": "off", |
| 280 | + "no-required-schema-properties-undefined": "warn", |
| 281 | + "no-enum-type-mismatch": "warn", |
| 282 | + "no-schema-type-mismatch": "warn", |
| 283 | + }, |
| 284 | + async3Rules: { |
| 285 | + "channels-kebab-case": "off", |
| 286 | + "info-contact": "off", |
| 287 | + "info-license-strict": "off", |
| 288 | + "no-channel-trailing-slash": "off", |
| 289 | + "operation-operationId": "warn", |
| 290 | + "tag-description": "warn", |
| 291 | + "tags-alphabetical": "off", |
| 292 | + "no-duplicated-tag-names": "off", |
| 293 | + "no-required-schema-properties-undefined": "warn", |
| 294 | + "no-enum-type-mismatch": "warn", |
| 295 | + "no-schema-type-mismatch": "warn", |
| 296 | + }, |
| 297 | + arazzo1Rules: { |
| 298 | + "criteria-unique": "off", |
| 299 | + "no-criteria-xpath": "off", |
| 300 | + "parameters-unique": "off", |
| 301 | + "requestBody-replacements-unique": "off", |
| 302 | + "sourceDescription-type": "off", |
| 303 | + "sourceDescriptions-not-empty": "off", |
| 304 | + "step-onSuccess-unique": "off", |
| 305 | + "step-onFailure-unique": "off", |
| 306 | + "stepId-unique": "error", |
| 307 | + "sourceDescription-name-unique": "off", |
| 308 | + "respect-supported-versions": "off", |
| 309 | + "workflowId-unique": "error", |
| 310 | + "workflow-dependsOn": "off", |
| 311 | + "no-x-security-scheme-name-without-openapi": "off", |
| 312 | + "x-security-scheme-required-values": "off", |
| 313 | + "no-x-security-scheme-name-in-workflow": "off", |
| 314 | + "no-required-schema-properties-undefined": "warn", |
| 315 | + "no-enum-type-mismatch": "warn", |
| 316 | + "no-schema-type-mismatch": "warn", |
| 317 | + }, |
| 318 | + overlay1Rules: { |
| 319 | + "info-contact": "off", |
| 320 | + }, |
| 321 | +}; |
0 commit comments