Skip to content
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

Requesting new configOption for JavaJAXRSS to generate or not both RestApplication.java and RestResourceRoot.java #20287

Open
WhiskasChaton opened this issue Dec 10, 2024 · 2 comments

Comments

@WhiskasChaton
Copy link

WhiskasChaton commented Dec 10, 2024

Is your feature request related to a problem? Please describe.

I'm working on a project where i need to generate several swagger specs through different config :

<executions>
  <execution>
      <id>ex1</id>
      <goals>
          <goal>generate</goal>
      </goals>
      <configuration>
          <inputSpec>
              ${project.basedir}/spec1.yaml
          </inputSpec>
          <modelPackage>path1.api</modelPackage>
          <apiPackage>path1.model</apiPackage>
      </configuration>
  </execution>
<execution>
      <id>ex2</id>
      <goals>
          <goal>generate</goal>
      </goals>
      <configuration>
          <inputSpec>
              ${project.basedir}/spec2.yaml
          </inputSpec>
          <modelPackage>path2.api</modelPackage>
          <apiPackage>path2.model</apiPackage>
      </configuration>
  </execution>

Problem is that both execution generates RestApplication.java and RestResourceRoot.java (which are not useful to my project...) , and having multiple of those give me the following error at build :

java.lang.RuntimeException:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.resteasy.reactive.common.deployment.ResteasyReactiveCommonProcessor#handleApplication threw an exception: java.lang.RuntimeException: More than one Application class: [path1.RestApplication, path2.RestApplication]

Problem exists since #17645

Describe the solution you'd like

Please introduce an new configOption (true by default to remain backward compatible) to enable generation of those files or not here :

https://github.com/OpenAPITools/openapi-generator/blame/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java#L178
https://github.com/OpenAPITools/openapi-generator/blame/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaJAXRSSpecServerCodegen.java#L187

Describe alternatives you've considered

Currently, as work-around, i have to delete the generated files after it has been generated
Example for people having the same issue :

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-antrun-plugin</artifactId>
	<version>1.7</version>
	<executions>
		<execution>
			<phase>generate-sources</phase>
			<goals>
				<goal>run</goal>
			</goals>
			<configuration>
				<tasks>
					<delete>
						<fileset dir="${project.build.directory}\path1\" includes="RestApplication.java"/>
						<fileset dir="${project.build.directory}\path1\" includes="RestResourceRoot.java"/>
						<fileset dir="${project.build.directory}\path2\" includes="RestApplication.java"/>
						<fileset dir="${project.build.directory}\path2\" includes="RestResourceRoot.java"/>
					</delete>
				</tasks>
			</configuration>
		</execution>
	</executions>
</plugin>
@wing328
Copy link
Member

wing328 commented Dec 10, 2024

to skip certain files from being generated, what about using .openapi-generator-ignore?

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#ignore-file-format

(there's an option to pre-populate this file)

@WhiskasChaton
Copy link
Author

WhiskasChaton commented Dec 11, 2024

to skip certain files from being generated, what about using .openapi-generator-ignore?

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#ignore-file-format

(there's an option to pre-populate this file)

I wasn't aware of this feature and it suits perfectly what I needed

Note that I also needed to add the <ignoreFileOverride>.openapi-generator-ignore</ignoreFileOverride> in the maven plugin configuration to make it works on top of the .openapi-generator-ignore file with the following
**/RestApplication.java
**/RestResourceRoot.java

Thanks for the tips !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants