swagger开放api定义不适用于micronaut jwt安全micronaut版本2.2.1

qvtsj1bj  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(331)

使用micronaut 2.2.1和jwt安全和swagger开放api。控制器定义未按如下所示工作

应用程序.yml

micronaut:
  application:
    name: demo
  security:
    enabled: true
    intercept-url-map:
      - pattern: /swagger-ui/**
        access:
          - isAnonymous()
  router:
    static-resources:
      swagger:
        paths: classpath:META-INF/swagger
        mapping: /swagger/**
      swagger-ui:
        paths: classpath:META-INF/swagger/views/swagger-ui
        mapping: /swagger-ui/**

控制器

@Secured(SecurityRule.IS_ANONYMOUS)
@Controller("/product")
public record ProductController(IProducer iProducer) {
    @Get(uri = "/{text}")
    public Single<String> get(String text){
        return iProducer.sendText(text);
    }
}

api.service.yml接口

openapi: 3.0.1
info:
  title: API service
  description: My API
  contact:
    name: Fred
    url: https://gigantic-server.com
    email: Fred@gigagantic-server.com
  license:
    name: Apache 2.0
    url: https://foo.bar
  version: "0.0"
paths:
  /product/{text}:
    get:
      operationId: get
      parameters:
      - name: text
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: get 200 response
          content:
            application/json:
              schema:
                type: string
dluptydi

dluptydi1#

我失踪了

intercept-url-map:
      - pattern: /swagger-ui/**
        httpMethod: GET
        access:
          - isAnonymous()
      - pattern: /swagger/**
        access:
          - isAnonymous()

相关问题