Fix initialization of SpringDoc so that it does not use null servername and null version #7575
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix initialization of SpringDoc so that it does not use null servername and null version
Before this fix. The initial deployment of geonetwork in a new database would cause Spring Doc api to look like the following
Also if checking the yaml api on https://editor.swagger.io/, we would see the following error because the version was not set.
The issue was mostly caused by 2 contexts being used.
JeevesApplicationContext was being loaded first and at that time, the database was not initialized with the data and ended up returning a null servername and null version from the settings manager.
Then it would later initialize WebApplicationContext and this would initialized the correct version. But when going to /doc/api/ it was using the JeevesApplicationContext version which was incorrect.
This fix modified OpenApi object so that it is a static object that is shared with all context. This helped fix initial api setting so that it was not set to null://null:80/geonetwork/srv/api
After this fix, a new installation of geonetwork will show the following:
Also as part of this fix, SiteApi was updated so that if the server url is changed then it will update the static OpenApi object without requiring an application restart.
Checklist
main
branch, backports managed with labelREADME.md
filespom.xml
dependency management. Update build documentation with intended library use and library tutorials or documentation