Skip to content

Inconsistent OpenAPI schema naming with SNAKE_CASE: some Java record fields remain camelCase #3293

Closed

Description

@AgilAghamirzayev

Title

Inconsistent OpenAPI schema naming with SNAKE_CASE: some Java record fields remain camelCase

Describe the bug

When spring.jackson.property-naming-strategy: SNAKE_CASE is enabled, OpenAPI schema generation is inconsistent for Java record fields.
Most fields are converted to snake_case, but some fields remain camelCase in /v3/api-docs and Swagger UI.

In my case, non-boolean fields starting with is... syllable (e.g. issuanceDate, issuingCountry, issuingAuthority) stay camelCase, while other fields are snake_case.


To Reproduce

Steps to reproduce the behavior:

  • Spring Boot version: 4.0.5
  • springdoc-openapi module/version: org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.2
  • Related transitive swagger-core version: io.swagger.core.v3:swagger-core-jakarta:2.2.43

application.yaml:

spring:
  jackson:
    property-naming-strategy: SNAKE_CASE

Optional OpenAPI config used:

@Bean
public ModelResolver modelResolver() {
    return new ModelResolver(
        Json.mapper().copy().setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
    );
}

Sample DTO:

public record PidLookupResponse(
    String familyName,
    String expiryDate,
    String issuanceDate,
    String issuingCountry,
    String issuingAuthority
) {}

Sample controller:

@RestController
@RequestMapping("/api/test")
public class HelloController {

    @GetMapping
    public PidLookupResponse get() {
        return new PidLookupResponse(
            "Doe", "2030-01-01", "2020-01-01", "AZ", "Authority"
        );
    }
}

Run app and check:

  • GET /v3/api-docs
  • components.schemas.PidLookupResponse.properties

Actual result (OpenAPI JSON):

{
  "family_name": { "type": "string" },
  "expiry_date": { "type": "string" },
  "issuanceDate": { "type": "string" },
  "issuingCountry": { "type": "string" },
  "issuingAuthority": { "type": "string" }
}

Expected result (OpenAPI JSON):

{
  "family_name": { "type": "string" },
  "expiry_date": { "type": "string" },
  "issuance_date": { "type": "string" },
  "issuing_country": { "type": "string" },
  "issuing_authority": { "type": "string" }
}

Expected behavior

All schema property names should consistently follow SNAKE_CASE when global Jackson naming strategy is set to SNAKE_CASE.

Screenshots

Can be provided if needed (Swagger UI shows mixed snake_case + camelCase in the same schema).

Additional context

Runtime JSON response naming is snake_case as expected.
Issue is specifically about generated OpenAPI schema naming.
Workaround is adding explicit @JsonProperty(...) on affected fields, but this should not be required for global naming strategy.

Activity

  1. Mattias-Sehlstedt commented on May 26, 2026

    @Mattias-Sehlstedt
    Contributor

    Hi, this issue is entirely tied to the swagger-core library that does the model introspection. Can be verified with:

    ModelResolver modelResolver = new ModelResolver(
            Json.mapper().copy().setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
    );
    ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
    Schema<?> schema = modelResolver.resolve(new AnnotatedType(PidLookupResponse.class), context, null);

    And then you will see that the field names vary.

  2. added a commit that references this issue on Jul 14, 2026
    1474280
  3. added a commit that references this issue on Jul 14, 2026
    9ed2340
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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