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

Spring doc API for link api should accept a structured object instead of JSONObject #7585

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

ianwallen
Copy link
Contributor

@ianwallen ianwallen commented Dec 29, 2023

API should accept a structured object instead of JSONObject
Updated link search to accept an object LinkFilter instead of JSONObject

This was causing a couple issues.
1 - JSONObject is a weird object to be accepted from an API when the results are really a String.
2 - There were a couple API's that were returning JSONObject but not the same one. One was net.sf.json.JSONObject and the other was org.json.JSONObject. This was causing a conflict in the SpringDoc API which was causing bugs in the open api specification. The JSONObject schema could change on each application restart. (i.e. see #7584)
3 - It was causing issues when trying to use CodeGen as it has issue using JSONObject objects as it conflict with the normal JSONObject.

Note: Usage description had "groupId: 12" as a sample however I could not find any case where groupId was being used so I removed that from the comment. I'm guessing that it was replaced by "groupIdFilter" at some point and the documentation was not updated.

This fix updates the link api so that it accepts a new LinkFilter object.

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests)
  • User documentation provided for new features or enhancements in mannual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

Updated link search to accept an object LinkFilter instead of JSONObject
@josegar74
Copy link
Member

@ianwallen from the Links analysis page, when I try to filter I get:

{
    "message": "Failed to convert value of type 'java.lang.String' to required type 'org.fao.geonet.api.links.LinksApi$LinkFilter'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'org.fao.geonet.api.links.LinksApi$LinkFilter': no matching editors or conversion strategy found",
    "code": "runtime_exception",
    "description": null
}

@ianwallen
Copy link
Contributor Author

@josegar74 I fixed the error - it should work now.

@ianwallen ianwallen merged commit b892b26 into geonetwork:main Jan 4, 2024
6 checks passed
@ianwallen ianwallen deleted the fix_link_json_results branch January 4, 2024 11:06
ianwallen added a commit that referenced this pull request Jan 4, 2024
…stead of JSONObject (#7585)

* API should accept a structured object instead of JSONObject
Updated link search to accept an object LinkFilter instead of JSONObject

* Fix error with Failed to convert value of type by adding a @InitBinder
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.

2 participants