Skip to content

OpenApiExampleProperty doesn't support lists within another OpenApiExamplePropertyΒ #252

@NKWBTB

Description

@NKWBTB

Describe the feature
The following annotation would give compilation error

@OpenApiContent(
  exampleObjects = {
    @OpenApiExampleProperty(
        name = "metadata",
        objects = {
          @OpenApiExampleProperty(name = "source", value = "document"),
          @OpenApiExampleProperty(name = "author", value = "John Doe"),
          @OpenApiExampleProperty(
              name = "tags",
              objects = {
                @OpenApiExampleProperty(value = "important"),
                @OpenApiExampleProperty(value = "research")
              })
        })
  }
)

Error message:

java.lang.IllegalArgumentException: Example object must have a name (ExampleProperty(name=-- This string represents a null value and shouldn't be used --, value=important, objects=[]))

Additional context
Related issue: #193

The list annotation can only work for a simple list.

@OpenApiContent(
      exampleObjects = {
            @OpenApiExampleProperty(value = "important"),
            @OpenApiExampleProperty(value = "research")
      }
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    βœ… Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions