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.
Title
Inconsistent OpenAPI schema naming with SNAKE_CASE: some Java record fields remain camelCase
Describe the bug
When
spring.jackson.property-naming-strategy: SNAKE_CASEis enabled, OpenAPI schema generation is inconsistent for Javarecordfields.Most fields are converted to
snake_case, but some fields remaincamelCasein/v3/api-docsand 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:
4.0.5org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.2io.swagger.core.v3:swagger-core-jakarta:2.2.43application.yaml:Optional OpenAPI config used:
Sample DTO:
Sample controller:
Run app and check:
GET /v3/api-docscomponents.schemas.PidLookupResponse.propertiesActual 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_CASEwhen global Jackson naming strategy is set toSNAKE_CASE.Screenshots
Can be provided if needed (Swagger UI shows mixed
snake_case+camelCasein 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.