Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Mattias-Sehlstedt
Copy link
Contributor

Fixes #20829

I have added an equals and a hashcode implementation to the WebClient and the RestClient singleRequestParameter-model that is created when setting useSingleRequestParameter to static.

The implementation is taken from the one present in the POJO mustache files, so it might be that the vendor-extension x-is-jackson-optional-nullable or the setting useReflectionEqualsHashCode should be removed since they might be irrelevant for this model.

Since the difference for RestClient with useSingleRequestParameter set to true and set to static is starting to diverge, I thought it made sense to also add an explicit test case for the static case so the difference is properly illustrated (done with samples/client/petstore/java/restclient-useSingleRequestParameter-static).

cc @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@Mattias-Sehlstedt Mattias-Sehlstedt force-pushed the single-request-parameter-equals-and-hashcode branch 3 times, most recently from d278cfa to ea453ba Compare March 9, 2025 16:52
@Mattias-Sehlstedt
Copy link
Contributor Author

The enum samples that are generated in the pipeline does not align with the samples can I get locally when running ./bin/generate-samples.sh bin/configs/java-restclient*

@Mattias-Sehlstedt Mattias-Sehlstedt force-pushed the single-request-parameter-equals-and-hashcode branch from ea453ba to ffc3879 Compare March 10, 2025 11:23
@wing328
Copy link
Member

wing328 commented Mar 11, 2025

@Mattias-Sehlstedt Mattias-Sehlstedt force-pushed the single-request-parameter-equals-and-hashcode branch from ffc3879 to 1a6fb0b Compare March 12, 2025 17:17
@Mattias-Sehlstedt
Copy link
Contributor Author

Mattias-Sehlstedt commented Mar 22, 2025

I dropped adding new samples since the locally generated samples did not align with those generated in the pipeline

@wing328
Copy link
Member

wing328 commented Mar 25, 2025

if no further question/feedback, i'll merge this PR later this week

@martin-mfg
Copy link
Contributor

I dropped adding new samples since the locally generated samples did not align with those generated in the pipeline

Please merge Mattias-Sehlstedt#1 into your branch. It adds the new restclient sample.

@Mattias-Sehlstedt
Copy link
Contributor Author

Thanks for the assistance martin. Would my issue be due to some misconfiguration on my end or is there some general misalignment that one has to account for?

I have for example also seen on my end that I get a lot of sample changes tied to enum value examples when I generated the samples. But I manually exclude them since they are not present upstream? Seems like someone did an enum update a long while ago and missed to update the samples?

@martin-mfg
Copy link
Contributor

Thanks for the assistance martin. Would my issue be due to some misconfiguration on my end or is there some general misalignment that one has to account for?

I have for example also seen on my end that I get a lot of sample changes tied to enum value examples when I generated the samples. But I manually exclude them since they are not present upstream? Seems like someone did an enum update a long while ago and missed to update the samples?

I just tried locally and didn't get any sample changes. And the pipeline which checks whether samples are up to date is also green for your branch, so I seems to be an issue on your end.
Looking at the failed pipeline run which wing328 linked above, the difference between your committed generated samples and the pipeline's expectation is that in your version trailing whitespaces are missing. So my guess is that your IDE or your git are configured to automatically remove any trailing whitespace. Which is a problem for generated samples.

or is there some general misalignment that one has to account for?

No. The only not so obvious thing is that I had to mark the new generated samples/client/petstore/java/restclient-useSingleRequestParameter-static/gradlew as executable. See here, where it says "100644 → 100755".

@Mattias-Sehlstedt
Copy link
Contributor Author

Hi @wing328, will this make it into 7.13, or is the scope for that release already set?

@wing328 wing328 added this to the 7.13.0 milestone Apr 27, 2025
@wing328 wing328 merged commit 10fc9d0 into OpenAPITools:master Apr 27, 2025
107 checks passed
@wing328
Copy link
Member

wing328 commented Apr 27, 2025

just merged it before v7.13.0 release

thanks for the contribution

@Mattias-Sehlstedt Mattias-Sehlstedt deleted the single-request-parameter-equals-and-hashcode branch July 16, 2025 19:50
@Mattias-Sehlstedt
Copy link
Contributor Author

The enum samples that are generated in the pipeline does not align with the samples can I get locally when running ./bin/generate-samples.sh bin/configs/java-restclient*

I found the cause for this. It is tied to me using a Swedish locale, and hence losing the negative enum values as per the issue reported in swagger-api/swagger-core#4223.

An example of a fix is to run export JAVA_OPTS="-Duser.language=en -Duser.region=US", before generating the samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REQ] [java] [restclient] [webclient] Equals and hashcode implementation for static singleRequestParameter model
3 participants