[Java][jaxrs-spec] Make contextPath template parameter available as a string constant for use in @ApplicationPath#13377
[Java][jaxrs-spec] Make contextPath template parameter available as a string constant for use in @ApplicationPath#13377wing328 merged 6 commits intoOpenAPITools:masterfrom shamus13:master
Conversation
… resource root to be used in the @ApplicationPath annotation to make it easier for people, who want to write their own jax-rs Application class
| package {{invokerPackage}}; | ||
|
|
||
| public class RestResourceRoot { | ||
| public static final String ROOT = "{{{contextPath}}}"; |
There was a problem hiding this comment.
thanks for the PR. one question from me is why do we need to store this ROOT separately in another class?
can you store it in RestApplication for example instead?
There was a problem hiding this comment.
I am using interface only, so that i can provide my own RestApplication class, where i add a bunch of exception mappers and such.
The variable could of course be defined in RestApplication, when that class is generated. In the interface only cases, i think, it would be odd to generate a RestApplication class without the @ApplicationPath annotation to hold this ROOT constant, that i am proposing. Btw perhaps APPLICATION_PATH would be a better name for this constant?
There was a problem hiding this comment.
Btw perhaps APPLICATION_PATH would be a better name for this constant?
yes, please rename it.
There was a problem hiding this comment.
when ready, please PM me via slack for review and merged.
… use more obvious
|
@wing328 I have updated my pull request with a simple renaming of the constant as suggested. Can't message you on Slack though, since i do not have it installed or even have an account. |
This PR extends the jaxrs-spec template creators to generate a class RestResourceRoot.java with a single string constant ROOT with the content of the template parameter `contextPath'. Secondly the existing generation of RestApplication.java has been updated to make use of this constant in its '@ApplicationPath' annotation. This PR relates to #13374
PR checklist
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*.For Windows users, please run the script in Git BASH.
master(6.1.0) (minor release - breaking changes with fallbacks),7.0.x(breaking changes without fallbacks)@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608