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

Migrate @SwaggerDefinition to @OpenAPIDefinition #25

Merged
merged 9 commits into from
Jan 1, 2025

Conversation

SiBorea
Copy link
Contributor

@SiBorea SiBorea commented Dec 4, 2024

What's changed?

This recipe migrate @SwaggerDefinition to @OpenAPIDefinition

  • Combines basePath, host and schemes into servers
  • Drop consumes and produces, leave the others untouched
  • Change io.swagger.annotations.Info to io.swagger.v3.oas.annotations.info.Info

Ref: https://support.intershop.com/kb/index.php/Display/2914L4

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

github-actions[bot]

This comment was marked as outdated.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/main/java/org/openrewrite/openapi/swagger/MigrateApiToTag.java
    • lines 30-31

github-actions[bot]

This comment was marked as outdated.

@timtebeek timtebeek self-requested a review December 4, 2024 09:50
github-actions[bot]

This comment was marked as outdated.

String servers = "";
if (basePath != null && host != null && schemes != null) {
tpl.append("servers = {\n");
for (Expression scheme : ((J.NewArray) schemes).getInitializer()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If folks use schemes = SwaggerDefinition.Scheme.HTTPS then this throws a class cast exception:

Caused by: java.lang.ClassCastException: class org.openrewrite.java.tree.J$FieldAccess cannot be cast to class org.openrewrite.java.tree.J$NewArray (org.openrewrite.java.tree.J$FieldAccess and org.openrewrite.java.tree.J$NewArray are in unnamed module of loader 'app')
	at org.openrewrite.openapi.swagger.MigrateSwaggerDefinitionToOpenAPIDefinition$1.visitAnnotation(MigrateSwaggerDefinitionToOpenAPIDefinition.java:75)
	at org.openrewrite.openapi.swagger.MigrateSwaggerDefinitionToOpenAPIDefinition$1.visitAnnotation(MigrateSwaggerDefinitionToOpenAPIDefinition.java:55)
	at org.openrewrite.java.tree.J$Annotation.acceptJava(J.java:233)
	at org.openrewrite.java.tree.J.accept(J.java:59)
	at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)

I think that's common enough to warrant proper handling here.

@timtebeek timtebeek self-requested a review December 20, 2024 08:26
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Some suggestions could not be made:

  • src/main/java/org/openrewrite/openapi/swagger/MigrateApiToTag.java
    • lines 30-31

Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Great to see @SiBorea ! Thanks a lot for the continued work here.

@timtebeek timtebeek merged commit 21944f6 into openrewrite:main Jan 1, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants