Swagger-core: title attribute in @SwaggerDefinition @Info is ignored

Created on 7 Jan 2016  路  8Comments  路  Source: swagger-api/swagger-core

I have a @SwaggerDefinition in my api:
@SwaggerDefinition(
info = @Info(
title = "My API",
description = "Documentation",
version = "1.0-SNAPSHOT"
)
)

But title attribute value is ignored. Instead the value from web.xml is used (in my case just empty string).
This happens because in WebXMLReader,java:82 title attribute is overwritten

Most helpful comment

@webron @fehguy
Any update on this one? At the moment I put the title in web.xml but a fix would be nice (using v.1.5.10).

All 8 comments

Well, it makes sense that configuration takes precedence over code.

It would make sense if I provided a configuration for this parameter, but I omitted title attribute in web.xml.
@Info title attribute is never used.

Based on your analysis I assume you're using the latest version. Would be great if you could submit a PR to fix the issue.

I have the same problem. I tried adding an api.title entry in web.xml (a guess, based on the comments above -- is there another way?), but that didn't help.

In addition, the version attribute in @SwaggerDefinition is ignored. Instead, the api.version from web.xml is used. If api.version is left out, the generated version becomes the string "Swagger Server"!

Also, the @SwaggerDefinition is not picked up at all if I put it on my ResourceConfig subclass. So, instead, I attached it to my top-level resource class that has @Path("/"). The documentation is a bit vague on where it's supposed to go...

Ah, it's swagger.api.title in web.xml. So at least there is a workaround for now.

Could someone tell me what the verdict is on this issue? Is there even an issue here or is this intentional?
I'm trying to use a very simple Bootstrap servlet and I'm encountering the same problem.

public class SwaggerBootstrap extends HttpServlet {
    @Override
    public void init(ServletConfig config) throws ServletException {
    LOGGER.info("Initialize swagger");
    Info info = new Info()
            .title("TITLE")
            .version("VERSION")
            .description("DESCRIPTION ");

    Swagger swagger = new Swagger().info(info);
    new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
    }
 }

only the description shows up, because the version number if being overridden by the web.xml and the title just doesn't appear anywhere. As stated above, if you remove the api.version tag from the web.xml then you just get Swagger Server, and the code is never read. Similarly the title is blank even though I've specified it here. Am I doing something wrong?

@henray nope, it sounds like a bug

@webron @fehguy
Any update on this one? At the moment I put the title in web.xml but a fix would be nice (using v.1.5.10).

Was this page helpful?
0 / 5 - 0 ratings