micronaut-core icon indicating copy to clipboard operation
micronaut-core copied to clipboard

Micronaut swagger ui not working with micronaut-security dependencies

Open subash89 opened this issue 1 year ago • 8 comments

Expected Behavior

Swagger UI to work.

Actual Behaviour

Swagger UI not working when micronaut security modules added as dependency.

Steps To Reproduce

  1. Created a simple app with micronaut jaxrs + swagger. And Swagger UI Working at http://localhost:8080/swagger/views/swagger-ui

  2. Now Add micronaut security jwt dependencies.

  3. Try mvn mn:run and access swagger ui again. Swagger ui not showing up.

Seems some dependency conflict that prevents jaxrs swagger module getting registered. Hence UI not working.

Environment Information

JDK 11.

Example Application

https://github.com/subash89/public-samples/tree/main/hellojaxrs

Version

3.8.4

subash89 avatar Feb 28 '23 16:02 subash89

probably the UI is locked down and secured hence you can't access it?

graemerocher avatar Feb 28 '23 17:02 graemerocher

@graemerocher In the example application I provided, first thing I did was to get swagger UI working on a simple micronaut cli generated jaxrs project. And I can access the swagger UI without any issue.

Then only thing I just did was add micronaut-security-jwt dependency and annotation processor to the pom. That's it. And swagger ui not showing up.

In this reference project to reproduce the issue https://github.com/subash89/public-samples/tree/main/hellojaxrs You can take out micronaut security dependency and its annotation processor. And swagger ui will come up without any issue on http://localhost:8080/swagger/views/swagger-ui

subash89 avatar Feb 28 '23 17:02 subash89

@graemerocher I just corrected https to http in swagger ui url, which was a typo to make sure if that's what you meant. Looks like a dependency conflict or one overpower the other. Any thoughts?

subash89 avatar Feb 28 '23 18:02 subash89

@graemerocher I corrected something in steps to reproduce from "now" to "not" which I think is the one mislead you. My bad. So issue stands as originally in the subject and above comments.

subash89 avatar Mar 01 '23 15:03 subash89

I'm too this problem. Some return about this issue?

davidrtpereira avatar Aug 23 '23 18:08 davidrtpereira

I was able to allow the access by defining these values, especially the intercept-url-map. The full source code can be found here (application.yaml)

swagger-ui:
  enabled: true

micronaut:
  openapi:
    views:
      spec: rapidoc.enabled=true
  router:
    static-resources:
      swagger:
        paths: classpath:META-INF/swagger
        mapping: /swagger/**
      swagger-ui:
        paths: classpath:META-INF/swagger/views/swagger-ui
        mapping: /swagger-ui/**
    intercept-url-map:
      - pattern: /swagger/**
        http-method: GET
        access:
          - isAnonymous()
      - pattern: /swagger-ui/**
        http-method: GET
        access:
          - isAnonymous()

Documentation about intercept-url-map

Swagger UI working image

image

FerroEduardo avatar Nov 06 '23 23:11 FerroEduardo

@graemerocher You can close it, it's not a bug

altro3 avatar Feb 18 '24 08:02 altro3

@graemerocher ping

altro3 avatar Mar 16 '24 05:03 altro3