You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor OpenAPI documentation and update dependency version
Reorganize content on generating OpenAPI documents and improve clarity on annotation-based generation. Update version number for microprofile-openapi-api dependency.
@@ -72,25 +72,21 @@ MicroProfile OpenAPI ensures your documentation stays synchronized with your imp
72
72
73
73
== Generating OpenAPI documents
74
74
75
-
Add annotations to your Jakarta REST resources to generate documentation with MicroProfile OpenAPI. This annotation-driven approach keeps your documentation synchronized with your code. When you update an endpoint, you update its documentation at the same time.
75
+
MicroProfile OpenAPI provides multiple approaches to generate OpenAPIdocumentation. You can use annotations, static files, or a combination of both to create comprehensive API specifications.
76
76
77
77
=== Annotation-based generation
78
78
79
-
You can use OpenAPI annotations to mark up your Jakarta REST classes and methods. MicroProfile OpenAPI then scans your application during the build time, automatically discovering the annotated endpoints, and producing a full OpenAPI specification.
79
+
Add annotations to your Jakarta REST resources to generate documentation with MicroProfile OpenAPI. This annotation-driven approach keeps your documentation synchronized with your code. When you update an endpoint, you update its documentation at the same time.
80
+
81
+
Annotate your Jakarta REST classes and methods with OpenAPI annotations. MicroProfile OpenAPI scans your application at build time, discovers annotated endpoints, and generates a complete OpenAPI specification automatically.
80
82
81
-
This approach has several advantages:
83
+
This approach offers several benefits:
82
84
83
85
* Documentation lives alongside the code it describes
84
-
* IDEs can provide support for autocomplete and validation features.
There are multiple ways in which you can generate OpenAPI documents. The most common way is to use annotations. This only requires augmenting your Jakarta Restful Web Services annotations with OpenAPI annotations.
91
-
92
-
Besides annotations, a predefined OpenAPI document may be provided in either YAML or JSON format. This so-called static model will be merged with the model generated by scanning for Jakarta REST endpoints and the combined result will be made available to clients. However, the annotation-based approach is recommended as it is more maintainable and easier to understand. Finally, you can filter out the resources you do not want to document using configuration.
93
-
94
90
=== Static OpenAPI files (optional)
95
91
96
92
You can also provide a static OpenAPI document in `.yaml` or `.json` format at `META-INF/openapi.yaml` or `META-INF/openapi.json`. MicroProfile OpenAPI will merge this static content with the generated specification, which allows you to:
@@ -114,7 +110,7 @@ To use MicroProfile OpenAPI in your project, add the following Maven coordinates
Below is an illustrative example of how you might annotate a method in the `ProductResource` class to achieve this documentation using MicroProfile OpenAPI annotations:
132
+
This property tells MicroProfile OpenAPI to scan your classes for annotations and generate API documentation for them.
133
+
134
+
== Basic annotation example
135
+
136
+
To document Jakarta RESTful Web Services using MicroProfile OpenAPI, annotate your resource classes and methods with OpenAPI annotations. The following example shows how to annotate a method in the `ProductResource` class:
143
137
144
138
[source, java]
145
139
----
@@ -185,15 +179,6 @@ The annotations provide the following documentation:
185
179
186
180
These annotations enrich the `ProductResource` class with metadata necessary for generating comprehensive OpenAPI documentation automatically.
187
181
188
-
Add the following property to the `src/main/resources/META-INF/microprofile-config.properties` file:
189
-
190
-
[source, properties]
191
-
----
192
-
mp.openapi.scan=true
193
-
----
194
-
195
-
This property tells MicroProfile OpenAPI to scan your classes for annotations and generate API documentation for them.
196
-
197
182
Build and run your application after configuring MicroProfile OpenAPI.
198
183
199
184
== Viewing the generated documentation
@@ -1430,111 +1415,6 @@ public class SecuredProductResource {
1430
1415
}
1431
1416
----
1432
1417
1433
-
==== Applying security to operations
1434
-
1435
-
You can apply security requirements to individual operations or to entire resource classes.
0 commit comments