Skip to content

Update chapter04.adoc about MicroProfile OpenAPI 4.1 with the latest features from OpenAPI 3.0#63

Open
ttelang wants to merge 9 commits intomicroprofile:mainfrom
ttelang:chatper-update-mp-openapi-4-1
Open

Update chapter04.adoc about MicroProfile OpenAPI 4.1 with the latest features from OpenAPI 3.0#63
ttelang wants to merge 9 commits intomicroprofile:mainfrom
ttelang:chatper-update-mp-openapi-4-1

Conversation

@ttelang
Copy link
Contributor

@ttelang ttelang commented Feb 4, 2026

This PR contains is for updating Chapter 04 of the official MicroProfile 7.1 API Tutorial with the coverage the latest feature and enhancements in MicroProfile OpenAPI 4.1.

This chapter provides detailed coverage of OpenAPI Specification integration with Jakarta RESTful Web Services, focusing on annotation-driven API documentation generation.

Topics Updated

  • Swagger UI Integration: Interactive API exploration and testing
  • Complete Code Examples: Working code examples with explanations
  • MicroProfile OpenAPI 4.1 New Features: Detailed coverage of all new features in version 4.1:
    • OpenAPI v3.1 Specification Support
      • JSON Schema 2020-12 alignment
      • Improved nullable type handling with type arrays
      • Enhanced schema composition (oneOf, anyOf, allOf)
      • Optional<T> support for nullable fields
    • Java Records Support
      • Native documentation generation for Java records
    • Enhanced Annotation Type Safety
      • @Target meta-annotation improvements
      • Compile-time validation
      • IDE integration benefits
    • JSON Schema Dialect Support
      • Default vs. full JSON Schema 2020-12 dialects
      • Programmatic dialect specification
      • CustomModelReader implementation
    • Extensible Interface Methods
      • New hasExtension() and getExtension() convenience methods
      • Vendor extensions documentation
      • ExtensionFilter implementation for dynamic documentation
    • Asynchronous Operations with Callbacks
      • Webhook-style API documentation
      • @Callback and @CallbackOperation usage
    • Comprehensive Security Schemes
      • API Key authentication
      • JWT Bearer token authentication
      • OAuth2 with authorization code flow
      • Security requirement application at operation and class levels

I would be sharing another PR for the associated code changes in next few days.

Improved clarity and readability of the MicroProfile OpenAPI section by rephrasing sentences and enhancing consistency in terminology.
Updated the chapter content to improve clarity and correctness, including rephrasing sentences and fixing typographical errors.
Rephrase and clarify the explanation of the OpenAPI Specification and its benefits, improving readability and consistency.
Comment on lines +352 to +354
== New features in MicroProfile OpenAPI 4.1

MicroProfile OpenAPI 4.1 introduces several enhancements that improve developer productivity and align with the OpenAPI v3.1 specification. These features simplify API documentation, add support for modern Java language features, and provide better schema validation capabilities.
Copy link
Member

Choose a reason for hiding this comment

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

Support for OpenAPI v3.1 was actually first included in MP OpenAPI 4.0.

You can reference the Release Notes for more details.

MP OpenAPI 4.1 really didn't add very much, but 4.0 was a major release so I think it is worth calling out these new features, just be aware that they were added in 4.0, not 4.1.

import java.util.LinkedHashMap;
import java.util.Map;

public class ExtensionFilter implements OASFilter {
Copy link
Member

Choose a reason for hiding this comment

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

This example could be simplified by using the getExtension method added in 4.1, along with the preexisting addExtension method, rather than handling the map of extensions directly.

Comment on lines +937 to +939
=== Documenting asynchronous operations with callbacks

MicroProfile OpenAPI 4.1 supports documenting asynchronous operations that use callbacks. Callbacks prove useful for webhook-style APIs where your service initiates an asynchronous process and notifies the client when it completes by making an HTTP request back to a URL provided by the client.
Copy link
Member

Choose a reason for hiding this comment

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

Support for callbacks was not new in 4.1 (or 4.0).

@Callback documents a callback that can be set up using an operation.

4.0 added support for webhooks, which document a callback which can be set up via some out of band mechanism (e.g. through a form on a web page). The OpenAPI document may include information on how to set the webhook up.

Comment on lines +1263 to +1265
=== Documenting security schemes

Security is a critical aspect of API documentation. MicroProfile OpenAPI 4.1 provides comprehensive support for documenting various security schemes including API keys, HTTP authentication, OAuth2, and OpenID Connect.
Copy link
Member

Choose a reason for hiding this comment

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

This is still in the "what's new" section?

If so, we should document what was actually added, otherwise you give the impression that security schemes were new in 4.0, whereas actually it was only a small tweak.

Comment on lines +1328 to +1332
==== Applying security to operations

You can apply security requirements to individual operations or to entire resource classes.

*Applying security to individual operations:*
Copy link
Member

Choose a reason for hiding this comment

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

Whenever we talk about applying security requirements in OpenAPI, we need to be very clear that OpenAPI only documents security requirements, it doesn't enforce anything.

The user must first implement access controls, and then use OpenAPI to document to their end users how to authenticate with the API.

Reorganize content on generating OpenAPI documents and improve clarity on annotation-based generation. Update version number for microprofile-openapi-api dependency.
Removed the section on configuring annotation scanning and added a note about its default state.
Refactored API response annotations for clarity and updated a note about usage of @APIResponses with `extensions' meta data fields.
Updated practical use cases for filters with more detailed examples and added notes on tool integration.
Removed section on new features in MicroProfile OpenAPI 4.1 and updated related content for clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants