Skip to content

Consider more fine-grained controle in the API Versioning such as filtering on full path #35776

@teunstout

Description

@teunstout

The new versioning is awesome, but it may not work with existing projects. I am used to versioning such as /v1 as many others. In my current project, I was using this way of versioning and wrote a custom ApiVersionParser.

public class ApiVersioningParser implements ApiVersionParser {

    @Override
    public Comparable parseVersion(String version) {
        // Remove the "v" prefix
        if (version.startsWith("v") || version.startsWith("V")) {
            version = version.substring(1);
        } else {
           // Default versions for paths like favicon.icon
            version = "1";
        }

        return version;
    }
}

Initially, nothing seemed wrong here until I started using another popular framework called OpenAPI. What ended up happening is that OpenAPI also likes the same versioning strategy. That meant that all Swagger v3 endpoints were suddenly mapped incorrectly, for example /v3/api-docs. Up until now, everyone has their own way of implementing strategies; these kinds of conflicts are bound to happen. To prevent this, I thought we could maybe add more fine-grained filtering. Maybe not only on versioning, but also being able to ignore certain paths based on something like a regex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions