Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions specmatic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ components:
specmaticOrderContracts:
git:
url: https://github.com/specmatic/specmatic-order-contracts.git
branch: missing-response-codes
localFilesystem:
filesystem:
directory: "."
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/store/controllers/Orders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import jakarta.validation.Valid
import jakarta.validation.constraints.NotNull
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.validation.annotation.Validated
Expand All @@ -18,7 +19,7 @@ class Orders {
@Autowired
lateinit var orderService: OrderService

@PostMapping("/orders")
@PostMapping("/orders", consumes = [MediaType.APPLICATION_JSON_VALUE])
fun create(
@Valid @RequestBody request: NewOrderRequest,
@NotNull @RequestHeader("Idempotency-Key", required = true) idempotencyKey: UUID,
Expand All @@ -39,7 +40,7 @@ class Orders {
return ResponseEntity(HttpStatus.OK)
}

@PatchMapping("/orders/{id}")
@PatchMapping("/orders/{id}", consumes = [MediaType.APPLICATION_JSON_VALUE])
fun update(
@PathVariable("id") id: Int,
@Valid @RequestBody request: UpdateOrderRequest,
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/store/controllers/Products.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import jakarta.validation.constraints.Positive
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.format.annotation.DateTimeFormat
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.validation.annotation.Validated
Expand All @@ -22,7 +23,7 @@ open class Products {
@Autowired
lateinit var productService: ProductService

@PatchMapping("/products/{id}")
@PatchMapping("/products/{id}", consumes = [MediaType.APPLICATION_JSON_VALUE])
@Validated
fun update(
@PathVariable("id") id: Int,
Expand All @@ -38,7 +39,7 @@ open class Products {
return productService.getProduct(id)
}

@PostMapping("/products")
@PostMapping("/products", consumes = [MediaType.APPLICATION_JSON_VALUE])
fun create(
@Valid @RequestBody request: NewProductRequest,
@NotNull @RequestHeader("Idempotency-Key", required = true) idempotencyKey: UUID,
Expand Down Expand Up @@ -72,7 +73,7 @@ open class Products {
return ResponseEntity(products.take(pageSize ?: products.size), HttpStatus.OK)
}

@PutMapping("/products/{id}/image", consumes = ["multipart/form-data"])
@PutMapping("/products/{id}/image", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
fun uploadImage(@PathVariable("id") id: Int, @RequestPart("image") image: MultipartFile): ResponseEntity<Map<String, Any>> {
productService.addImage(id, image.originalFilename, image.bytes)
val response = mapOf("message" to "Product image updated successfully")
Expand Down
Loading