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

OpenAPI definition endpoint #10328

Merged
merged 51 commits into from
Jun 6, 2024
Merged

Conversation

jp-tosca
Copy link
Contributor

@jp-tosca jp-tosca commented Feb 16, 2024

What this PR does / why we need it:
On Dataverse 6.0 Payara was updated and this caused the url /openapi to stop working and caused an exception on the server.

This PR restores the functionality by adding a Servlet on /openapi.

We incorporated the SmallRye OpenAPI plugin on our POM (https://github.com/smallrye/smallrye-open-api/tree/main/tools/maven-plugin) which will generate files for YAML and JSON formats and deposit them on edu/harvard/iq/dataverse/openapi/ these files will be provided by this endpoint depending on the format requested.

Which issue(s) this PR closes:

Suggestions on how to test this:

There are additional changes to improve the quality of the OpenAPI document like changing duplicated names from Java classes.

Is there a release notes update needed for this change?:
Yes


on Apr 17 2024: Payara has fixed the original endpoint but it is generating a spec definition that still has errors due duplicated names. We did some testing and regardless of what is on the documentation, the server is not returning the provided files on the META-INF directory, we tested this on the application root META-INF and the currently used META-INF. At this point, we decided to use this solution that will override the original endpoint and server the generated files from the smallrye plugin.

Preview of docs: https://dataverse-guide--10328.org.readthedocs.build/en/10328/api/native-api.html#get-openapi-specification

@jp-tosca jp-tosca self-assigned this Feb 16, 2024
@jp-tosca jp-tosca added the Size: 30 A percentage of a sprint. 21 hours. (formerly size:33) label Feb 16, 2024
@jp-tosca jp-tosca changed the title Openapi definition endpoint 10236 Openapi definition endpoint Feb 16, 2024
@coveralls
Copy link

coveralls commented Feb 16, 2024

Coverage Status

coverage: 20.569% (-0.01%) from 20.58%
when pulling ef267d0 on openapi-definition-endpoint
into 26be8e1 on develop.

Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume docs are coming. Just a quick initial review. I'm excited that SmallRye is working to create the OpenAPI output!

jp-tosca and others added 3 commits February 16, 2024 14:50
Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>
Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>
Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>

This comment has been minimized.

5 similar comments

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little more doc review.

doc/sphinx-guides/source/api/changelog.rst Outdated Show resolved Hide resolved
doc/sphinx-guides/source/api/native-api.rst Outdated Show resolved Hide resolved
doc/sphinx-guides/source/api/native-api.rst Outdated Show resolved Hide resolved
doc/sphinx-guides/source/api/native-api.rst Outdated Show resolved Hide resolved

This comment has been minimized.

2 similar comments

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@jp-tosca jp-tosca removed their assignment Feb 16, 2024

This comment has been minimized.

Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a few commits and have a couple more comments.

import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataParam;

import com.mashape.unirest.request.body.MultipartBody;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm the one who added Unirest but it's one of the libraries I'm hoping we can remove some day in favor of using the Jakarta EE standard. Do we need it here? I see a possible solution at https://stackoverflow.com/questions/64079847/how-to-provide-swagger-annotation-for-multipartformdatainput-in-resteasy-with-qu/65339649#65339649 . Is it worth trying it here and other places in this PR where Unirest is being used?

This comment has been minimized.

This comment has been minimized.

Copy link

github-actions bot commented Jun 3, 2024

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:openapi-definition-endpoint
ghcr.io/gdcc/configbaker:openapi-definition-endpoint

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. API tests are passing. @JR-1991 did note the following...

I just went through the doc and ran a validation. These are the open points:

  • multipart schema must be an object— All multipart bodies are currently typed as string. This can also be addressed in preprocessing prior to code generation.
  • items attribute required for arrays in OpenAPI 3.0.X documents- Two array properties do not contain the items key. Also, easy to fix in pre-processing.
  • duplicate-properties - hTTPUpload (HTTPUpload) will collide with httpUpload (HTTPUpload) [line 11325] when converted to field name- Also addressable in pre-processing.

... in Zulip at https://dataverse.zulipchat.com/#narrow/stream/379673-dev/topic/.2Fopenapi.20broken.20in.206.2E0/near/441630800 BUT my take is that he can live with these problems.

Also, I still think we might want to stop gitignoring the YAML so we always have a version in the guides but we can talk about this at tech hours some day. No need to hold this up.

Approved.

@pdurbin pdurbin removed their assignment Jun 3, 2024
@JR-1991
Copy link
Contributor

JR-1991 commented Jun 4, 2024

@pdurbin - I am totally fine with the current version. The problems are minor and easily addressable in a pre-processing step 🙌

@stevenwinship stevenwinship self-assigned this Jun 6, 2024
@stevenwinship stevenwinship merged commit c052773 into develop Jun 6, 2024
20 checks passed
@stevenwinship stevenwinship removed their assignment Jun 6, 2024
@pdurbin pdurbin added this to the 6.3 milestone Jun 6, 2024
luddaniel pushed a commit to Recherche-Data-Gouv/dataverse that referenced this pull request Jun 12, 2024
* Plugin initial config

* Initial changes to provide OpenAPI definition

* Added integration test

* Imports fix

* Add patchnotes

* Update the changelog

* Update src/main/java/edu/harvard/iq/dataverse/api/Info.java

Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>

* Update doc/release-notes/10236-openapi-definition-endpoint.md

Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>

* Update doc/release-notes/10236-openapi-definition-endpoint.md

Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>

* Add native API docs

* Remove generated definitions

* Add to gitignore generated openapi files

* Updates to docs

* Ignore files correction

* Remove files created by the plugin

* Changes to move the definition files to META-INF

* Changes to move the definitions to WEB-INF

* Changes to get the files from META-INF

* Changed the phase of execution of the smallrye plugin

* Changes of names to improve the generation of the spec

* Add support for OpenAPI annotations and documents the version endpoint

* Multipart Annotations

* Typos correction

* Changes for tags

* Renaming of methods

* Changes to the endpoint

* Added test

* Add test

* Deleted extra import

* Docs updated

* openapi doc tweaks IQSS#9981 IQSS#10236

* improve release note IQSS#9981 IQSS#10236

* Remove old test and changes response to JSON

* stub out guidance on openapi validation IQSS#9981 IQSS#10236

* add InfoIT to list of tests

* use description of Dataverse from website

* mention status codes in openapi doc

* update api faq about changelog, link to breaking changes doc

* typo

* Change to OpenApi

* Changes to docs

* Name fix

* Removing the multipart from unirest

---------

Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>
@DS-INRAE
Copy link
Member

Congrats on merging this PR 👍
Does it also close these OpenAPI related issues ?

Or if the issues remaining are minor should the issues be closed as "won't resolve" ?

@pdurbin pdurbin deleted the openapi-definition-endpoint branch June 14, 2024 16:06
@pdurbin
Copy link
Member

pdurbin commented Jun 14, 2024

@DS-INRA thanks, we've been talking about this in Zulip and we closed both issues as out of date now that the new SmallRye-based /openapi endpoint will be available in the next release.

By the way, I love the issue triage you do for us. To encourage even more, I listed it as a way to contribute: https://dataverse-guide--10532.org.readthedocs.build/en/10532/contributor/index.html#issue-triage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: API Size: 30 A percentage of a sprint. 21 hours. (formerly size:33) Type: Bug a defect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spike: Investigate creating OpenAPI YAML from our code OpenAPI endpoint is broken
7 participants