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

Jaxrs @BeanParam isn't working #618

Closed
avanathan opened this issue Jul 15, 2014 · 4 comments
Closed

Jaxrs @BeanParam isn't working #618

avanathan opened this issue Jul 15, 2014 · 4 comments

Comments

@avanathan
Copy link

We are using Swagger in our Jersey project

Gradle : com.wordnik:swagger-jersey2-jaxrs_2.10:1.3.7
Jersey : 2.9

/**
 * HTTP GET method for employee of a given ID
 *
 * @param employeeBeanParam EmployeeBeanParam
 * @return Employee
 */
@GET
@Path("/employees")
@ApiOperation(value = "Find employee by employee-id", notes = "More notes about find employee by employee-id", response = Employee.class)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "Ok", response = Employee.class)})
public Response getEmployee2(@BeanParam EmployeeBeanParam employeeBeanParam) {
}

/** EmployeeBeanParam.java**/
public class EmployeeBeanParam {
@PathParam(KeyImpl.Constants.EMPLOYEE_ID_VALUE)
String employeeId;

@HeaderParam("If-Match")
String ifMatch;

public String getEmployeeId() {
    return employeeId;
}

public void setEmployeeId(String employeeId) {
    this.employeeId = employeeId;
}

public String getIfMatch() {
    return ifMatch;
}

public void setIfMatch(String ifMatch) {
    this.ifMatch = ifMatch;
}

}

Below is the snapshot of SwaggerUI :

beanparam

@webron
Copy link
Contributor

webron commented Jul 15, 2014

Can you share your web.xml? Looking for the swagger configuration.

@avanathan
Copy link
Author

We use Spring as well. Here is the BeanConfig

<bean id="swaggerConfig" class="com.wordnik.swagger.jaxrs.config.BeanConfig">
    <property name="resourcePackage" value="com.intuit.ems"/>
    <property name="version" value="${swagger.api.version}"/>
    <property name="basePath" value="${swagger.basepath.url}"/>
    <property name="description" value="Company Employee Paycheck Services"/>
    <property name="scan" value="true"/>
</bean>

We haven't configured Swagger through web.xml. We use Jersey auto scanning with @Provider annotation. In Jersey ResourceConfig here is the package used for scanning :

packages("com.wordnik.swagger.jersey.listing");

@webron
Copy link
Contributor

webron commented Jul 15, 2014

Try adding this property to the bean:

<property name="apiReader" value="com.wordnik.swagger.jersey.JerseyApiReader"/>

@avanathan
Copy link
Author

Awesome!!! That fixed the problem. Thank you very much!

@webron webron closed this as completed Jul 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants