swagger-api / swagger-api/swagger-ui

Empty /swagger-ui.html - 404 /typography.css

Open
#6,580 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

  • Swagger-ui version: 2.7.0
  • Swagger-core version: 2.7.0
Content & configuration

Project tree (multi-module):

.
├── api
│   ├── build.gradle
│   └── src
│       └── main
│           └── java
│               └── com
│                   └── example
│                       └── api
│                           └── controllers
│                               ├── BarController.java
│                               └── FooController.java
├── build.gradle
├── app
│   ├── build.gradle
│   ├── settings.gradle
│   └── src
│       └── main
│           ├── java
│           │   └── com
│           │       └── example
│           │           └── app
│           │               ├── AppApplication.java
│           │               └── security
│           │                   └── WebSecurityConfiguration.java
│           │               └── swagger
│           │                   └── Swagger2Configuration.java
│           └── resources
│               └── application.properties
└── core
    ├── build.gradle
    └── src
        └── main
            └── java
                └── com
                    └── example
                        └── core
                            ├── model
                            │   └── Foo.java
                            ├── repository
                            │   └── FooRepository.java
                            └── service
                                └── FooService.java


Swagger2Configuration:

@Configuration
@EnableSwagger2
public class Swagger2Configuration {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.example")) - This didn't work either.
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
}

configure function from WebSecurityConfiguration:

@Override
    public void configure(WebSecurity web) throws Exception {
        web
                .ignoring()
                .antMatchers("/v2/api-docs",
                        "/configuration/ui",
                        "/swagger-resources/**",
                        "/configuration/security",
                        "/swagger-ui.html",
                        "/webjars/**");
    }

AppApplication:

@ComponentScan("com.example")
@EnableJpaRepositories("com.example.core.repository")
@EntityScan("com.example.core.model")
@SpringBootApplication
public class AppApplication {
    public static void main(String... args) {
        SpringApplication.run(AppApplication.class, args);
    }
}
Screenshots

Screenshot 2020-10-31 at 7 55 03 PM

Screenshot 2020-11-02 at 3 39 06 PM

I have a project that has three modules: api, app, and core. Endpoints are placed in the api module while service, model, and repository are placed in the core module. All configuration and @SpringBootApplication are placed in the app module.

I am able to see my endpoints and models on http://localhost:8080/v2/api-docs, but http://localhost:8080/swagger-ui.html shows nothing due to /typography.css - 404. How can I fix this issue?

Thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the empty /swagger-ui.html response and the /typography.css 404 with the provided multi-module Spring Boot setup. Review Swagger2Configuration, WebSecurityConfiguration, AppApplication, and the /v2/api-docs endpoint to determine whether the failure is in Swagger UI assets or application routing. Done means the UI loads its CSS and displays the documented endpoints without the 404.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, javascript, spring-boot
Domain
backend, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.