Skip to content

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

Closed
@AlexanderBartash

Description

@AlexanderBartash

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions