* We'll use the `default` values of the field as the only value in `examples`. * This will ensure no docs are needed to be read, as the configuration is * self-documenting. * * See https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.9.5
(ctx)
| 16 | * See https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.9.5 |
| 17 | */ |
| 18 | override(ctx) { |
| 19 | const schema = ctx.jsonSchema |
| 20 | |
| 21 | // Preserve strictness: set additionalProperties: false for objects |
| 22 | if (schema && typeof schema === "object" && schema.type === "object" && schema.additionalProperties === undefined) { |
| 23 | schema.additionalProperties = false |
| 24 | } |
| 25 | |
| 26 | // Add examples and default descriptions for string fields with defaults |
| 27 | if (schema && typeof schema === "object" && "type" in schema && schema.type === "string" && schema?.default) { |
| 28 | if (!schema.examples) { |
| 29 | schema.examples = [schema.default] |
| 30 | } |
| 31 | |
| 32 | schema.description = [schema.description || "", `default: \`${schema.default}\``] |
| 33 | .filter(Boolean) |
| 34 | .join("\n\n") |
| 35 | .trim() |
| 36 | } |
| 37 | }, |
| 38 | }) as Record<string, unknown> & { |
| 39 | allowComments?: boolean |
| 40 | allowTrailingCommas?: boolean |
nothing calls this directly
no outgoing calls
no test coverage detected