Skip to content

Renaming model property with JsonProperty disables description from JavaDoc  #2315

Closed
@zamirov

Description

@zamirov

Describe the bug
While descriptions from JavaDoc normally work, if you rename json property, it looses JavaDoc description.

I presume somewhere inside it does not keep original property name and if the name gets change by JsonProperty it loses mapping with JavaDoc.

To Reproduce
Steps to reproduce the behavior:
Create Webflux API server.
Add controller with POST request using model class with a property.
Enable JavaDoc, generate Swagger - JavaDoc is used as description.
Add JsonProperty with different name over the property - description becomes empty.

  • What version of spring-boot you are using?
    3.1.1
  • What modules and versions of springdoc-openapi are you using?
    • springdoc-openapi-starter-webflux-ui: 2.1.0
    • therapi-runtime-javadoc: 0.15.0
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>com.github.therapi</groupId>
                            <artifactId>therapi-runtime-javadoc-scribe</artifactId>
                            <version>0.15.0</version>
                        </path>
  • What is the actual and the expected result using OpenAPI Description (yml or json)?
    Property description taken from JavaDoc becomes empty if JsonProperty is used.
   "properties": {
       "task_id": {
            "type": "string"
      }
    }

Expected property description from JavaDoc regardless of using JsonProperty attribute.

   "properties": {
       "task_id": {
            "type": "string",
            "description": "Test model property."
      }
    }
  • Provide with a sample code (HelloController) or Test that reproduces the problem
/**
 * Test model.
 */
@Data
@Builder
public class TestModel {
  /**
   * Test model property.
   */
  @JsonProperty("test_property")
  String property;
}

public class TestController {
  @PostMapping("test-request")
  public Mono<Void> testRequest(
      @RequestBody TestModel model) {
    return null;
}

Expected behavior

The property should change its name with JsonProperty but description should stay as per JavaDoc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions