Following https://github.com/swagger-api/swagger-core/wiki/Annotations-1.5.X#swagger-definition I created an interface 'ApiConfig' with no method in it and put it the interface in the package that swagger will scan.
I am using jersey 2.15 and swagger-jersey2-jaxrs version is 1.5.10. I also tried swagger-jersey2-jaxrs 1.5.14 with no luck.
This is the interface I created.
@SwaggerDefinition(
info = @Info(
description = "my apis",
version = "1.0.0",
title = "my apis"
),
schemes = {SwaggerDefinition.Scheme.HTTP},
tags = {@Tag(name = "mytag", description = "test tag")},
securityDefinition = @SecurityDefinition(
oAuth2Definitions = {
@OAuth2Definition(
key = "testoauth",
description = "MES OAuth",
authorizationUrl = "http://www.example.com/",
tokenUrl = "",
scopes = {
@Scope(
name = "test",
description = "testscope"
),
@Scope(
name = "general:save",
description = "save operation"
),
@Scope(
name = "general:update",
description = "update operation"
)
},
flow = OAuth2Definition.Flow.IMPLICIT
)
}
)
)
public interface ApiConfig {
}
But the result 'swagger.json' does not contain anything I specified in the annotation(I hit 'swagger.json' in chrome and searched 'securityDefinition' and got nothing). Then I added @Path("") to the interface, and restarted web server, it worked as expected. What did I do wrong?
I could be wrong, but i think you also need to add the @Api annotation to the Interface.
same here
Same issue, cannot get it to generate the securtiyDefinitions, tried @ChristianCiach suggestion as well, doesn't work.
I got it to work, you should add @Provider annotation on the interface, otherwise it will not be picked up by Jersey container
Had exactly the same issue, and @zak905 's suggestion worked for me.
Thanks!
same issue
Had exactly the same issue, and @zak905 's suggestion worked for me.
Thanks!
doesn't work for me, because I use msf4j, not Jersey
Most helpful comment
I got it to work, you should add
@Providerannotation on the interface, otherwise it will not be picked up by Jersey container