Astro企业应用 AstroPro-swagger标签使用指南:6、x-controller-annotations

时间:2025-02-12 15:02:26

6、x-controller-annotations

作用

添加指定的注解。

该标签用于在api实现类上添加指定的注解。

标签值类型

String

使用位置

  • x-class-annotations(定义在swagger最外层,所有的api实现类上都会添加指定注解)
  • components.schemas.model.x-class-annotations(定义在指定tag下,只会在具体api实现类上添加指定注解)

使用示例

swagger: "2.0"info:  description: ""  version: "v1"  title: "testSwagger"  termsOfService: "http://www.coarl.org/service.html"host: "git.huawei.com"basePath: "/testswagger"x-imports:   - "org.springframework.context.annotation.Profile;" # 使用的时候结尾一定要带上 ;x-controller-annotations: # 此处添加的注解,在所有生成的api实现类上都会添加,需要使用x-imports手动导入相应的包  - '@Profile("test")'

使用效果:

使用前:

public class CardApiController implements CardApi {     ------}

使用后:

@Profile("test")   // 通过x-controller-annotations引入的注解public class CardApiController implements CardApi {     ------}
support.huaweicloud.com/usermanual-astropro/astropro_05_0143.html