Skip to content

[REQ][Spring] Be able to filter with API version #8545

Open
@Zomzog

Description

@Zomzog

Is your feature request related to a problem? Please describe.

I need to generate multiple versions of an API handled by the same service. The version can be provided by a custom header or a custom query param. So I can't use Media-type tricks.

My need is to use the spring capacity of filtering (example can be found here).

This will allow us to generate and deploy each version of each contract without conflict and manage.

Describe the solution you'd like

I want to be able to do something like this

            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>5.0.1-SNAPSHOT</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>src/main/resources/openapi.yaml</inputSpec>
                            <generatorName>spring</generatorName>
                            <apiPackage>org.openapitools.api</apiPackage>
                            <modelPackage>org.openapitools.model</modelPackage>
                            <generateSupportingFiles>false</generateSupportingFiles>
                            <configOptions>
                                <versionType>HEADER</versionType>
                                <versionToken>X-CUSTOM-VERSION</versionToken>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

and get

    @GetMapping(
        value = "/ponies",
        produces = { "application/json" },
        headers = "X-CUSTOM-VERSION=1.0.0"
    )

Describe alternatives you've considered

Media-type and path have been excluded. I don't manage to specify this kind of filtering directly in the OAS3 file.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions