Skip to content

use MethodParameter#isOptional() instead of checking for Optional type #500

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

Merged
merged 1 commit into from
Mar 19, 2020

Conversation

zarebski-m
Copy link
Contributor

Check for whether a parameter is required now uses isOptional() method. This improves integration with JSR-305 annotations and Kotlin nullability.

In the following Kotlin example, parameter foo will be mandatory, but bar and baz not:

@RestController
@RequestMapping
class FooController {
    @GetMapping("test")
    fun testParams(
        @RequestParam foo: String,
        @RequestParam bar: String = "default",
        @RequestParam baz: String?
    ) {}
}

Similarly, parameter foo will correctly be rendered non-mandatory in this Java example:

@RestController
@RequestMapping
public class FooController {
    @GetMapping("test")
    void fooNullable(@RequestParam @Nullable String foo) {}
}

Check for whether a parameter is required now uses isOptional()
method. This improves integration with JSR-305 annotations
and Kotlin nullability.
@bnasslahsen
Copy link
Collaborator

Thank you @zarebski-m for your contribution.

@bnasslahsen bnasslahsen merged commit ce49d6f into springdoc:master Mar 19, 2020
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

Successfully merging this pull request may close these issues.

2 participants