-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
189 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/com/bloggios/blog/configuration/SwaggerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.bloggios.blog.configuration; | ||
|
||
import com.bloggios.blog.properties.SwaggerConfigProperties; | ||
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.SecurityScheme; | ||
import io.swagger.v3.oas.models.servers.Server; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springdoc.core.GroupedOpenApi; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Owner - Rohit Parihar | ||
* Author - rohit | ||
* Project - blog-provider-application | ||
* Package - com.bloggios.blog.configuration | ||
* Created_on - August 30 - 2024 | ||
* Created_at - 01:19 | ||
*/ | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class SwaggerConfiguration { | ||
|
||
private final SwaggerConfigProperties swaggerConfigProperties; | ||
|
||
@Bean | ||
public GroupedOpenApi api() { | ||
return GroupedOpenApi.builder() | ||
.group(swaggerConfigProperties.getGroupName().getDefinition()) | ||
.packagesToScan(swaggerConfigProperties.getGroupName().getScanPackages()) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public OpenAPI customOpenAPI() { | ||
return new OpenAPI() | ||
.info(new Info() | ||
.title(swaggerConfigProperties.getInfo().getTitle()) | ||
.version(swaggerConfigProperties.getInfo().getVersion()) | ||
.description(swaggerConfigProperties.getInfo().getDescription()) | ||
.license(new License().name(swaggerConfigProperties.getInfo().getLicense().getName()).url(swaggerConfigProperties.getInfo().getLicense().getUrl())) | ||
.contact(new Contact().name(swaggerConfigProperties.getInfo().getContact().getName()).email(swaggerConfigProperties.getInfo().getContact().getEmail()).url(swaggerConfigProperties.getInfo().getContact().getUrl()))) | ||
.servers(getServers()) | ||
.components(new Components() | ||
.addSecuritySchemes("bearerAuth", new SecurityScheme() | ||
.name("bearerAuth") | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("bearer") | ||
.bearerFormat("JWT") | ||
.in(SecurityScheme.In.HEADER) | ||
.description("JWT Authentication"))); | ||
} | ||
|
||
public List<Server> getServers(){ | ||
Map<String, SwaggerConfigProperties.Server> servers = swaggerConfigProperties.getServers(); | ||
List<Server> serversList = new ArrayList<>(); | ||
for (String server : servers.keySet()){ | ||
SwaggerConfigProperties.Server getServer = servers.get(server); | ||
serversList.add(new Server().description(getServer.getName()).url(getServer.getUrl())); | ||
} | ||
return serversList; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/bloggios/blog/properties/SwaggerConfigProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.bloggios.blog.properties; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Owner - Rohit Parihar | ||
* Author - rohit | ||
* Project - blog-provider-application | ||
* Package - com.bloggios.blog.properties | ||
* Created_on - August 30 - 2024 | ||
* Created_at - 01:35 | ||
*/ | ||
|
||
@Getter | ||
@Setter | ||
@ConfigurationProperties(prefix = "swagger-properties") | ||
@Configuration | ||
public class SwaggerConfigProperties { | ||
|
||
private Info info; | ||
private Map<String, Server> servers; | ||
private Group groupName; | ||
|
||
|
||
@Getter | ||
@Setter | ||
public static class Info{ | ||
private String title; | ||
private String description; | ||
private String summary; | ||
private String version; | ||
private Contact contact; | ||
private License license; | ||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class Contact{ | ||
private String name; | ||
private String email; | ||
private String url; | ||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class License{ | ||
private String name; | ||
private String url; | ||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class Server{ | ||
private String name; | ||
private String url; | ||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class Group{ | ||
private String definition; | ||
private String scanPackages; | ||
} | ||
} |
51 changes: 0 additions & 51 deletions
51
src/main/java/com/bloggios/blog/scheduler/SchedulerValidator.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters