ePages-de / ePages-de/restdocs-api-spec

Gradle task openapi3 fails when a field is not given a description

Open
#121 2 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
Kotlin
Stars
427
Forks
116
Avg merge
23h 54m
Merged PRs (30d)
1

Description

Not sure if this is intended behavior, but when I don't specify a description for a response field, the output snippet resource.json outputs "description": null, which causes the openapi3 gradle task to fail.

Example:

The controller returns an array of objects.
````json
[
{
"example": "blah"
}
]
````

resources.json shows a null value for description
````
"responseFields" : [ {
"attributes" : { },
"description" : null,
"ignored" : false,
"path" : "[].example",
"type" : "STRING",
"optional" : false
},
````

Test uses Spring @WebMvcTest and MockMvc with MockMvcRestDocumentationWrapper
````java
this.mockMvc.perform(get("/example"))
.andExpect(status().isOk())
.andDo(document("example", resource(ResourceSnippetParameters.builder()
.responseFields(
fieldWithPath("[].example").type(JsonFieldType.STRING)
)
.build()
)));
````

Error:
````
Execution failed for task ':example:openapi3'.
> com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class com.epages.restdocs.apispec.model.FieldDescriptor] value failed for JSON property description due to missing (therefore NULL) value for creator parameter description which is a non-nullable type
...

com.epages.restdocs.apispec.model.ResourceModel["response"]->com.epages.restdocs.apispec.model.ResponseModel["responseFields"]->java.util.ArrayList[0]->com.epages.restdocs.apispec.model.FieldDescriptor["description"])
````

If I add any description to the FieldDescriptor, the task succeeds.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.