spring-cloud / spring-cloud/spring-cloud-gateway

Fallthrough proxy with Swagger-UI

Open
#3,738 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feedback-provided
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

I am using the latest version of the following dependencies:

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>3.4.3</version>
	<relativePath/>
</parent>
[...]
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
	<groupId>org.springdoc</groupId>
	<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
	<version>2.8.5</version>
</dependency>

And the following configuration in application.yml

spring:
  cloud:
    gateway:
      routes:
        - id: legacy_proxy
          uri: http://localhost:8000
          predicates:
            - Path=/**
          filters:
            - RewritePath=/(?<segment>.*), /legacy-app-1/${segment}
          order: 1000

I have a controller:

@RestController
@RequestMapping("/example")
public class ExampleController {
    @GetMapping()
    public String getString() {
        return "test";
    }
}

When this application is running I can make requests to /example which hits the controller endpoint, and I can make requests to /some/other/path which proxies the request correctly to http://localhost:8000/legacy-app-1/some/other/path, but in this configuration I can not access /swagger-ui/index.html. Curiously not all Swagger endpoints are affected, I can access /v3/api-docs.

If I change to Path=/legacy/** then Swagger UI works correctly.

Any idea why the /swagger-ui/index.html path is affected like this?

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 routes in application.yml with Path=/** and then with Path=/legacy/**. Compare handling of /swagger-ui/index.html, /v3/api-docs, /example, and /some/other/path to trace the fallthrough proxy interaction. Done means the cause is identified and Swagger UI remains accessible without breaking the controller or legacy proxy paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.