question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Springdoc does not resolve property descriptions for arrays

See original GitHub issue

Describe the bug

Springdoc is not properly substituting variables sourced from a .properties files on Array types such as List<String>;

We are using the springdoc.api-docs.resolve-schema-properties=true feature so we can store our descriptions in a .properties file.

This setup works for all fields types except for List properties. It might even be only be happening with lists of “primitives” such as String.

The result is that we see the un-substituted variable name in the generated open api spec rather than the substituted value.

For example we have a java model two properties like this

    @ApiModelProperty( value = "${blahDescription.value}" )
    @Schema( description = "${blahDescription.value}" )
    String blah;

    @ApiModelProperty( value = "${blahDescription.value}" )
    @ArraySchema( arraySchema = @Schema( description = "${blahDescription.value}" ),
                  schema = @Schema( description = "${blahDescription.value}" ) )
    List<String> listBlah;

and in our .properties file we have

blahDescription.value="I am description for blah"

This is generating a schema like so

                "properties":
                {
                    "listBlah":
                    {
                        "type": "array",
                        "description": "\"I am description for blah\"",
                        "items":
                        {
                            "type": "string",
                            "description": "${blahDescription.value}"
                        }
                    },
                    "blah":
                    {
                        "type": "string",
                        "description": "\"I am description for blah\""
                    }
                },

Notice in the description of properties.listBlah.items.description the description is ${blahDescription.value} and wasn’t substituted correctly.

To Reproduce Steps to reproduce the behavior:

  • setup a java model with the same properties above and the descriptions sourced from a .properties file.

  • What version of spring-boot you are using? id 'org.springframework.boot' version '2.3.12.RELEASE' apply false

  • What modules and versions of springdoc-openapi are you using?

            dependencySet( group: 'org.springdoc', version: '1.5.10' ) {
                entry 'springdoc-openapi-ui'
                entry 'springdoc-openapi-webmvc-core'
            }
            dependency 'io.swagger.core.v3:swagger-annotations:2.1.10'
            dependency 'io.swagger:swagger-annotations:1.5.24'
  • What is the actual and the expected result using OpenAPI Description (yml or json)?

Expected

                    "listBlah":
                    {
                        "maxItems": 255,
                        "minItems": 1,
                        "type": "array",
                        "description": "\"I am description for blah\"",
                        "items":
                        {
                            "type": "string",
                            "description":  "\"I am description for blah\""
                        }
                    },

Actual

                    "listBlah":
                    {
                        "maxItems": 255,
                        "minItems": 1,
                        "type": "array",
                        "description": "\"I am description for blah\"",
                        "items":
                        {
                            "type": "string",
                            "description": "${blahDescription.value}"
                        }
                    },

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
bnasslahsencommented, Dec 14, 2022

It should part of the next release. Hopefully by the end of this week!

0reactions
stv8commented, Dec 14, 2022

Will this be part of a patch release?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found