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

The same RequestMapping with different params #4060

Open
YeJiaL opened this issue Mar 29, 2023 · 3 comments
Open

The same RequestMapping with different params #4060

YeJiaL opened this issue Mar 29, 2023 · 3 comments
Labels

Comments

@YeJiaL
Copy link

YeJiaL commented Mar 29, 2023

image
image

enableUrlTemplating(true)

when set enableUrlTemplating true, the url is incorrect, unable to post the correct url

@geetnsh2k1
Copy link

geetnsh2k1 commented Mar 29, 2023

Hi @YeJiaL, According to best practices, it is recommended to define all possible query parameters for a particular endpoint at the same level. To do this, you can use the @RequestParam annotation with the name attribute set to the name of the query parameter and required attribute set to false for each parameter.

By doing this, the Swagger UI will automatically detect the query parameters and generate the user interface accordingly.

@GetMapping(path = "items")
@ApiOperation(value = "Find items by name or description", response = ItemSearchResponse.class)
public ResponseEntity<?> searchItemsByName(@RequestParam("name", required=false) String name, @RequestParam("description", required=false) String description) {
       // add checks for the case when query params were not sent in the api call
       // you can use Objects.isNull(name)
}

@YeJiaL
Copy link
Author

YeJiaL commented Mar 30, 2023

@geetnsh2k1 when i use @GetMapping(params="key1=value1") on method ,and set enableUrlTemplating true, when i open the swagger UI ,i cannot test the urlMethod from the UI,becasuse the method has the additional param like xxx) .
jsut like picture show ,it has namespaceid)=""

@stale
Copy link

stale bot commented Aug 12, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants