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

Spike: Investigate creating OpenAPI YAML from our code #10236

Closed
cmbz opened this issue Jan 16, 2024 · 5 comments · Fixed by #10328
Closed

Spike: Investigate creating OpenAPI YAML from our code #10236

cmbz opened this issue Jan 16, 2024 · 5 comments · Fixed by #10328
Labels
Feature: API Size: 10 A percentage of a sprint. 7 hours.
Milestone

Comments

@cmbz
Copy link

cmbz commented Jan 16, 2024

Overview

The openapi endpoint provided by Payara results in an internal server error in version 6.0, as detailed here: #9981

Payara has been contacted for a fix (see: #9981 (comment)).

This spike proposes that while we await the Payara fix, we investigate using the OpenAPI Generator Tool to determine feasibility, as recommended here: #9981 (comment)

Related

@pdurbin pdurbin added the Size: 10 A percentage of a sprint. 7 hours. label Jan 16, 2024
@cmbz cmbz moved this to SPRINT READY in IQSS Dataverse Project Jan 17, 2024
@cmbz
Copy link
Author

cmbz commented Jan 17, 2024

2024/01/17: Moved to sprint ready so work can start.

@pdurbin pdurbin moved this from SPRINT READY to This Sprint 🏃‍♀️ 🏃 in IQSS Dataverse Project Jan 17, 2024
@pdurbin pdurbin moved this from This Sprint 🏃‍♀️ 🏃 to In Progress 💻 in IQSS Dataverse Project Jan 17, 2024
@pdurbin pdurbin self-assigned this Jan 17, 2024
@pdurbin
Copy link
Member

pdurbin commented Jan 18, 2024

As I mentioned in standup, I'm going to change the title of this issue to make it more generic.

After poking at https://github.com/OpenAPITools/openapi-generator a bit and playing with the example at https://openapi-generator.tech/docs/plugins/ I'm not so sure that this is the right tool for generating the OpenAPI YAML we want. Instead, it seems like it produced client code from OpenAPI YAML.

I checked with @poikilotherm who suggested some additional libraries to try:

"I might have gotten that one wrong - the OpenAPI generator is about generating Java code from the spec, not the other way round

But: I did some digging, looking specifically for generating the OpenAPI YAML file... And here's what I found:

A) Use Swagger and Swagger Annotations. https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-maven-plugin/README.md and https://github.com/openapi-tools/swagger-maven-plugin (not sure what the difference is). There is also https://github.com/stoicflame/enunciate which supports Swagger output as well as generating client code in a variety of languages.

B) Use MicroProfile OpenAPI annotations (these are the ones also useable with Payara /openapi endpoint) and use other plugins: https://geronimo.apache.org/microprofile/openapi.html or https://github.com/smallrye/smallrye-open-api/tree/main/tools/maven-plugin

I think the best shot is the SmallRye Maven Plugin, as it provides code scanning and keeps us compatible with the Payara OpenAPI implementation"

So next we should try some of the above.

@pdurbin pdurbin changed the title Spike: Investigate OpenAPI Generator Tool as alternative for OpenAPI pyDataverse support Spike: Investigate creating OpenAPI YAML from our code Jan 18, 2024
@pdurbin pdurbin moved this from In Progress 💻 to This Sprint 🏃‍♀️ 🏃 in IQSS Dataverse Project Jan 18, 2024
@pdurbin pdurbin removed their assignment Jan 18, 2024
@jp-tosca jp-tosca self-assigned this Feb 14, 2024
@jp-tosca jp-tosca moved this from This Sprint 🏃‍♀️ 🏃 to In Progress 💻 in IQSS Dataverse Project Feb 14, 2024
@jp-tosca
Copy link
Contributor

jp-tosca commented Feb 14, 2024

Testing this plugin I was able to generate the following spec:

openapi.json

I also generated the yaml version but GitHub doesn't allow them 😓

@pdurbin
Copy link
Member

pdurbin commented Feb 14, 2024

Here's, I grabbed the YAML from the post JP made and added .txt so GitHub will take it: openapi.yaml.txt

This is great! I guess if we go with this approach we should figure out where to put these files. It reminds me of how we put SchemaSpy output here, for example: https://guides.dataverse.org/en/5.14/schemaspy . That said, SchemaSpy has been treated as a one-off, something @donsizemore kindly does manually. Maybe this output should go directly into doc/sphinx-guides/source somewhere and get committed as part of a PR? It could even be useful for code review to see how the API has been extended or changed. And of course, we'd like to the output from the guides so API users can easily find it.

@pdurbin
Copy link
Member

pdurbin commented Feb 23, 2024

On a related note, I just built a version of Payara (for the first time) using the PR that fixes /openapi and left some notes about how I built it and where I put it: #9981 (comment)

@jp-tosca jp-tosca removed their assignment Mar 27, 2024
pdurbin added a commit that referenced this issue May 29, 2024
pdurbin added a commit that referenced this issue May 29, 2024
stevenwinship pushed a commit that referenced this issue Jun 6, 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 <[email protected]>

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

Co-authored-by: Philip Durbin <[email protected]>

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

Co-authored-by: Philip Durbin <[email protected]>

* 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 #9981 #10236

* improve release note #9981 #10236

* Remove old test and changes response to JSON

* stub out guidance on openapi validation #9981 #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 <[email protected]>
@pdurbin pdurbin added this to the 6.3 milestone Jun 6, 2024
luddaniel pushed a commit to Recherche-Data-Gouv/dataverse that referenced this issue 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 <[email protected]>

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

Co-authored-by: Philip Durbin <[email protected]>

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

Co-authored-by: Philip Durbin <[email protected]>

* 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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: API Size: 10 A percentage of a sprint. 7 hours.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants