Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fields and getters name collision #178

Merged

Conversation

valfirst
Copy link
Contributor

The exception is thrown starting from version 2.4.0 when attempting to use the model:

java.lang.IllegalArgumentException: Multiple fields representing property "method": de.sstoehr.harreader.model.HarRequest#method vs de.sstoehr.harreader.model.HarRequest#rawMethod
        at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.getField(POJOPropertyBuilder.java:643)
        at io.swagger.v3.core.jackson.ModelResolver.ignore(ModelResolver.java:1256)
        at io.swagger.v3.core.jackson.ModelResolver.resolve(ModelResolver.java:631)
        at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:97)
        at io.swagger.v3.core.jackson.ModelResolver.resolve(ModelResolver.java:736)
        at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:97)
        at io.swagger.v3.core.converter.ModelConverters.resolveAsResolvedSchema(ModelConverters.java:191)
        at io.swagger.v3.core.converter.ModelConverters.readAllAsResolvedSchema(ModelConverters.java:181)
        at io.swagger.v3.core.util.AnnotationsUtils.resolveSchemaFromType(AnnotationsUtils.java:898)
        at io.swagger.v3.core.util.AnnotationsUtils.getSchema(AnnotationsUtils.java:1744)
        at io.swagger.v3.core.util.AnnotationsUtils.getSchema(AnnotationsUtils.java:1723)
        at io.swagger.v3.core.util.AnnotationsUtils.getContent(AnnotationsUtils.java:1580)
        at io.swagger.v3.jaxrs2.OperationParser.getApiResponses(OperationParser.java:94)
        at io.swagger.v3.jaxrs2.Reader.setOperationObjectFromApiOperationAnnotation(Reader.java:1427)
        at io.swagger.v3.jaxrs2.Reader.parseMethod(Reader.java:1105)
        at io.swagger.v3.jaxrs2.Reader.parseMethod(Reader.java:956)

I haven't investigated it deeply, but my guess it happens because of mixup in fields and getters names. The fix has been tested locally, the error is not reproduced.

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.98%. Comparing base (8bba76d) to head (eb478f1).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #178   +/-   ##
=========================================
  Coverage     78.98%   78.98%           
  Complexity      395      395           
=========================================
  Files            27       27           
  Lines           728      728           
  Branches        131      131           
=========================================
  Hits            575      575           
  Misses          153      153           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sdstoehr sdstoehr merged commit abef2cb into sdstoehr:main Nov 15, 2024
5 checks passed
@sdstoehr
Copy link
Owner

sdstoehr commented Nov 15, 2024

Thank you for the PR - and sorry for the introduction of that issue 🙈 My tests only covered Jackson as used by HarReader directly, but I didn't think about other code struggling with the introduction of the rawStatus/rawMethod

Version 2.4.1 should be available soon through Maven Central including this fix.

@valfirst valfirst deleted the fix-fields-and-getters-name-collision branch November 15, 2024 16:07
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.

2 participants