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

Implementing ApiParamsImplicit #55

Closed
chrishuttonch opened this issue Apr 5, 2013 · 9 comments · Fixed by #353
Closed

Implementing ApiParamsImplicit #55

chrishuttonch opened this issue Apr 5, 2013 · 9 comments · Fixed by #353
Labels

Comments

@chrishuttonch
Copy link

Hi there,

I'm trying to use the @ApiParamsImplicit annotation. Has this been implemented?

@RequestMapping(method = RequestMethod.GET)
@ResponseBody
@ApiParamsImplicit({@ApiParamImplicit(name="X-Header-1", dataType = "String", paramType = "header"), @ApiParamImplicit(name="X-Header-2", dataType = "String", paramType = "header")})
public RestApiResponse getUser(@RequestParam("userId") String userId) throws UserNotFoundException, UserDeletedException, InvalidUserException, InvalidUserFieldException, InvalidTokenException {
// code
    }
@dilipkrish
Copy link
Member

@chrishuttonch Unfortunately thats not been implemented yet. Also the swagger-ui support for this was spotty when I looked at it a while ago. A quick google lead me to this ... which leads me to think that it might easier to configure on the UI than have the swagger ui infer it from the documentation.

@chrishuttonch
Copy link
Author

I think there are two parts to this issue, the use of headers and adding extra params to the swagger ui to describe the api. Basically, I have a spring filter that grabs both "X-Header-1" and "X-Header-2" and adds a Request Parameter for the userId to the request before hitting the controller. I would like to describe the need for these two headers via something like the @ApiParamsImplicit.

@dilipkrish
Copy link
Member

@chrishuttonch I think it would be especially useful if supported @RequestHeader annotation out of the box. As such supporting @ApiParamsImplicit is useful too, but in which case you are essentially have the knowledge of the fact that there are headers coming in, as in your case, in a filter. Its a useful feature regardless, we just need to think of how to implement it, especially in the light of the hypermedia support thats introduced in spring mvc

@durbon
Copy link

durbon commented Apr 11, 2013

I have a problem with the definitions controller

 @Controller
 @RequestMapping ("/{country}/ad/{adId}/list")

I'd like to use @ApiParamsImplicits above my method because I use @Valid annotations with object AdModel

  @ApiParamsImplicit( @ApiParamImplicit(name ="country", value = "Country object that needs to be selected country api", required = true, dataType = "String", paramType = "body")) 
  public @ResponseBody Object listMultimediaByAdId(HttpServletRequest request, HttpServletResponse response, @ApiParam @Valid AdModel adModel)

The definition of adModel:

public class AdModel {


private String country;

private Integer adId;

 ...
 }

@dilipkrish
Copy link
Member

@durbon May be I dont understand your question correctly. Are you trying to update your AdModel object based on your url path parameters?

Are you looking for something like this?

@durbon
Copy link

durbon commented Apr 12, 2013

yes, I'd like to show on swagger documentation console into method form two parameters: country and adId.

These parameters updates my adModel based on these url path parameters, but I don't know how I can indicate by annotations for documentation.

thanks

@kldavis4
Copy link

so @dilipkrish is @RequestHeader not currently supported? If not, is there a feature request for it?

@dilipkrish
Copy link
Member

@kldavis4 Thats on the todo list and this is the TODO item :)

@kldavis4
Copy link

@dilipkrish great, thanks, I will watch for it

dilipkrish added a commit that referenced this issue Jun 20, 2013
Added support for @RequestHeader

partially fixes issue #55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants