[CORE] - Feature: forcedGenerateSchemas — Force generation of schema-mapped or import-mapped schemas#24066
Conversation
…ings or importMappings
…tions and wildcard support
There was a problem hiding this comment.
1 issue found across 14 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
Would the behavior that you seek not simply be realized by generating the entire structure without any schema-mappings, creating a git-branch with it, and then doing it with the schema-mappings, and then looking at the diffs? Having a setting dedicated to it feels a bit overkill and feature-for-the-sake-of-feature? |
|
Hi @Mattias-Sehlstedt, thanks for the push-back. I'll explain why I don't think using a separate branch is sufficient here, and why the feature in this PR is useful. When you use OpenAPI Generator, the API spec is the source of truth. At the same time, The problem is: once a schema is substituted, it is no longer generated, and from that moment it can drift from the spec without any direct signal. A branch-based diff can help as a one-time/manual check, but it is not a stable mechanism for continuous verification in normal CI flows.
Also, this was not introduced as a theoretical capability. The need arose organically from my real-world usage of the I would argue against it being a feature-for-feature's-sake, but rather an automated guardrail for teams that intentionally customize model mappings while still treating the OpenAPI spec as authoritative. And I think this drift-check capability might actually reduce pressure for additional small generator features. Without a guardrail, every mismatch risk tends to become a request for another targeted option. With this option one can keep custom mapped/imported models and still verify conformance against spec-derived reference models directly in unit tests. So instead of adding many narrowly-scoped features over time, this provides one general mechanism to safely support customization while keeping the OpenAPI spec the real source of truth. I also think the current suppression behavior with I understand suppressing generation when the mapped/imported target FQN exactly matches what would be generated (to avoid duplicate/conflicting classes). But suppressing the original schema unconditionally for any |
|
thanks for the pr the use case sounds valid. let's give it a try |
When a schema is listed in
schemaMappings, OpenAPI Generator skips it entirely during model generation (no file is written). This is correct for normal use, but makes it impossible to generate a "reference copy" of the schema - e.g. for a test that asserts a hand-written enum class has not diverged from what the generator would produce.This feature adds a
forcedGenerateSchemasoption: a set of schema names that must be generated even when they also appear inschemaMappingsorimportMappings. It is also possible to just pass an asterisk*in the list to force generation of all schemas.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.