Skip to content

Lost deprecated attribute after updating to 2.8.16 #3250

Closed

Description

@kevinm416

Describe the bug

  • I just upgraded 2.8.14 -> 2.8.16
  • 3 deprecated fields on my models no longer show up in the generated yaml.
  • Here is one example, a simple String field that loses the deprcated attribute:
  • public record AdjustmentReportRow(
      ...
      @java.lang.Deprecated @NotNull String productLengthName) {}
    
diff --git a/web/sdk/openapi.json b/web/sdk/openapi.json
index 0a1a252003..2465478b97 100644
--- a/web/sdk/openapi.json
+++ b/web/sdk/openapi.json
@@ -193,7 +193,6 @@
             "$ref": "#/components/schemas/ProductLink"
           },
           "productLengthName": {
-            "deprecated": true,
             "type": "string"
           },
           "tag": {

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? 3.5.12
  • What modules and versions of springdoc-openapi are you using? 2.8.16, no modules that I know of, but I'm not sure what a module is in springdoc.
  • What is the actual and the expected result using OpenAPI Description (yml or json)?

Actual:

             "$ref": "#/components/schemas/ProductLink"
           },
           "productLengthName": {
-            "deprecated": true,
             "type": "string"
           },
           "tag": {

Expected: no changes:

             "$ref": "#/components/schemas/ProductLink"
           },
           "productLengthName": {
             "deprecated": true,
             "type": "string"
           },
           "tag": {
  • Provide with a sample code (HelloController) or Test that reproduces the problem.
    • Is there a template I can use to provide this?

Expected behavior

  • A clear and concise description of what you expected to happen.
    • No changes in behavior for a point version update in springdoc.
  • What is the expected result using OpenAPI Description (yml or json)?
    • No changes to the openapi description for a point version update.

Activity

  1. Mattias-Sehlstedt commented on Mar 25, 2026

    @Mattias-Sehlstedt
    Contributor

    Hi, these are the different modules that springdoc offers, so the question is what type of spring application and specification-ui that you are using.

    Image

    A HelloController is just the simplest controller possible, e.g.,

    @RestController
    @Tag(name = "items")
    public class ItemController {
    
      @PostMapping("/items")
      public ResponseEntity<URI> addItem(@Valid @RequestBody final DTO dto) {
        return null;
      }
    
      public record DTO(@Deprecated @NotNull String field) {}
    }

    This produces an expected deprecated for me when resolving to 3.0. See main...Mattias-Sehlstedt:springdoc-openapi:missing-deprecated#diff-2289cb6b8ff406dc3091863f6a8a8c509930d24b52f9c818a7916c771c476fc6R50.

    The issue most likely lies within transitive dependencies that you have that springdoc uses (e.g., swagger-core), and that you are using a version that is incompatible with springdoc 2.8.16. If you believe springdoc is at fault. Then please provide a HelloController similar to that shared by me that reproduces your issue within this repository.

  2. minman commented on Mar 26, 2026

    @minman

    Inconsitent behaviour can be reproduced using the following controller:

    @RestController
    @Tag(name = "items")
    public class ItemController {
    
        @PostMapping("/items")
        public ResponseEntity<URI> addItem(@Valid @RequestBody final DTO dto) {
            return null;
        }
    
        public record DTO(@Deprecated @NotNull String field) {}
    
        @PostMapping("/items2")
        public ResponseEntity<URI> addItem(@Valid @RequestBody final DTO2 dto2) {
            return null;
        }
    
        public record DTO2(@NotNull String field) {}
    }

    Result

    • If the field in DTO is marked as @Deprecated, then both fields (DTO and DTO2) appear as deprecated in the generated OpenAPI schema.
    • If the field in DTO2 is marked as @Deprecated, then neither field is marked as deprecated.
    • The deprecation status appears to be determined by the first occurrence of the field name, regardless of the declaring class.
  3. Mattias-Sehlstedt commented on Mar 26, 2026

    @Mattias-Sehlstedt
    Contributor

    Thanks for the example!

    It looks like the cause could be tied to the upgrade of swagger-core, and that this issue is this exact issue. I have updated my own branch with the case provided by minman, and also shown that the deprecation is treated correctly again if the @NotNull is removed from DTO2. I.e., the issue is actually tied to swagger-core, and should preferably be corrected there.

  4. Mattias-Sehlstedt commented on Mar 26, 2026

    @Mattias-Sehlstedt
    Contributor

    I have created PR swagger-api/swagger-core#5099 in swagger-core that should resolve the issue.

  5. added
    duplicate
    wontfix
    and removed
    duplicate
    on Apr 10, 2026
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

    wontfix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions