Valider les resource entrente #91
@@ -14,10 +14,8 @@ import java.util.concurrent.CompletionException
|
||||
|
||||
class HttpError(
|
||||
statusCode: HttpStatusCode,
|
||||
val cause: Throwable? = null,
|
||||
val type: String? = null,
|
||||
cause: Throwable? = null,
|
||||
val title: String = cause?.message ?: statusCode.description,
|
||||
val detail: String? = null,
|
||||
) {
|
||||
val statusCode: Int = statusCode.value
|
||||
}
|
||||
|
||||
@@ -164,6 +164,13 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/400'
|
||||
404:
|
||||
description: BadReqest
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/404'
|
||||
|
||||
/articles/{article}/versions:
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/article'
|
||||
@@ -2278,7 +2285,7 @@ components:
|
||||
example: MASTER
|
||||
|
||||
400:
|
||||
description: noting
|
||||
description: Bad Request
|
||||
required:
|
||||
- title
|
||||
- invalidParams
|
||||
@@ -2304,6 +2311,20 @@ components:
|
||||
type: string
|
||||
example: 'Cannot be null'
|
||||
|
||||
404:
|
||||
description: Not Found
|
||||
required:
|
||||
- title
|
||||
- statusCode
|
||||
additionalProperties: false
|
||||
properties:
|
||||
statusCode:
|
||||
type: integer
|
||||
example: 404
|
||||
title:
|
||||
type: string
|
||||
example: Bad Request
|
||||
|
||||
securitySchemes:
|
||||
JWTAuth:
|
||||
type: http
|
||||
|
||||
@@ -22,6 +22,7 @@ import integration.steps.then.`which contains`
|
||||
import integration.steps.then.and
|
||||
import io.ktor.http.HttpStatusCode.Companion.BadRequest
|
||||
import io.ktor.http.HttpStatusCode.Companion.Forbidden
|
||||
import io.ktor.http.HttpStatusCode.Companion.NotFound
|
||||
import io.ktor.http.HttpStatusCode.Companion.OK
|
||||
import org.junit.jupiter.api.Tag
|
||||
import org.junit.jupiter.api.Tags
|
||||
@@ -82,6 +83,17 @@ class `Article routes` : BaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `I cannot get article with id doesn't exist`() {
|
||||
withIntegrationApplication {
|
||||
`When I send a GET request`("/articles/635fe2e8-2dbc-4c80-b306-101d38a4ab23") `Then the response should be` NotFound and {
|
||||
`And the response should not be null`()
|
||||
`And the response should contain`("$.title", "Article 635fe2e8-2dbc-4c80-b306-101d38a4ab23 not found")
|
||||
`And the response should contain`("$.statusCode", 404)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("BadRequest")
|
||||
fun `I cannot get article by id with wrong id format`() {
|
||||
|
||||
Reference in New Issue
Block a user