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

ApiQueryParam should use @RequestParam value attribute for its name by default #106

Closed
djpotter77 opened this issue Apr 24, 2015 · 8 comments
Closed
Assignees
Labels
Milestone

Comments

@djpotter77
Copy link

@djpotter77 djpotter77 commented Apr 24, 2015

The ApiQueryParam annotation should use the Spring @RequestParam value attribute for its name attribute by default if it's present. It already uses other information (e.g. required) from the RequestParam annotation, but having to specify the same param name in both annotations seems unnecessary and error-prone.

For example, you currently have to do this:

public String sayHello(@ApiQueryParam(name = "personName", description = "The person to greet") @RequestParam(value = "personName", required = true) String personName) {

@fabiomaffioletti fabiomaffioletti self-assigned this Apr 27, 2015
@fabiomaffioletti
Copy link
Owner

@fabiomaffioletti fabiomaffioletti commented Apr 27, 2015

Can't reproduce. See SpringJSONDocScannerTest in project jsondoc-springmvc, which has a test to verify that the param name is taken from the RequestParam Spring's annotation.

@djpotter77
Copy link
Author

@djpotter77 djpotter77 commented Apr 29, 2015

The issues is that the name attribute of the ApiQueryParam annotation is required and doesn't have a default value, so you have to specify it in your code.

@fabiomaffioletti
Copy link
Owner

@fabiomaffioletti fabiomaffioletti commented Apr 29, 2015

Ok, I got it. Thank you.

@fabiomaffioletti fabiomaffioletti added this to the 1.1.14 milestone Apr 29, 2015
@cendy172
Copy link

@cendy172 cendy172 commented May 15, 2015

Hello, it seems the issue is fixed, but I cannot find the version 1.1.14 in maven repository.

@cendy172
Copy link

@cendy172 cendy172 commented May 15, 2015

the dependency is org.jsondoc:spring-boot-starter-jsondoc:1.1.14

@fabiomaffioletti
Copy link
Owner

@fabiomaffioletti fabiomaffioletti commented May 15, 2015

Version 1.1.14 is still under development, it's not released yet.

fabiomaffioletti pushed a commit that referenced this issue May 20, 2015
fmaffioletti
@Manfred73
Copy link

@Manfred73 Manfred73 commented Aug 17, 2015

I'm using version 1.1.16 and found that the following works:

@ApiQueryParam in combination with Spring's @RequestParam works ok. The name and required attributes are taken from @RequestParam.

However, the following doesn't work:

@ApiPathParam in combination with @PathParam (for required fields): I still have to specify the 'path parameter name' within the @ApiPathParam annotation, so it's not taking the default name from Spring's @PathParam.

@fabiomaffioletti
Copy link
Owner

@fabiomaffioletti fabiomaffioletti commented Aug 17, 2015

@PathParam is not part of Spring MVC. Did you mean @PathVariable?

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.