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

Add global customizer and filters #1616

Conversation

christophejan
Copy link

Add GlobalOpenApiCustomiser GlobalOperationCustomizer and GlobalOpenApiMethodFilter that will be applied to :

  1. Default OpenAPI description
  2. GroupedOpenApi declared through spring properties (yml)
  3. GroupedOpenApi declared programmatically like :
@Bean
public GroupedOpenApi mygroup(GroupedOpenApi.Builder builder) {
    return builder
        .group("mygroup")
        [...]
        .build();
}

The PR is composed by 4 commits that are more easy to review one by one. Only the last one add global customizer/filter.

Here some details on the commits :

  1. Extra assertions on default group (on current behavior) :
    I would warn about a preexisting suspicious behavior when springdoc.use-management-port=true, querying nonexistent groups return a 404 with Webflux but a 500 with MVC.
  2. Declare the most specific return type possible on some bean declaration :
    This is safer for components that implement several interfaces or for components potentially referred to by their implementation type (see Declaring a bean tip on spring core documentation)
  3. Interact only with bean definition during bean registration phase :
    This will prevent any premature bean instantiation, violating the container and causing unintended side-effects (see BeanFactoryPostProcessor documentation). In concrete terms :
    • register bean definition rather than bean instance
    • do not require GroupedOpenApi beans instances anymore for SpringdocActuatorBeanFactoryConfigurer bean registrations
  4. Add global customizers and filters

This is safer for components that implement several interfaces or for
components potentially referred to by their implementation type (see
'Declaring a bean' on spring core documentation)
- register bean definition rather than bean instance
- do not require GroupedOpenApi beans instances anymore for
SpringdocActuatorBeanFactoryConfigurer bean registrations

This will prevent any premature bean instantiation, violating the
container and causing unintended side-effects (see
BeanFactoryPostProcessor documentation)
@bnasslahsen bnasslahsen merged commit da735b0 into springdoc:master Apr 20, 2022
@bnasslahsen
Copy link
Contributor

@christophejan,

Thank you for your contribution to the project.
If you have any other technical code enhancements, please feel free to propose a separate PR.

@christophejan christophejan deleted the feature/global-customizer-and-filters branch April 20, 2022 13:29
@christophejan
Copy link
Author

@bnasslahsen, thank you for all your hard work on Springdoc

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.

None yet

2 participants