Skip to content

io.swagger.v3.oas.annotations.Webhook does not work when defined on the method level #2998

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

Open
AlexanderBartash opened this issue May 17, 2025 · 0 comments

Comments

@AlexanderBartash
Copy link

AlexanderBartash commented May 17, 2025

Describe the bug
The io.swagger.v3.oas.annotations.Webhook has @Target({METHOD, ANNOTATION_TYPE})

/**
 * The annotation may be used to define a method as an OpenAPI Webhook.
 *
 * @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.1.1/versions/3.1.1.md#oas-webhooks">Webhook (OpenAPI specification)</a>
 * @see io.swagger.v3.oas.annotations.OpenAPIDefinition
 **/
@Target({METHOD, ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@OpenAPI31
public @interface Webhook {
    /**
     * Provides the name related to this webhook.
     * @return webhook name
     */
    String name();

    /**
     * Provides the operation related to this webhook.
     * @return webhook operation
     */
    Operation operation();

Which is a bit misleading because SpringDoc seems to be searching only for io.swagger.v3.oas.annotations.Webhooks on the class level and never tries to resolve annotations on the method level.

To Reproduce
Steps to reproduce the behavior:

  • Try to use io.swagger.v3.oas.annotations.Webhook on the method level, as per its target .

Expected behavior

  • Either log a warning that the annotation should be on the class level or support them on the method level too.

Workaround

  • Use io.swagger.v3.oas.annotations.Webhooks on class level on any Spring Bean and add the webhooks as its child (nested) io.swagger.v3.oas.annotations.Webhook annotations.
@AlexanderBartash AlexanderBartash changed the title io.swagger.v3.oas.annotations.Webhook does not work when defined at method level io.swagger.v3.oas.annotations.Webhook does not work when defined on method level May 17, 2025
@AlexanderBartash AlexanderBartash changed the title io.swagger.v3.oas.annotations.Webhook does not work when defined on method level io.swagger.v3.oas.annotations.Webhook does not work when defined on the method level May 17, 2025
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

No branches or pull requests

1 participant