Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

jaxrs-cxf-client - Generate error in @ApiResponse when the response class is not specified #7853

Closed
liberoguerra opened this issue Mar 16, 2018 · 5 comments

Comments

@liberoguerra
Copy link

liberoguerra commented Mar 16, 2018

Description

ISSUE:
I use language jaxrs-cxf-client and inside json file there is not specified a response class for HTTP Status code 401.
After generation, the api class contains several errors about @ApiResponse. In detail the plugin generates this line in error "response = .class"

API class generated (Java code)

...
	@ApiResponses(value = {
		@ApiResponse(code = 200, message = "OK", response = ResponseBody.class),
		@ApiResponse(code = 401, message = "Unauthorized", response = .class)
	})
...
Swagger-codegen version

2.2.3 and 2.3.1

Swagger declaration file content
...
	"responses":{
		"200":{
			"description":"OK",
			"schema":{
				"$ref":"#/definitions/ResponseBody"
			}
		},
		"401":{
			"description":"Unauthorized"
		}
	}
...
Command line used for generation

I use maven generate goals with this configuration:

<configuration>
	<inputSpec>scr/main/resources/file.json</inputSpec>
	<language>jaxrs-cxf-client</language>
	<configOptions>
		<sourceFolder>codegen</sourceFolder>
		<apiPackage>com.example.rest.api</apiPackage>
		<modelPackage>com.example.rest.model</modelPackage>
		<generateApiTests>false</generateApiTests>
		<generateModelTests>false</generateModelTests>
		<useJaxbAnnotations>true</useJaxbAnnotations>
	
	</configOptions>
</configuration>
@jmini
Copy link
Contributor

jmini commented Mar 21, 2018

Thank you for this report. I have proposed a fixed for the 2.x version here: #7886.

I have taken this opportunity to work on a port of jaxrs-cxf-client generator for v3 (I will link the corresponding PR here).

@jmini
Copy link
Contributor

jmini commented Mar 22, 2018

Fix for v3: swagger-api/swagger-codegen-generators#47

@jmini
Copy link
Contributor

jmini commented Mar 25, 2018

In v3, the swagger-codegen-generators jar now contains the fix.

The next swagger-codegen build will produce a cli jar that contains the lattest version of swagger-codegen-generators. You can also build it locally as I did to run bin/jaxrs-cxf-client-petstore.sh which demonstrates that everything works as expected: see #7904

You are writting that you are using maven. I guess that if you run your build with -U, using version 3.0.0-SNAPSHOT of the swagger-codegen-maven-plugin maven will also fetch io.swagger:swagger-codegen-generators:1.0.0-SNAPSHOT

You can give it a try and report feedback here.

@jmini
Copy link
Contributor

jmini commented Mar 28, 2018

@HugoMario @webron, can you please add cxf-client and issue labels? Depending on if #7886 gets merged or not the version will be 2.4.0 or 3.0.0

@jmini
Copy link
Contributor

jmini commented Apr 12, 2018

Both PR have been fixed for v2 and v3.
@webron, @HugoMario or someone else, can you add "jaxrs-cxf-client" and "issue" Labels? Milestone is "2.4.0".

This issue can be closed.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants