Skip to content
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

ApplicationPath not added by swagger-maven-plugin #3060

Closed
martin-v-ottesen opened this issue Dec 20, 2018 · 6 comments
Closed

ApplicationPath not added by swagger-maven-plugin #3060

martin-v-ottesen opened this issue Dec 20, 2018 · 6 comments

Comments

@martin-v-ottesen
Copy link

io.swagger.core.v3 swagger-maven-plugin 2.06

Does not add the ApplicationPath in the openapi files.

@deBFM
Copy link

deBFM commented Mar 27, 2019

Having the same problem with 2.0.7

@wallaroo
Copy link

same for 2.0.8

@webron
Copy link
Contributor

webron commented Jul 24, 2019

Please consider submitting a PR.

@borramTAS
Copy link

same for 2.1.6

@adagios
Copy link
Contributor

adagios commented Mar 11, 2021

To mitigate this issue I ended up creating a ReaderListener that modifies the Paths and adds the needed top level path.

Something like:

@OpenAPIDefinition //just so that it's picked up by the class scanner
public class BasePathModifier implements ReaderListener {

    @Override
    public void beforeScan(OpenApiReader openApiReader, OpenAPI openAPI) {
    }

    @Override
    public void afterScan(OpenApiReader openApiReader, OpenAPI openAPI) {
        Paths paths = openAPI.getPaths();
        Paths modifiedPaths = new Paths();

        paths.forEach((path, pathItem) -> {
            modifiedPaths.addPathItem("/SOME_BASE_PATH" + path, pathItem);
        });

        openAPI.setPaths(modifiedPaths);
    }
}

I did have to annotate it with @OpenAPIDefinition so that it was picked up by the JaxrsAnnotationScanner.

Hope it helps!

@frantuma
Copy link
Member

since version 2.1.9 (#3936) a new boolean configuration parameter alwaysResolveAppPath is available: if set to true @ApplicationPath annotation applied to a JAX-RS Application class will be considered also at build time (e.g. via maven/gradle plugin or programmatic execution) and when exposing via a separate app (e.g. via OpenAPIServlet).

adagios pushed a commit to adagios/swagger-core that referenced this issue Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants