diff --git a/pom.xml b/pom.xml
index 03e138b..bc5c894 100644
--- a/pom.xml
+++ b/pom.xml
@@ -135,6 +135,16 @@
jsoup
1.17.2
+
+ org.springdoc
+ springdoc-openapi-ui
+ 1.7.0
+
+
+ org.springdoc
+ springdoc-openapi-security
+ 1.7.0
+
diff --git a/src/main/java/com/bloggios/blog/configuration/SwaggerConfiguration.java b/src/main/java/com/bloggios/blog/configuration/SwaggerConfiguration.java
new file mode 100644
index 0000000..4253506
--- /dev/null
+++ b/src/main/java/com/bloggios/blog/configuration/SwaggerConfiguration.java
@@ -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 getServers(){
+ Map servers = swaggerConfigProperties.getServers();
+ List 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;
+ }
+}
diff --git a/src/main/java/com/bloggios/blog/properties/SwaggerConfigProperties.java b/src/main/java/com/bloggios/blog/properties/SwaggerConfigProperties.java
new file mode 100644
index 0000000..71e28bc
--- /dev/null
+++ b/src/main/java/com/bloggios/blog/properties/SwaggerConfigProperties.java
@@ -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 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;
+ }
+}
diff --git a/src/main/java/com/bloggios/blog/scheduler/SchedulerValidator.java b/src/main/java/com/bloggios/blog/scheduler/SchedulerValidator.java
deleted file mode 100644
index 6a6c599..0000000
--- a/src/main/java/com/bloggios/blog/scheduler/SchedulerValidator.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.bloggios.blog.scheduler;
-
-import com.bloggios.blog.dao.implementation.pgsqlimplementation.SchedulerDataDao;
-import com.bloggios.blog.modal.SchedulerData;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import java.util.Date;
-
-/**
- * Owner - Rohit Parihar
- * Author - rohit
- * Project - blog-provider-application
- * Package - com.bloggios.blog.scheduler
- * Created_on - August 29 - 2024
- * Created_at - 19:03
- */
-
-@Component
-@Slf4j
-public class SchedulerValidator {
-
- private final SchedulerDataDao schedulerDataDao;
-
- public SchedulerValidator(
- SchedulerDataDao schedulerDataDao
- ) {
- this.schedulerDataDao = schedulerDataDao;
- }
-
- public void validate(SchedulerData schedulerData) {
- if (schedulerData.getScheduleDate().compareTo(new Date()) <= 0) {
- return;
- }
-
- if (schedulerData.isSchedulingDone()) {
- schedulerDataDao.deleteByEntity(schedulerData);
- log.warn("""
- Scheduler Entry deleted for below details
- Scheduler Id: {}
- Destination Id: {}
- Task For: {}
- Scheduled Completed On: {}
- """,
- schedulerData.getSchedulerId(),
- schedulerData.getDestId(),
- schedulerData.getScheduledTaskType().toString(),
- schedulerData.getScheduleCompletedOn());
- }
- }
-}
diff --git a/src/main/java/com/bloggios/blog/scheduler/implementation/BlogSchedulerImplementation.java b/src/main/java/com/bloggios/blog/scheduler/implementation/BlogSchedulerImplementation.java
index ed8b55a..e535abb 100644
--- a/src/main/java/com/bloggios/blog/scheduler/implementation/BlogSchedulerImplementation.java
+++ b/src/main/java/com/bloggios/blog/scheduler/implementation/BlogSchedulerImplementation.java
@@ -9,9 +9,8 @@
import com.bloggios.blog.modal.SchedulerData;
import com.bloggios.blog.persistence.BlogEntityToDocumentPersistence;
import com.bloggios.blog.scheduler.ExecuteScheduler;
-import com.bloggios.blog.scheduler.SchedulerValidator;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.actuate.logging.LoggersEndpoint;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
@@ -29,29 +28,16 @@
@Component
@Slf4j
+@RequiredArgsConstructor
public class BlogSchedulerImplementation implements ExecuteScheduler {
private final SchedulerDataDao schedulerDataDao;
- private final SchedulerValidator schedulerValidator;
private final BlogEntityDao blogEntityDao;
private final BlogEntityToDocumentPersistence blogEntityToDocumentPersistence;
- public BlogSchedulerImplementation(
- SchedulerDataDao schedulerDataDao,
- SchedulerValidator schedulerValidator,
- BlogEntityDao blogEntityDao,
- BlogEntityToDocumentPersistence blogEntityToDocumentPersistence
- ) {
- this.schedulerDataDao = schedulerDataDao;
- this.schedulerValidator = schedulerValidator;
- this.blogEntityDao = blogEntityDao;
- this.blogEntityToDocumentPersistence = blogEntityToDocumentPersistence;
- }
-
@Override
@Transactional
public void execute(SchedulerData schedulerData) {
- schedulerValidator.validate(schedulerData);
Optional optionalBlogEntity = blogEntityDao.findById(schedulerData.getDestId());
if (optionalBlogEntity.isEmpty()) return;
BlogEntity blogEntity = optionalBlogEntity.get();
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 424d0f5..2a64fe6 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -75,6 +75,17 @@ security-config:
- /actuator/**
- /topics/**
- /unauth/**
+ - /api/v1/auth/**"
+ - /v2/api-docs
+ - /swagger-resources
+ - /swagger-resources/**
+ - /configuration/ui
+ - /configuration/security
+ - /swagger-ui/**
+ - /webjars/**
+ - /swagger-ui.html
+ - /v3/api-docs
+ - /v3/api-docs/**
cookie:
cookie-name: ${ACTIVE_PROFILE:local}.bg-refresh-mgmt
paths:
@@ -85,4 +96,28 @@ security-config:
blog-files:
blog-images: ${BLOG_IMAGES_PATH:files/blog-provider/blog}
- cover-images: ${COVER_IMAGES_PATH:files/blog-provider/cover}
\ No newline at end of file
+ cover-images: ${COVER_IMAGES_PATH:files/blog-provider/cover}
+
+swagger-properties:
+ group-name:
+ definition: ${spring.application.name}
+ scan-packages: com.bloggios.blog
+ info:
+ title: Bloggios - Blog Provider Application
+ version: @version@
+ description: API Documentation for blog-provider-application
+ summary: The Blog Provider Application, developed using Java 17 and Spring Boot, serves as a comprehensive backend microservice for Bloggios. It offers a full suite of blogging features, including commenting, likes, and more, to enhance user engagement and content management.
+ contact:
+ name: Bloggios
+ email: support@bloggios.com
+ url: https://www.bloggios.com
+ license:
+ name: Apache 2 License
+ url: https://github.com/Bloggios/blog-provider-application/blob/main/LICENSE
+ servers:
+ local:
+ name: Local Port
+ url: http://localhost:${server.port}/blog-provider
+ production:
+ name: Hosted Port
+ url: https://api.bloggios.com/blog-provider
\ No newline at end of file