From 89816e9df1c5aab90832033b820fb35108bdca5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98seokjun7410=E2=80=99?= <47974623+seokjun7410@users.noreply.github.com> Date: Thu, 14 Mar 2024 23:27:58 +0900 Subject: [PATCH] fix: FieldDescriptor.description to nullable --- .../apispec/gradle/ApiSpecTaskTest.kt | 27 ++++++++++++++++--- ...JsonSchemaFromFieldDescriptorsGenerator.kt | 2 +- .../restdocs/apispec/model/ResourceModel.kt | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/restdocs-api-spec-gradle-plugin/src/test/kotlin/com/epages/restdocs/apispec/gradle/ApiSpecTaskTest.kt b/restdocs-api-spec-gradle-plugin/src/test/kotlin/com/epages/restdocs/apispec/gradle/ApiSpecTaskTest.kt index 630d2f84..acdeed72 100644 --- a/restdocs-api-spec-gradle-plugin/src/test/kotlin/com/epages/restdocs/apispec/gradle/ApiSpecTaskTest.kt +++ b/restdocs-api-spec-gradle-plugin/src/test/kotlin/com/epages/restdocs/apispec/gradle/ApiSpecTaskTest.kt @@ -115,7 +115,14 @@ abstract class ApiSpecTaskTest { "status" : 200, "contentType" : "application/hal+json", "headers" : [ ], - "responseFields" : [ ], + "responseFields" : [ { + "attributes" : { }, + "description" : null, + "ignored" : false, + "path" : "name", + "type" : "STRING", + "optional" : false + } ], "example" : "{\n \"name\" : \"Fancy pants\",\n \"price\" : 49.99,\n \"_links\" : {\n \"self\" : {\n \"href\" : \"http://localhost:8080/products/7\"\n },\n \"product\" : {\n \"href\" : \"http://localhost:8080/products/7\"\n }\n }\n}" } } @@ -160,7 +167,14 @@ abstract class ApiSpecTaskTest { "status" : 200, "contentType" : "application/hal+json", "headers" : [ ], - "responseFields" : [ ], + "responseFields" : [ { + "attributes" : { }, + "description" : null, + "ignored" : false, + "path" : "name", + "type" : "STRING", + "optional" : false + } ], "example" : "{\n \"name\" : \"Fancy pants\",\n \"price\" : 49.99,\n \"_links\" : {\n \"self\" : {\n \"href\" : \"http://localhost:8080/products/7\"\n },\n \"product\" : {\n \"href\" : \"http://localhost:8080/products/7\"\n }\n }\n}" } } @@ -194,7 +208,14 @@ abstract class ApiSpecTaskTest { "status" : 200, "contentType" : "application/hal+json", "headers" : [ ], - "responseFields" : [ ], + "responseFields" : [ { + "attributes" : { }, + "description" : null, + "ignored" : false, + "path" : "name", + "type" : "STRING", + "optional" : false + } ], "example" : "{\n \"name\" : \"Fancy pants\",\n \"price\" : 49.99,\n \"_links\" : {\n \"self\" : {\n \"href\" : \"http://localhost:8080/products/7\"\n },\n \"product\" : {\n \"href\" : \"http://localhost:8080/products/7\"\n }\n }\n}" } } diff --git a/restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGenerator.kt b/restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGenerator.kt index 56f7adb6..1708c44c 100644 --- a/restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGenerator.kt +++ b/restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGenerator.kt @@ -196,7 +196,7 @@ class JsonSchemaFromFieldDescriptorsGenerator { internal class FieldDescriptorWithSchemaType( path: String, - description: String, + description: String?, type: String, optional: Boolean, ignored: Boolean, diff --git a/restdocs-api-spec-model/src/main/kotlin/com/epages/restdocs/apispec/model/ResourceModel.kt b/restdocs-api-spec-model/src/main/kotlin/com/epages/restdocs/apispec/model/ResourceModel.kt index 0cbb6aba..769f4d31 100644 --- a/restdocs-api-spec-model/src/main/kotlin/com/epages/restdocs/apispec/model/ResourceModel.kt +++ b/restdocs-api-spec-model/src/main/kotlin/com/epages/restdocs/apispec/model/ResourceModel.kt @@ -81,7 +81,7 @@ data class HeaderDescriptor( open class FieldDescriptor( val path: String, - val description: String, + val description: String?, val type: String, val optional: Boolean = false, val ignored: Boolean = false,