Exclude endpoints with brackets in swagger-ui

94 Views Asked by At

Let say i have the two following endpoints :

/api/v2/query/{param1}

/api/v2/query/filter 

I want to have in my swagger-ui only : /api/v2/query/{param1}

So i tried to filter :

@Bean
public GroupedOpenApi adminApi() {
    return GroupedOpenApi.builder().group("filteredGroup").pathsToMatch("/api/v2/query/{param1}").pathsToExclude("/api/v2/query/filter").build();
}

The issue is that i still see this endpoints :

/api/v2/query/filter 

How can I exclude it ? I think {param1} acts like *

1

There are 1 best solutions below

0
On

these endpoints are ambiguous because /query/filter and /query/{template} can resolve to the same endpoint. what are you trying to do with the /filter that can't be done with the template path?

From the looks of it, using a path /query is already causing you some issues where you should be using the query parameters (?) and then adding query parameter definitions in your OpenAPI description

something like this.. api/v2/cars?filter=

The Specification defines the behavior you have shown as non-compliant.

Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. In case of ambiguous matching, it’s up to the tooling to decide which one to use https://spec.openapis.org/oas/v3.0.3#paths-object