Skip to content

Commit b0cea3a

Browse files
add header example value (#92)
1 parent aba4b96 commit b0cea3a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

restdocs-api-spec-openapi3-generator/src/main/kotlin/com/epages/restdocs/apispec/openapi3/OpenApi3Generator.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ object OpenApi3Generator {
382382
description = headerDescriptor.description
383383
required = headerDescriptor.optional.not()
384384
schema = simpleTypeToSchema(headerDescriptor.type)
385+
example = headerDescriptor.example
385386
}
386387
}
387388

restdocs-api-spec-openapi3-generator/src/test/kotlin/com/epages/restdocs/apispec/openapi3/OpenApi3GeneratorTest.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class OpenApi3GeneratorTest {
160160
then(openApiJsonPathContext.read<List<String>>("$productGetByIdPath.parameters[?(@.name == 'locale')].schema.type")).containsOnly("string")
161161
then(openApiJsonPathContext.read<List<String>>("$productGetByIdPath.parameters[?(@.name == 'Authorization')].in")).containsOnly("header")
162162
then(openApiJsonPathContext.read<List<Boolean>>("$productGetByIdPath.parameters[?(@.name == 'Authorization')].required")).containsOnly(true)
163+
then(openApiJsonPathContext.read<List<String>>("$productGetByIdPath.parameters[?(@.name == 'Authorization')].example")).containsOnly("some example")
163164
then(openApiJsonPathContext.read<List<String>>("$productGetByIdPath.parameters[?(@.name == 'Authorization')].schema.type")).containsOnly("string")
164165

165166
then(openApiJsonPathContext.read<String>("$productGetByIdPath.requestBody")).isNull()
@@ -583,11 +584,12 @@ class OpenApi3GeneratorTest {
583584
method = HTTPMethod.GET,
584585
securityRequirements = getSecurityRequirement(),
585586
headers = listOf(
586-
HeaderDescriptor(
587-
name = "Authorization",
588-
description = "Access token",
589-
type = "string",
590-
optional = false
587+
HeaderDescriptor(
588+
name = "Authorization",
589+
description = "Access token",
590+
type = "string",
591+
optional = false,
592+
example = "some example"
591593
)
592594
),
593595
pathParameters = listOf(

0 commit comments

Comments
 (0)