-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
[REQ] Support multiple YAML files for openapi-generator-maven-plugin #6379
Comments
Do we have a fix available for this |
Actually, it is possible. I use a setup where I define the plugin in a pluginManagement section and a project with a plugin definition that generates two sets of models, one even inheriting from the other.
Then the plugin in the project pom looks like:
Result: two sets of files are generated, one after the other. I myself was quite surprised it worked. I got a hint from here: https://maven.apache.org/guides/mini/guide-default-execution-ids.html. |
Will you excuse a late question? Do we know that the managed plugin is necessary? With versions 6.3.0 and 6.4.0I tried a naïve way with just two executions in the same plugin in my pom.xml, but it seems the plugin is overwriting generated Java files when generating for the second input file in spite of me specifying different package names. This leads to requests being routed to the wrong API and hence failing. Should I expect a managed plugin to fix this? |
Используется вариант предложенный здесь OpenAPITools/openapi-generator#6379 для запуска двух конфигураций плагина с помощью pluginManagement.
I have to generate an API from those yaml I've received, all going into the same model, api generation folders:
1) I don't understand really your inheritance system: who shall inherit from one another in my case? 2) Whatever, this would lead to add in my pom at least 70 lines (100 lines?) to perform my generation, Don't you think this would be difficult and clumsy, in comparison to setting:
or
or
|
@ole-v-v : I don't think the managed plugin is really necessary, it should be a convenience in case the plugin is used multiple POMs. My knowledge of maven is not extensive enough to be 100% sure. It is complicated matter if Maven configuration is your full-time job. And openApiGenerator is also not known for its ease of use. |
@mlebihan : The inheritance between the generated models appeared indeed an issue. In the above example I could not get the inheritance correctly modelled. I ended up by using a single yaml file as within a single file the modelling of the inheritance was feasible. Answering your question 2: You are quite right, unless you also want different model packages for each section. In my case I had a base API and a few derived APIs. I did want to mix them in a single package and, as a consequence, I needed to specify each package. But as I said: I abandoned the idea of multiple executions in the end, because I couldn't get the relations between the schemas correctly modelled. |
Hi It's kind of ugly, but if you keep the models and apiInterfaces in a separate project that you then import into your main project it's not too annoying, if you have 20+ yaml file my solution could be useful (tested on windows, not tested on linux) ant-build.xml
Mavento execute only with right profile
to execute with any profile (or starting profile)
If there was a smarter solution I would love it |
Hi, I was able to generate sources for two different specs. I added a second execution goal and specified different output directories for the specs using the option from the config: <executions>
<execution>
<id>api-1</id>
<inputSpec>${project.basedir}/api-1.yaml</inputSpec>
...
<output>${project.build.directory}/generated-sources/openapi-1</output>
</execution>
<execution>
<id>api-2</id>
<inputSpec>${project.basedir}/api-2.yaml</inputSpec>
...
<output>${project.build.directory}/generated-sources/openapi-2</output>
</execution>
<executions> |
For me, it only processes the first |
I think it is already supported with So the config can look like that:
|
Do you know how to use inputSpecRootDirectory with openapi-generator-cli |
@minesunny npm based generator works with that as well:
|
thank you,it does work |
This indeed works but all the generated classes are heaped onto a single package. Is there any way to have separate packages for separate source files? |
I have a project that needs to use multiple YAML files, but the
inputSpec
doesn't support this.I try a workaround solution by adding multiple executions of the maven plugin into the pom, this issue can be temporarily solved.
But in case I need to generate for many more files (YAML1, YAML2, YAML3,...), and in case my execution contains a big block of code like below:
The above workaround is not good, can you support us for a feature that supports multiple YAML files?
The text was updated successfully, but these errors were encountered: