mirror of
https://github.com/andwati/cymelle.git
synced 2026-11-05 08:22:16 +00:00
added swagger ui support
This commit is contained in:
Generated
+1
-1
@@ -5,7 +5,7 @@
|
||||
<profile name="Gradle Imported" enabled="true">
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="false">
|
||||
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-configuration-processor/4.1.0/c3e27f93b579220e4e18fe941321525200eb36b/spring-boot-configuration-processor-4.1.0.jar" />
|
||||
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-configuration-processor/3.5.15/dd1f197a202c7ea67c4fef05c3fe259b55fb2640/spring-boot-configuration-processor-3.5.15.jar" />
|
||||
</processorPath>
|
||||
<module name="orders.main" />
|
||||
</profile>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
java
|
||||
id("org.springframework.boot") version "4.1.0"
|
||||
id("org.springframework.boot") version "3.5.15"
|
||||
id("io.spring.dependency-management") version "1.1.7"
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ dependencies {
|
||||
|
||||
// dotenv
|
||||
implementation("io.github.cdimascio:dotenv-java:3.2.0")
|
||||
|
||||
//swagger
|
||||
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.16")
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.andwati.orders.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Bean
|
||||
WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/api/**")
|
||||
.allowedOrigins("http://localhost:3000")
|
||||
.allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH", "OPTIONS")
|
||||
.allowedHeaders("*");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.andwati.orders.config;
|
||||
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
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.servers.Server;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class OpenApiConfig {
|
||||
|
||||
@Bean
|
||||
OpenAPI orderFareOpenAPI() {
|
||||
return new OpenAPI()
|
||||
.info(new Info()
|
||||
.title("Order Management + Fare Engine API")
|
||||
.description("""
|
||||
API for managing orders, inventory stock levels, order cancellation rollback,
|
||||
and fare calculation.
|
||||
|
||||
Core features:
|
||||
- Place orders and deduct stock
|
||||
- Cancel orders and roll back stock
|
||||
- View inventory and low-stock items
|
||||
- Calculate trip fares using base fare, per-km rate, surge multiplier, and minimum fare
|
||||
""")
|
||||
.version("1.0.0")
|
||||
.contact(new Contact()
|
||||
.name("Ian Andwati")
|
||||
.email("[email protected]"))
|
||||
.license(new License()
|
||||
.name("MIT")))
|
||||
.servers(List.of(
|
||||
new Server()
|
||||
.url("http://localhost:8080")
|
||||
.description("Local development server")
|
||||
))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("Project Repository")
|
||||
.url("https://github.com/andwati/cymelle"));
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.andwati.orders.controller;
|
||||
|
||||
import com.andwati.orders.dto.response.FareCalculationResponse;
|
||||
import com.andwati.orders.services.FareCalculationService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -11,6 +12,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Tag(name = "Fare", description = "Calculate trip fares")
|
||||
|
||||
@Validated
|
||||
@RestController
|
||||
public class FareController {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.andwati.orders.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "Health", description = "Health check endpoint")
|
||||
|
||||
@RestController
|
||||
public class HealthController {
|
||||
|
||||
|
||||
@@ -3,11 +3,15 @@ package com.andwati.orders.controller;
|
||||
import com.andwati.orders.dto.response.InventoryResponse;
|
||||
import com.andwati.orders.dto.response.LowStockInventoryResponse;
|
||||
import com.andwati.orders.services.InventoryService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@Tag(name = "Inventory", description = "View inventory and low-stock items")
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/inventory")
|
||||
public class InventoryController {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.andwati.orders.dto.response.OrderSummaryResponse;
|
||||
import com.andwati.orders.dto.response.PageResponse;
|
||||
import com.andwati.orders.model.OrderStatus;
|
||||
import com.andwati.orders.services.OrderService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
@Tag(name = "Orders", description = "Place, list, view, and cancel orders")
|
||||
@RestController
|
||||
@RequestMapping("/api/orders")
|
||||
public class OrderController {
|
||||
|
||||
@@ -21,3 +21,8 @@ fare.default-surge-multiplier=${FARE_DEFAULT_SURGE_MULTIPLIER:1.0}
|
||||
fare.currency=${FARE_CURRENCY:KES}
|
||||
|
||||
app.seed-data=${SEED_DATA:true}
|
||||
springdoc.api-docs.path=/api-docs
|
||||
springdoc.swagger-ui.path=/swagger-ui.html
|
||||
springdoc.swagger-ui.operations-sorter=method
|
||||
springdoc.swagger-ui.tags-sorter=alpha
|
||||
springdoc.swagger-ui.try-it-out-enabled=true
|
||||
@@ -21,6 +21,7 @@
|
||||
"@tanstack/match-sorter-utils": "latest",
|
||||
"@tanstack/react-devtools": "latest",
|
||||
"@tanstack/react-form": "latest",
|
||||
"@tanstack/react-query": "^5.101.0",
|
||||
"@tanstack/react-router": "latest",
|
||||
"@tanstack/react-router-devtools": "latest",
|
||||
"@tanstack/react-router-ssr-query": "latest",
|
||||
|
||||
Generated
+358
-406
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user