Skip to content

fix: ensure sentinel values are handled correctly in defaultValue mer…#5078

Merged
daniel-kmiecik merged 2 commits intomasterfrom
fix-sentinel-value
Mar 6, 2026
Merged

fix: ensure sentinel values are handled correctly in defaultValue mer…#5078
daniel-kmiecik merged 2 commits intomasterfrom
fix-sentinel-value

Conversation

@daniel-kmiecik
Copy link
Copy Markdown
Collaborator

@daniel-kmiecik daniel-kmiecik commented Mar 5, 2026

Pull Request

Thank you for contributing to swagger-core!

Please fill out the following information to help us review your PR efficiently.


Description

Fixes: #5076

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

@daniel-kmiecik daniel-kmiecik merged commit df6595e into master Mar 6, 2026
7 checks passed
@daniel-kmiecik daniel-kmiecik deleted the fix-sentinel-value branch March 6, 2026 09:26
@JanneAndersson
Copy link
Copy Markdown

JanneAndersson commented Mar 11, 2026

Hi I still have a problem with 2.2.45. (2.2.43 works fine)
If I annotate like this in a java library
@NotNull
@Schema(description = "an integer")
private Integer someInteger;

The generated openapi-spec is:
"someInteger": {
"type": "integer",
"format": "int32",
"default": "##default",
"description": "an integer"
}

And the generated code will be:
@jakarta.annotation.Nonnull
private Integer someInteger = ##default;

If I add a default value the problem disappears:
@NotNull
@Schema(description = "an integer", defaultValue = "0")
private Integer someInteger;

@pmerschmann
Copy link
Copy Markdown

pmerschmann commented Mar 11, 2026

@daniel-kmiecik
Copy link
Copy Markdown
Collaborator Author

daniel-kmiecik commented Mar 11, 2026

@JanneAndersson this test works well for OAS 3.0 and 3.1:

public static class NonNullableInteger {
        @NotNull
        @Schema(description = "an integer")
        private Integer nonNullableInteger;
        public void setNonNullableInteger(Integer nonNullableInteger) {
            this.nonNullableInteger = nonNullableInteger;
        }
    }

If the problem still occurs, please create a new ticket and provide a complete example. Call me in a new issue.
Please ensure that you are working with the latest version 2.2.45.

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.

[Bug]: Problem with ##default and release 2.2.44

4 participants