-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Pointing to in/specmatic/examples/store/api_order_with_oauth_v3.yaml
- Switching from specmatic.json to specmatic.yaml - Updating all layers to work with in/specmatic/examples/store/api_order_with_oauth_v3.yaml - Upgrading Specmatic to 1.3.25
- Loading branch information
1 parent
9c2a6b4
commit dceae06
Showing
14 changed files
with
145 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ lib/* | |
*.iml | ||
*.idea | ||
|
||
.vscode/* | ||
.vscode/* | ||
.specmatic |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
sources: | ||
- provider: git | ||
repository: https://github.com/znsio/specmatic-order-contracts.git | ||
test: | ||
- in/specmatic/examples/store/api_order_with_oauth_v3.yaml | ||
|
||
report: | ||
formatters: | ||
- type: text | ||
layout: table | ||
types: | ||
APICoverage: | ||
OpenAPI: | ||
successCriteria: | ||
minThresholdPercentage: 70 | ||
maxMissedEndpointsInSpec: 4 | ||
enforce: true | ||
excludedEndpoints: | ||
- /internal/metrics |
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
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
7 changes: 7 additions & 0 deletions
7
src/main/java/com/store/exceptions/UnrecognizedTypeException.kt
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,7 @@ | ||
package com.store.exceptions | ||
|
||
import org.springframework.http.HttpStatus | ||
import org.springframework.web.bind.annotation.ResponseStatus | ||
|
||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
class UnrecognizedTypeException(type: String) : Throwable("Unrecognized type: $type") |
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
59 changes: 59 additions & 0 deletions
59
src/main/java/com/store/handlers/GlobalExceptionHandler.kt
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,59 @@ | ||
package com.store.handlers | ||
|
||
import com.store.exceptions.NotFoundException | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.ControllerAdvice | ||
import org.springframework.web.bind.annotation.ExceptionHandler | ||
import java.time.LocalDateTime | ||
|
||
@ControllerAdvice | ||
class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(NotFoundException::class) | ||
fun handleGenericException(ex: NotFoundException): ResponseEntity<ErrorResponse> { | ||
val notFound = HttpStatus.NOT_FOUND | ||
return ResponseEntity.status(notFound).body( | ||
errorResponse( | ||
notFound, | ||
ex, | ||
"Requested resource not found", | ||
"resource not found" | ||
) | ||
) | ||
} | ||
|
||
@ExceptionHandler(Exception::class) | ||
fun handleGenericException(ex: Exception): ResponseEntity<ErrorResponse> { | ||
val badRequest = HttpStatus.BAD_REQUEST | ||
return ResponseEntity.status(badRequest).body( | ||
errorResponse( | ||
badRequest, | ||
ex, | ||
"An error occurred while processing the request", | ||
"Unknown error" | ||
) | ||
) | ||
} | ||
|
||
private fun errorResponse( | ||
httpStatus: HttpStatus, | ||
ex: Exception, | ||
error: String, | ||
message: String | ||
): ErrorResponse { | ||
return ErrorResponse( | ||
LocalDateTime.now(), | ||
httpStatus.value(), | ||
error, | ||
ex.message ?: message | ||
) | ||
} | ||
} | ||
|
||
data class ErrorResponse( | ||
val timestamp: LocalDateTime, | ||
val status: Int, | ||
val error: String, | ||
val message: String | ||
) |
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
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