Skip to content

Add OpenAPI extension for auto-documenting Restlet applications' APIs#1484

Merged
thboileau merged 10 commits into2.7from
2.7__openapi_extension
Mar 28, 2026
Merged

Add OpenAPI extension for auto-documenting Restlet applications' APIs#1484
thboileau merged 10 commits into2.7from
2.7__openapi_extension

Conversation

@anicolas
Copy link
Copy Markdown
Collaborator

The aim

Add OpenAPI extension for auto-documenting Restlet applications APIs.

The solution

Introduce a new org.restlet.ext.openapi extension that leverages swagger-core and swagger-annotations under-the-hood.

Reproduction

Check-list

  • PR size
    • Under 300 lines ✅
    • Can't be split without complicating the process even more
  • Tests
    • Added
    • Not applicable (why?)
  • Doc
    • Added
    • Not applicable
  • Reviewer
    • Asked for a review
    • Added label DO NOT REVIEW

@anicolas anicolas self-assigned this Feb 13, 2026
Copy link
Copy Markdown
Collaborator

@jlouvel jlouvel left a comment

Choose a reason for hiding this comment

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

Thank you @anicolas for this significant contribution!

I've left a few comments along the way, also could you add the boilerplate copyright header, including your name as author (additional author if you reused significant code from the older Swagger extension)?

import org.restlet.routing.Filter;
import org.restlet.routing.Router;

public class RestletOpenApiApplication extends Application {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would suggest "OpenApiApplication" as it extends Restlet's Application, which makes it explicit enough


private Paths paths = new Paths();

private OpenAPI openAPI = new OpenAPI();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we rename to "openApi" for consistency within RF?

}
}
} else {
LOGGER.info("Route type ignored: {}", route.getClass());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we access the Logger like other RF code, not directly via SLF4J?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh, nice catch, I wasn't aware of this!


import java.util.Optional;

class OpenApiAnnotationProcessor {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we make this class 'public', as well as other classes in the openapi package? That would be consistent with the RF codebase.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I tried to minimize the public API but let's be consistent!

@jlouvel
Copy link
Copy Markdown
Collaborator

jlouvel commented Mar 5, 2026

This looks great. Exciting progress!!

My last comment would be to move all supporting classes from org.restlet.ext.openapi to org.restlet.ext.openapi.internal package, as done for other extension, to keep the top package level as clean as possible. If those classes can be directly used or exposed to the user, then it is fine to keep them that way.

@thboileau Did you get a chance to review as well?


private Router router;

private OpenAPIConfiguration config;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we define a default configuration (to prevent NPE in the processTypeToContent method)?

Copy link
Copy Markdown
Collaborator Author

@anicolas anicolas Mar 27, 2026

Choose a reason for hiding this comment

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

Nice catch, thanks! I think it's better to immediately fail in read if we do not have it (same for router). I added two checks in the read method to fail early.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

great, thanks Antoine

@thboileau thboileau marked this pull request as ready for review March 28, 2026 15:38
Copy link
Copy Markdown
Contributor

@thboileau thboileau left a comment

Choose a reason for hiding this comment

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

it's fine for the next release: 2.7.0-m3

@sonarqubecloud
Copy link
Copy Markdown

@thboileau thboileau merged commit 6285f12 into 2.7 Mar 28, 2026
3 checks passed
@thboileau thboileau deleted the 2.7__openapi_extension branch March 28, 2026 16:20
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.

3 participants