springdoc-openapi-demos icon indicating copy to clipboard operation
springdoc-openapi-demos copied to clipboard

gateway-service

Open 891877295 opened this issue 2 years ago • 1 comments

gateway-service

@Bean
	@Lazy(false)
	public List<GroupedOpenApi> apis(SwaggerUiConfigParameters swaggerUiConfigParameters, RouteDefinitionLocator locator) {
		List<GroupedOpenApi> groups = new ArrayList<>();
		List<RouteDefinition> definitions = locator.getRouteDefinitions().collectList().block();
		for (RouteDefinition definition : definitions) {
			System.out.println("id: " + definition.getId()+ "  "+definition.getUri().toString());
		}
		definitions.stream().filter(routeDefinition -> routeDefinition.getId().matches(".*-service")).forEach(routeDefinition -> {
			String name = routeDefinition.getId().replaceAll("-service", "");
			swaggerUiConfigParameters.addGroup(name);
			GroupedOpenApi.builder().pathsToMatch("/" + name + "/**").group(name).build();
		});
		return groups;
	}

groups why not add GroupedOpenApi ?

891877295 avatar May 07 '22 10:05 891877295

GroupedOpenApi build = GroupedOpenApi.builder()
                    .pathsToMatch("/" + name + "/**")
                    .group(name + "Group")
                    .build();
            groups.add(build);

But I need to filter some APIs to add addOpenApiMethodFilter( ) method, which doesn't work

GroupedOpenApi build = GroupedOpenApi.builder()
                    .pathsToMatch("/" + name + "/**")
                     .addOpenApiMethodFilter(method -> method.isAnnotationPresent(Operation.class))
                    .group(name + "Group")
                    .build()

jimmyqin avatar Jul 14 '22 05:07 jimmyqin

GroupedOpenApi build = GroupedOpenApi.builder()
                    .pathsToMatch("/" + name + "/**")
                    .group(name + "Group")
                    .build();
            groups.add(build);

但是我需要过滤一些API来添加addOpenApiMethodFilter( )方法,这不起作用

GroupedOpenApi build = GroupedOpenApi.builder()
                    .pathsToMatch("/" + name + "/**")
                     .addOpenApiMethodFilter(method -> method.isAnnotationPresent(Operation.class))
                    .group(name + "Group")
                    .build()

I have the same problem. No good examples have been found

mmm8955405 avatar Sep 05 '22 07:09 mmm8955405

Compete for the filtering of some APIs, not the whole! No solution found at present

mmm8955405 avatar Sep 05 '22 07:09 mmm8955405