-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Breaking change without fallback] [suggestion] [discussion] Split apis option as a semicolon-separated list #4938
Conversation
…rated list Since this option is a list itself and the additionalProperties option is also a list, it is impossible to have a comma-separated list inside a comma-separated list.
I like the idea of making these 'more accessible' from a tooling perspective. However, I think the target of adding this to The The Also, please find the ignore file documentation on the site. I feel like this might better address your concerns and is a much more powerful option (although, tied to file rather than OpenAPI tag/schema simple names). |
I also wanted to comment on the "weird" apisToGenerate, I think the Maven plugin sets this to an empty string because the contents are populated later. I'm on mobile and not really able to fully look into it at the moment. I wanted to point you to CodegenConfigurator, which is where the workflow settings are managed. This is the best place to look for configuration management because the CLI and plugins have some idiosyncrasies that are normalized by CodegenConfigurator. See: Line 444 in b22f7f0
I have some goals to rename things a bit to match our terminology, for instance |
Agreed, The selective generation is slightly different from what I mean - currently, it is a crude short-circuit, (generate) "all-or-nothing" switch. Whilst what I mean is actually grouping the generated operations into resources so that (as in our case) it matches the existing REST API structure. Users might disagree with the current (or "default") grouping. Talking about
|
Getting back to the topic of grouping the operations into resources by user-defined configuration, what do you think about such a feature/enhancement? Do you think grouping operations by tags is a good approach? |
@shybovycha I do think it would be good to allow users to control the grouping. Our tag grouping may fall apart when people have defined more than one tag on a path, as we take the first tag only. Regarding your comment about The See Line 533 in 0344f14
The weird if condition in CodegenMojo is probably a weird case with Maven, but should be commented at the line you've linked. You can still define the "system properties" in the Maven plugin, but I'm assuming the reason this "all-or-nothing" exists is because Maven probably treats an empty node as if it doesn't exist. That is, The reason we have the all-or-nothing is because if you pass one of the selective generation options, it'll limit to only that option. For instance, We've since moved toward the more robust ignore file style patterns, but keep these other properties for existing users. All that said, I'd personally prefer if the selective generation provided something different to users. For example, if it allowed tags and operation ids. Or, http methods. I'm just not sure how much it's used in the first place, or how much effort should go into extending it. |
I'll be addressing this issue via #5251 documentation and adding the new The plugin supports the following structure:
Where |
I'm gonna close this PR in favor of #5251 |
Introduction
There is one quite nifty but undocumented option,
apis
, which could be set in system properties. It defines which API groups should be generated. Given the undocumented internal behavior of grouping all operations by tags, this gives an easy way to migrate existing projects to Open-API with minimal changes by automatically generating API definitions and then generating API interfaces with operations automatically grouped according to the existing endpoints.Hence I am creating a few PRs (#4937, #4938, #4939) addressing this hidden gem of
openapi-generator
.This change
Since
apis
is a (comma-separated) list itself and theadditionalProperties
option is also a (comma-separated) list, it is impossible to have a comma-separated list inside a comma-separated list with the existing parsing.This PR introduces a behavioral change by treating the
apisToGenerate
list as semicolon-separated list. This way it is possible to pass it inside the list (such asadditionalProperties
).Other two possible work-arounds I see are:
x-generate-apis
property and make it a normal comma-separated list; this will, however, require a bit of rework of the core logic by altering betweenapis
andx-generate-apis
values to populate theapisToGenerate
variable inDefaultGenerator#generateApis
, like in [feature] [jax-rs] Get apis property from vendor extensions #4945 (since it is a private method - this can't be easily overriden forJavaJAXRSSpecServerCodegen
only)generateApis
, which only stores the string representation of a boolean value in configuration (either in POM file or in CLI options), but later is transformed to either an empty string (representing thetrue
) ornull
(representingfalse
), see this. This could be replaced with a list of APIs to generate, essentially following option 1, just for a different config optionHappy to hear your thoughts on this.
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.