Skip to content

get wrong config when upgrade 1.2.34 #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
evil0th opened this issue Apr 19, 2020 · 1 comment
Closed

get wrong config when upgrade 1.2.34 #584

evil0th opened this issue Apr 19, 2020 · 1 comment

Comments

@evil0th
Copy link

evil0th commented Apr 19, 2020

Describe the bug

  • visit gateway service url /v3/api-docs/swagger-config return a wrong urls when i upgraded springdoc to 1.2.34:
{
    "configUrl": "/v3/api-docs/swagger-config", 
    "oauth2RedirectUrl": "http://localhost:8060/v3/api-docs/swagger-config/webjars/swagger-ui/oauth2-redirect.html", 
    "url": "/v3/api-docs", 
    "validatorUrl": ""
}

Btw, the right urls is :

{
    "configUrl": "/v3/api-docs/swagger-config", 
    "oauth2RedirectUrl": "http://localhost:8060/v3/api-docs/swagger-config/webjars/swagger-ui/oauth2-redirect.html", 
    "urls": [
        {
            "url": "/v3/api-docs/department", 
            "name": "department"
        }, 
        {
            "url": "/v3/api-docs/employee", 
            "name": "employee"
        }, 
        {
            "url": "/v3/api-docs/organization", 
            "name": "organization"
        }
    ], 
    "validatorUrl": ""
}

To Reproduce
Steps to reproduce the behavior:

Expected behavior

# GroupedOpenApi.java L52
	SwaggerUiConfigProperties.addGroup(this.group);

# SwaggerUiConfigProperties.java L149
	private static Set<SwaggerUrl> urls = new HashSet<>();

# SwaggerUiConfigProperties.java L155
	public static void addGroup(String group) {
		SwaggerUrl swaggerUrl = new SwaggerUrl(group);
		urls.add(swaggerUrl);
	}

Screenshots
wrong:
wrong

right:
image

@bnasslahsen
Copy link
Collaborator

Hi @Liaow,

Hi

Before, there was a high coupling between GroupedOpenApi and SwaggerUiConfigProperties, which is ugly, using static references and difficult to maintain.
Here is a better configuration for your gateway, while you upgrade to v1.3.4:

@Bean
public List<GroupedOpenApi> apis(SwaggerUiConfigProperties swaggerUiConfigProperties) {
	List<GroupedOpenApi> groups = new ArrayList<>();
	List<RouteDefinition> definitions = locator.getRouteDefinitions().collectList().block();
	definitions.stream().filter(routeDefinition -> routeDefinition.getId().matches(".*-service")).forEach(routeDefinition -> {
		String name = routeDefinition.getId().replaceAll("-service", "");
		swaggerUiConfigProperties.addGroup(name);
		GroupedOpenApi.builder().pathsToMatch("/" + name + "/**").setGroup(name).build();
	});
	return groups;
}
 

@springdoc springdoc deleted a comment from an0nh4x0r Nov 21, 2022
@springdoc springdoc locked as resolved and limited conversation to collaborators Nov 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants