Skip to content

JavaDoc integration not working with SnakeCaseStrategy property naming #2484

Closed
@joarobles

Description

@joarobles

Describe the bug

When trying to generate Schema description from JavaDoc comments, it's not working as expected for fields that not match exactly with their JSON representation (camelCase to snake_case for example).

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    spring-boot: 3.2.1

  • What modules and versions of springdoc-openapi are you using?
    springdoc-openapi-starter-webmvc-ui: 2.3.0
    therapi-runtime-javadoc: 0.15.0

  • What is the actual and the expected result using OpenAPI Description (yml or json)?

Actual:

{
    "SearchRequest": {
        "required": [
            "org_id",
            "organization_id"
        ],
        "type": "object",
        "properties": {
            "organization_id": {
                "type": "integer",
                "format": "int64"
            },
            "org_id": {
                "type": "integer",
                "description": "All search requests must specify an Organization to filter the results by (exact match). I.e.: <code>1234</code>",
                "format": "int64"
            }
        }
    }
}

Expected:

{
    "SearchRequest": {
        "required": [
            "org_id",
            "organization_id"
        ],
        "type": "object",
        "properties": {
            "organization_id": {
                "type": "integer",
                "description": "All search requests must specify an Organization to filter the results by (exact match). I.e.: <code>1234</code>",
                "format": "int64"
            },
            "org_id": {
                "type": "integer",
                "description": "All search requests must specify an Organization to filter the results by (exact match). I.e.: <code>1234</code>",
                "format": "int64"
            }
        }
    }
}
  • Provide with a sample code (HelloController) or Test that reproduces the problem
@Data
@Builder
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class SearchRequest {

  /**
   * All search requests must specify an Organization to filter the results by (exact match)
   * I.e.: <code>1234</code>
   */
  private @NotNull final Long organizationId;

  @Schema(description = "All search requests must specify an Organization to filter the results by (exact match). I.e.: <code>1234</code>")
  private @NotNull final Long orgId;

}

Expected behavior

  • A clear and concise description of what you expected to happen.
    I'd expect all fields to have the same schema description in the generated json.

  • What is the expected result using OpenAPI Description (yml or json)?
    I'd expect all fields to have the same schema description in the generated json.

Screenshots
If applicable, add screenshots to help explain your problem.
N/A

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions