swagger-api / swagger-play

Apache License 2.0
330 stars 181 forks source link

SwaggerDefinition should be completely supported (add support for @Info) #134

Open JFCote opened 7 years ago

JFCote commented 7 years ago

Right now, it seems that swagger-play only partially support the core annotation @SwaggerDefinition.

If I use the annotation provided in the documentation over one of my constructor:

 @SwaggerDefinition(
        info = @Info(
                description = "Gets the weather",
                version = "V12.0.12",
                title = "The Weather API",
                termsOfService = "http://theweatherapi.io/terms.html",
                contact = @Contact(
                        name = "Rain Moore",
                        email = "rain.moore@theweatherapi.io",
                        url = "http://theweatherapi.io"
                ),
                license = @License(
                        name = "Apache 2.0",
                        url = "http://www.apache.org/licenses/LICENSE-2.0"
                )
        ),
        consumes = {"application/json"},
        produces = {"application/json"},
        schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
        tags = {
                @Tag(name = "Private", description = "Tag used to denote operations as private")
        },
        externalDocs = @ExternalDocs(value = "Meteorology", url = "http://theweatherapi.io/meteorology.html")
)

It will only generate this:

{
  "swagger" : "2.0",
  "info" : {
    "version" : "1.0",
    "title" : "",
    "contact" : {
      "name" : ""
    },
    "license" : {
      "name" : "",
      "url" : "http://licenseUrl"
    }
  },
  "host" : "localhost:9000",
  "basePath" : "/",
  "tags" : [ {
    "name" : "Private",
    "description" : "Tag used to denote operations as private"
  }, {
    "name" : "Actors"
  }, {
    "name" : "Affiliates"
  } ],
  "schemes" : [ "http", "https" ],
  "consumes" : [ "application/json" ],
  "produces" : [ "application/json" ],
  "externalDocs" : {
    "description" : "Meteorology",
    "url" : "http://theweatherapi.io/meteorology.html"
  }

It seems only these fields are supported:

The more important field, called @Info is completely ignored and the value we see are the default values.

I'm using swagger-play2 1.5.3

jorge-sanz commented 7 years ago

@JFCote You can use application.conf file for that instead: https://github.com/swagger-api/swagger-play/tree/master/play-2.6/swagger-play2#applicationconf---config-options

ultrasonex commented 7 years ago

@jorge-sanz Is there any way I can put the email in the contact from application.conf ? Currently I don't see any documentation for that.

jorge-sanz commented 7 years ago

@ultrasonex Me neither. I would put it in the swagger.api.info.contact property.

One of the Swagger staff member told me that would change a lot of stuff in Swagger Core v3 including the annotations thing. 🙂

ultrasonex commented 7 years ago

@jorge-sanz Thanks for replying ! I tried to put the contact and it shows in the swagger.json as "contact" : { "name" : "name" }, but seems to me missed in the swagger-ui . Not sure how why it is not visible. Do you know when v3 is releasing and when will be ready for play from your source? Anyways looking forward to it.