Skip to content

Commit

Permalink
Merge pull request #336 from DanyBv/3.0.x
Browse files Browse the repository at this point in the history
Added security and components in swagger configuration.
  • Loading branch information
jplock authored Nov 14, 2023
2 parents e5ae637 + d456d53 commit c85d8b4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
13 changes: 12 additions & 1 deletion spotbugs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@
limitations under the License.
-->
<FindBugsFilter/>
<FindBugsFilter>
<Match>
<Class name="io.federecio.dropwizard.swagger.SwaggerBundleConfiguration" />
<Method name="getComponents" />
<Bug pattern="EI_EXPOSE_REP" />
</Match>
<Match>
<Class name="io.federecio.dropwizard.swagger.SwaggerBundleConfiguration" />
<Method name="setComponents" />
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Strings;
import io.swagger.v3.oas.integration.SwaggerConfiguration;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.servers.Server;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -79,6 +81,10 @@ public class SwaggerBundleConfiguration implements Cloneable {

@Nullable private List<Server> servers;

@Nullable private List<SecurityRequirement> security;

@Nullable private Components components;

@Nullable private String customJavascript;

private SwaggerViewConfiguration swaggerViewConfiguration = new SwaggerViewConfiguration();
Expand Down Expand Up @@ -317,6 +323,28 @@ public void setServers(List<Server> servers) {
this.servers = servers != null ? new ArrayList<>(servers) : null;
}

@Nullable
@JsonProperty
public List<SecurityRequirement> getSecurity() {
return security != null ? new ArrayList<>(security) : null;
}

@JsonProperty
public void setSecurity(List<SecurityRequirement> security) {
this.security = security != null ? new ArrayList<>(security) : null;
}

@Nullable
@JsonProperty
public Components getComponents() {
return components;
}

@JsonProperty
public void setComponents(Components components) {
this.components = components;
}

@Nullable
@JsonProperty
public String getCustomJavascript() {
Expand Down Expand Up @@ -358,7 +386,7 @@ public SwaggerConfiguration build() {

final String[] exclusions = {SwaggerResource.PATH};
return new SwaggerConfiguration()
.openAPI(oas.info(info).servers(servers))
.openAPI(oas.info(info).servers(servers).security(security).components(components))
.prettyPrint(prettyPrint)
.readAllResources(readAllResources)
.ignoredRoutes(Arrays.stream(exclusions).collect(Collectors.toSet()))
Expand Down

0 comments on commit c85d8b4

Please sign in to comment.