Skip to content

Document an HttpStatusCode property like an HttpStatus one - #3470

Open
Ss0Mae wants to merge 1 commit into
springdoc:mainfrom
Ss0Mae:fix-http-status-code-schema
Open

Ss0Mae wants to merge 1 commit into
springdoc:mainfrom
Ss0Mae:fix-http-status-code-schema

Conversation

@Ss0Mae

@Ss0Mae Ss0Mae commented Dec 5, 2026

Copy link
Copy Markdown

Fixes #3469

HttpStatusCode is a sealed interface, so SpringDocSealedClassModule documents a property of that type as oneOf: [DefaultHttpStatusCode, HttpStatus]. Both inherit an object schema built from the is… boolean getters, and the HttpStatus component ends up with an object allOf next to a string enum, which no value can satisfy. The serialized value for an HttpStatus is a plain string such as "200 OK".

This registers HttpStatusCode to be documented as HttpStatus, next to the existing Charset replacement, so the property gets the same string schema a property declared as HttpStatus already has.

Limitation

A non-enum code, for example HttpStatusCode.valueOf(299), is serialized by Jackson 3 as {"error":false}, and this change does not describe that case. The previous schema did not describe it correctly either (it listed six boolean properties, only error is written). I chose the enum because it matches what is returned for every HttpStatus value. If you would rather keep the oneOf and fix the HttpStatus component instead, I am happy to rework it.

Tests

app286 for 3.0.1 and 3.1.0: a response type with one HttpStatusCode property and one HttpStatus property. It fails before the change on components.schemas.ApiResponse.properties.statusCode and passes after it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A property of type HttpStatusCode is documented as an object of booleans, and the generated HttpStatus schema is unsatisfiable

1 participant