-
-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Labels
Description
Actual behavior (the bug)
I am trying to give an OpenAPI example object for a request where one of the properties needs to be an empty JSON Object, which I have specified as follows:
requestBody = @OpenApiRequestBody(
description = "JSON-RPC request",
content= @OpenApiContent(
type = "application/json" ,
from = Object.class,
exampleObjects = {
@OpenApiExampleProperty(name = "jsonrpc", value = "2.0"),
@OpenApiExampleProperty(name = "method", value = "initialize"),
@OpenApiExampleProperty(name = "params", objects= {}),
@OpenApiExampleProperty(name = "id", value = "1")
}
)),
Note the objects= {} property
When building however I get the following Maven error:
[ERROR] Failed to execute goal �[32morg.apache.maven.plugins:maven-compiler-plugin:3.14.0:compile�[m �[1m(default-compile)�[m on project �[36mvenue�[m: �[1;31mFatal error compiling�[m: java.lang.IllegalArgumentException: Example object must have either value or objects (ExampleProperty(name=params, value=-- This string represents a null value and shouldn't be used --, objects=[])) -> �[1m[Help 1]�[m
Expected behavior
I would expect it to be possible to specify an empty JSON object (e.g. as expected by various APIs) using this method, i.e. an object with no properties.
To Reproduce
This seems to occur whenever you try to create a empty object example property value.
It doesn't occur if you include at least one property in the child object, e.g.
@OpenApiExampleProperty(name = "params", objects= {@OpenApiExampleProperty(name="foo",value="222")})
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
✅ Done