Skip to content

Commit 92bb98b

Browse files
committed
improve docs, add release note #12439
1 parent 91762b2 commit 92bb98b

4 files changed

Lines changed: 41 additions & 6 deletions

File tree

doc/release-notes/12439-openapi.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Updates for API Users
2+
3+
- The quality of the OpenAPI document has been greatly improved, increasing from 10/100 to 98/100 according [vacuum](https://quobix.com/vacuum/). See [the guides](https://dataverse-guide--12439.org.readthedocs.build/en/12439/api/getting-started.html#getting-the-openapi-document) and #12439.
4+
5+
## Updates for Developers
6+
7+
- If you are adding or updating Dataverse APIs you are now required to add OpenAPI annotations. See [the guides](https://dataverse-guide--12439.org.readthedocs.build/en/12439/developers/api-design.html#openapi) and #12439.

doc/sphinx-guides/source/api/getting-started.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ The fully expanded example above (without environment variables) looks like this
178178
179179
curl "https://demo.dataverse.org/openapi?format=json"
180180
181-
We are aware that our OpenAPI document is not perfect. You can find more information about validating the document under :ref:`openapi-dev` in the Developer Guide.
181+
If you have feedback about the our OpenAPI document, please contact us through the usual channels under :ref:`getting-help-with-apis`.
182+
183+
You can find more information about validating the document under :ref:`openapi-dev` in the Developer Guide.
182184

183185
Beyond "Getting Started" Tasks
184186
------------------------------

doc/sphinx-guides/source/developers/api-design.rst

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,39 @@ OpenAPI
1414

1515
As you add API endpoints, please be conscious that we are exposing these endpoints as an OpenAPI document at ``/openapi`` (e.g. http://localhost:8080/openapi ). See :ref:`openapi` in the API Guide for the user-facing documentation.
1616

17-
We've played around with validation tools such as https://quobix.com/vacuum/ and https://pb33f.io/doctor/ only to discover that our OpenAPI output is less than ideal, generating various warnings and errors.
17+
OpenAPI Annotations
18+
~~~~~~~~~~~~~~~~~~~
19+
20+
To keep our OpenAPI document at a reasonable quality, you must add annotations to API endpoints you are adding and editing. Here's an example:
21+
22+
.. code-block:: java
23+
24+
@POST
25+
@AuthRequired
26+
@Path("/")
27+
@Operation(summary = "Creates a license", description = "Creates a license when the authenticated user is a superuser and returns the created license location.")
28+
@APIResponse(responseCode = "201", description = "License created with a Location header pointing to the new license.")
29+
public Response addLicense(@Context ContainerRequestContext crc,
30+
@RequestBody(description = "License definition to persist, including name, URI, active state, and sort order.",
31+
content = @Content(mediaType = "application/json",
32+
schema = @Schema(type = SchemaType.OBJECT,
33+
description = "License definition accepted by the license administration API.")))
34+
License license) {
35+
...
36+
}
37+
38+
If you are looking for a reference about the annotations used to generate the OpenAPI document, you can find it in the `MicroProfile OpenAPI Specification <https://download.eclipse.org/microprofile/microprofile-open-api-3.1/microprofile-openapi-spec-3.1.html#_detailed_usage_of_key_annotations>`_.
39+
40+
OpenAPI Quality
41+
~~~~~~~~~~~~~~~
42+
43+
To use `vacuum <https://quobix.com/vacuum/>`_ with our recommended settings to check the quality of our OpenAPI document, see the :download:`README.md <../../../../scripts/openapi/README.md>` under ``scripts/openapi``.
1844

1945
You can prevent additional problems in our OpenAPI document by observing the following practices:
2046

2147
- When creating a method name within an API class, make it unique.
22-
23-
If you are looking for a reference about the annotations used to generate the OpenAPI document, you can find it in the `MicroProfile OpenAPI Specification <https://download.eclipse.org/microprofile/microprofile-open-api-3.1/microprofile-openapi-spec-3.1.html#_detailed_usage_of_key_annotations>`_.
48+
- Check that HTTP GET and DELETE operations do not accept request bodies.
49+
- Various notes under :download:`vacuum-recommended.yaml <../../../../scripts/openapi/vacuum-recommended.yaml>`.
2450

2551
Paths
2652
-----

scripts/openapi/vacuum-recommended.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ rules:
99
oas3-missing-example: false
1010
# We have /pids/{id}/delete --> see edu.harvard.iq.dataverse.api.Pids#deletePid
1111
# The HTTP verb there is DELETE so actually we don't need to have the verb in the path,
12-
# could be fixed
12+
# could be fixed.
1313
no-http-verbs-in-path: false
1414
# These endpoints have an unused `body` parameter, probably because of copy-paste.
1515
# no-request-body: false would not report them, but rather we should fix them to remove `body`
1616
# GET /files/{id}/prov-freeform
1717
# GET /files/{id}/prov-json
1818
# GET /files/{id}/prov-json
19-
#no-request-body: false
19+
#no-request-body: false

0 commit comments

Comments
 (0)