San Jaisy
San Jaisy

Reputation: 17048

Swagger open API definition not working with Micronaut JWT security Micronaut version 2.2.1

Using the Micronaut 2.2.1 with JWT security and swagger open API. The controller definition is not working as shown below

enter image description here

Application.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/**

Controller

@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: [email protected]
  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

Upvotes: 0

Views: 1084

Answers (1)

San Jaisy
San Jaisy

Reputation: 17048

I was missing

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

Upvotes: 2

Related Questions