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

[Spring] fix <async>false</async> in the Maven plugin #1179

Merged
merged 4 commits into from
Oct 5, 2018
Merged

[Spring] fix <async>false</async> in the Maven plugin #1179

merged 4 commits into from
Oct 5, 2018

Conversation

raghuraman1
Copy link
Contributor

@raghuraman1 raghuraman1 commented Oct 5, 2018

Hi,
I am using the openapi-generator-maven-plugin with these versions: 3.3.1-SNAPSHOT (thats master ).
I came across this bug. Please see code snippet below of the pom.xml alongwith my suggestions for the fix..

I have also noted another smaller issue unrelated to this.
Thanks.
R
Please note value of asynch: false.

            <plugin>
                          <groupId>org.openapitools</groupId>
			<artifactId>openapi-generator-maven-plugin</artifactId>
			<version>${openapi.codegen.version}</version>
			<executions>
				<execution>
					<id>common</id>
					<goals>
						<goal>generate</goal>
					</goals>
					<configuration>
                                              <inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
						<modelPackage>com.example.api.models</modelPackage>
						<apiPackage>com.example.api</apiPackage>
						<output>${project.basedir}</output>					
						<language>spring</language>
						<invokerPackage>com.example.api</invokerPackage>
						<basePackage>com.example.api</basePackage>
						<withXml>true</withXml>
						<configOptions>
						
							<artifactId>foo</artifactId>
							<artifactDescription>Test API</artifactDescription>
							<title>Test API</title>
							<artifactUrl>https://api.example.com</artifactUrl>
							<groupId>com.example.api</groupId>
							<artifactVersion>1</artifactVersion>								
							<sourceFolder>src/gen/java/main</sourceFolder>
							<serializableModel>true</serializableModel>
							<dateLibrary>java8</dateLibrary>
							<java8>true</java8>
							<async>false</async>
							<library>spring-boot</library>		
							<delegatePattern>true</delegatePattern>
							<useBeanValidation>true</useBeanValidation>
							<useOptional>true</useOptional>	
							<hideGenerationTimestamp>true</hideGenerationTimestamp>								
						</configOptions>							
					</configuration>
				</execution>
			</executions>
		</plugin>

`

For the above configuration in openapi-generator\modules\openapi-generator\src\main\resources\JavaSpring\methodBody.mustache an expression of
{{#async}}CompletableFuture.completedFuture({{/async}} should resolve to empty. Unfortunately : In openapi-generator\modules\openapi-generator\src\main\java\org\openapitools\codegen\DefaultGenerator.java the value of async in this.config.additionalProperties() is a string and not a boolean.

This causes wrong code generation.

I am providing a immediate fix for this:
Please see the code difference in openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java.

@raghuraman1 raghuraman1 changed the title Pushing the improved fix JAVA Spring <async>false</async> Pushing the improved fix Oct 5, 2018
@wing328
Copy link
Member

wing328 commented Oct 5, 2018

As discussed, later we'll need to fix other options as well (in Spring or other generators) by doing something similar to

if (additionalProperties.containsKey(Constants.AUTOMATIC_HEAD_REQUESTS)) {

@wing328 wing328 merged commit b0dfcf2 into OpenAPITools:master Oct 5, 2018
@wing328 wing328 changed the title JAVA Spring <async>false</async> Pushing the improved fix [Spring] fix <async>false</async> in the Maven plugin Oct 15, 2018
@wing328
Copy link
Member

wing328 commented Oct 16, 2018

@raghuraman1 thanks again for the fix, which has been included in the v3.3.1 release: https://twitter.com/oas_generator/status/1052020299821080577

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
…ls#1179)

* Pushing the improved fix

* reverting the unrelated change

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

Successfully merging this pull request may close these issues.

None yet

2 participants