Skip to content

Commit 08a4649

Browse files
ozscheygeooz
andauthored
GH-168 OpenAPI 3 generator, consider path parameter types (#171)
* GH-168 Adapt test to reproduce issue * GH-168 Fix by considering PathParameter type Co-authored-by: ooz <[email protected]>
1 parent a614f47 commit 08a4649

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ object OpenApi3Generator {
408408
return PathParameter().apply {
409409
name = parameterDescriptor.name
410410
description = parameterDescriptor.description
411-
schema = StringSchema()
411+
schema = simpleTypeToSchema(parameterDescriptor.type)
412412
}
413413
}
414414

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class OpenApi3GeneratorTest {
266266

267267
then(openApiJsonPathContext.read<List<String>>("$productGetByIdPath.parameters[?(@.name == 'id')].in")).containsOnly("path")
268268
then(openApiJsonPathContext.read<List<Boolean>>("$productGetByIdPath.parameters[?(@.name == 'id')].required")).containsOnly(true)
269+
then(openApiJsonPathContext.read<List<String>>("$productGetByIdPath.parameters[?(@.name == 'id')].schema.type")).containsOnly("integer")
269270
then(openApiJsonPathContext.read<List<String>>("$productGetByIdPath.parameters[?(@.name == 'locale')].in")).containsOnly("query")
270271
then(openApiJsonPathContext.read<List<Boolean>>("$productGetByIdPath.parameters[?(@.name == 'locale')].required")).containsOnly(false)
271272
then(openApiJsonPathContext.read<List<String>>("$productGetByIdPath.parameters[?(@.name == 'locale')].schema.type")).containsOnly("string")
@@ -891,7 +892,7 @@ class OpenApi3GeneratorTest {
891892
ParameterDescriptor(
892893
name = "id",
893894
description = "Product ID",
894-
type = "STRING",
895+
type = "INTEGER",
895896
optional = false,
896897
ignored = false
897898
)

0 commit comments

Comments
 (0)