Skip to content

Augment parameter schema with type's schema when no type given#2596

Open
Pepo48 wants to merge 3 commits into
smallrye:mainfrom
Pepo48:issue-2595
Open

Augment parameter schema with type's schema when no type given#2596
Pepo48 wants to merge 3 commits into
smallrye:mainfrom
Pepo48:issue-2595

Conversation

@Pepo48

@Pepo48 Pepo48 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

… is set

  • merge type, enum and format from the Java field type into the existing partial schema when it has no type set

Closes: #2595

@MikeEdgar MikeEdgar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @Pepo48 . I plan to review later today/tomorrow. I'm wondering if this issue affects schema handling generally and not just for parameters. E.g. does it happen for a property within another schema as well?

@Pepo48

Pepo48 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@MikeEdgar I also wondered about this earlier and at least based on what I see from my research is that it doesn't affect schema properties. The POJO property pipeline handles this correctly via TypeProcessor.processType(), which resolves enums before @Schema is read.

The bug is in mapParameterSchema() in AbstractParameterProcessor, which handles all parameter types, not just @BeanParam fields. Verified on @QueryParam and @HeaderParam, both as @BeanParam fields and direct method arguments. In all cases, parameterHasSchema() returns early when any schema object exists, skipping type resolution entirely.

But, please, recheck this thoroughly, just to be on the safe side. 😊

@MikeEdgar

Copy link
Copy Markdown
Member

@Pepo48 pardon the delay, I am still thinking through this one. Your change works well for the narrow set of attributes in the new logic (type, enumeration, format), but really the issue impacts any type that is currently not being introspected. Granted, this can easily be worked around by adding implementation = SomeClass.class to the @Schema annotation nested within the @Parameter, but I think it might be best to handle it generally for more than just enumerations.

Pepo48 added 2 commits July 1, 2026 14:01
… is set

* merge type, enum and format from the Java field type into the existing partial schema when it has no type set

Closes: smallrye#2595

Signed-off-by: Peter Zaoral <pzaoral@redhat.com>
… is set

* merge type, enum and format from the Java field type into the existing partial schema when it has no type set

Closes: smallrye#2595

Signed-off-by: Peter Zaoral <pzaoral@redhat.com>
@Pepo48

Pepo48 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Hey @MikeEdgar, I found some time to look and it again. I verified one by one with all 7 types (enum, Integer, Double, Long, Boolean, LocalDate, UUID) that they all lose their type info when @Schema(defaultValue) is present.

I tried to replace the manual property merge with a simpler approach. For ref types (UUID, LocalDate, enum), the $ref is now set on the existing schema, so enums are no longer a special case, they just behave like any other ref type. For non-ref types (Integer, Boolean, etc.), mergeObjects fills in type/format while preserving defaultValue.

Is this roughly roughly the approach you had in mind? (I pushed the changes as a separate commit for now)

Signed-off-by: Michael Edgar <michael@xlate.io>
@MikeEdgar

Copy link
Copy Markdown
Member

@Pepo48 I pushed a commit with some more test scenarios in the same test case and handling for multi-variant parameter content (i.e., >1 schema per parameter).

@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

@MikeEdgar MikeEdgar changed the title @BeanParam enum field losing type and enum when @Schema(defaultValue)… Augment parameter schema with type's schema when no type given Jul 8, 2026
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.

@Schema(defaultValue) inside @Parameter on @BeanParam field loses type and enum

2 participants