feat: allow preserving specific schemas during prune (preserve-schemas + x-oapi-codegen-keep-unused) by aureleoules · Pull Request #2233 · oapi-codegen/oapi-codegen

@aureleoules

…s + x-oapi-codegen-keep-unused)

Add two ways to keep unreferenced component schemas from being pruned:

- output-options.preserve-schemas: list of schema names to always keep,
  even when not referenced anywhere in the spec.

- x-oapi-codegen-keep-unused: set to true on a schema in the OpenAPI spec
  so that schema is never pruned when unreferenced.

pruneUnusedComponents() now takes an optional preserveSchemas []string
(from config); schemas in that list or with the extension are not removed.
Existing call sites use nil. Tests and configuration-schema/README updated.