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

[234] Create rules detecting use of MicroProfile OpenAPI to facilitate EAP XP5->6 migration. #235

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions default/generated/eapxp6/180-eapxp_microprofile_openapi_4.0.mta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
- ruleID: eapxp_microprofile_openapi_4.0-00001
description: "Incompatible changes to the Schema model API, reflecting changes in the OpenAPI v3.1 document format."
message: "Replace use of `nullable` property with `SchemaType.NULL`."
category: mandatory
effort: 1
links:
- url: https://download.eclipse.org/microprofile/microprofile-open-api-4.0/microprofile-openapi-spec-4.0.html#incompatible_changes_40
title: "Release Notes for MicroProfile OpenAPI 4.0"
when:
and:
- java.dependency:
name: org.eclipse.microprofile.openapi.microprofile-openapi-api
lowerbound: "1.0"
upperbound: "3.99"
- or:
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.getNullable
location: METHOD_CALL
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.setNullable
location: METHOD_CALL
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.nullable
location: METHOD_CALL
- ruleID: eapxp_microprofile_openapi_4.0-00002
description: "Incompatible changes to the Schema model API, reflecting changes in the OpenAPI v3.1 document format."
message: "`type` property type changed from `SchemaType` to `List<SchemaType>`."
category: potential
effort: 1
links:
- url: https://download.eclipse.org/microprofile/microprofile-open-api-4.0/microprofile-openapi-spec-4.0.html#incompatible_changes_40
title: "Release Notes for MicroProfile OpenAPI 4.0"
when:
and:
- java.dependency:
name: org.eclipse.microprofile.openapi.microprofile-openapi-api
lowerbound: "1.0"
upperbound: "3.99"
- or:
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.getType
location: METHOD_CALL
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.setType
location: METHOD_CALL
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.type
location: METHOD_CALL
- ruleID: eapxp_microprofile_openapi_4.0-00003
description: "Incompatible changes to the Schema model API, reflecting changes in the OpenAPI v3.1 document format."
message: "`exclusiveMinimum` and `exclusiveMaximum` property types changed from `Boolean` to `BigDecimal`."
category: potential
effort: 1
links:
- url: https://download.eclipse.org/microprofile/microprofile-open-api-4.0/microprofile-openapi-spec-4.0.html#incompatible_changes_40
title: "Release Notes for MicroProfile OpenAPI 4.0"
when:
and:
- java.dependency:
name: org.eclipse.microprofile.openapi.microprofile-openapi-api
lowerbound: "1.0"
upperbound: "3.99"
- or:
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.getExclusiveMaximum
location: METHOD_CALL
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.setExclusiveMaximum
location: METHOD_CALL
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.exclusiveMaximum
location: METHOD_CALL
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.getExclusiveMinimum
location: METHOD_CALL
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.setExclusiveMinimum
location: METHOD_CALL
- java.referenced:
pattern: org.eclipse.microprofile.openapi.models.media.Schema.exclusiveMinimum
location: METHOD_CALL
- ruleID: eapxp_microprofile_openapi_4.0-00004
description: "Default value of `@RequestBody.required` changed from `false` to `true` to reflect that this is the much more common case where a RESTful resource method accepts a request body."
message: "If `@RequestBody` of a resource method is not required, override new default value via `required = false`."
category: potential
effort: 1
links:
- url: https://download.eclipse.org/microprofile/microprofile-open-api-4.0/microprofile-openapi-spec-4.0.html#incompatible_changes_40
title: "Release Notes for MicroProfile OpenAPI 4.0"
when:
and:
- java.dependency:
name: org.eclipse.microprofile.openapi.microprofile-openapi-api
lowerbound: "1.0"
upperbound: "3.99"
- java.referenced:
pattern: org.eclipse.microprofile.openapi.annotations.parameters.RequestBody
location: ANNOTATION
- ruleID: eapxp_microprofile_openapi_4.0-00005
description: "`/openapi` endpoint now serves documentation in OpenAPI v3.1 format."
message: "Static OpenAPI documents should conform to verson 3.1 of the OpenAPI specification."
category: potential
effort: 1
links:
- url: https://download.eclipse.org/microprofile/microprofile-open-api-4.0/microprofile-openapi-spec-4.0.html#incompatible_changes_40
title: "Release Notes for MicroProfile OpenAPI 4.0"
when:
builtin.file:
pattern: openapi\.(yaml|yml|json)

7 changes: 7 additions & 0 deletions default/generated/eapxp6/ruleset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: eapxp6/eapxp5
description: This ruleset provides analysis of Maven built applications when migrating from EAP XP 5 to 6.
labels:
- konveyor.io/source=eapxp
- konveyor.io/target=eapxp6+
- konveyor.io/target=eapxp

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>microprofile-openapi-example</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-bom</artifactId>
<version>10.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>6.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
<version>1.11</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.konveyor;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody;

/**
* @author Paul Ferraro
*/
@Path("/echo")
@Produces(MediaType.TEXT_PLAIN)
public class EchoResource {

@GET
@Path("{value}")
public String echo(@RequestBody(content = @Content(mediaType = "text/plain")) @PathParam("value") String value) {
return value;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.konveyor;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

/**
* @author Paul Ferraro
*/
@ApplicationPath("/test")
public class TestApplication extends Application {

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.konveyor;

import org.eclipse.microprofile.openapi.OASFilter;
import org.eclipse.microprofile.openapi.models.media.Schema;
import org.kohsuke.MetaInfServices;

/**
* @author Paul Ferraro
*/
@MetaInfServices(OASFilter.class)
public class TestFilter implements OASFilter {

@Override
public Schema filterSchema(Schema schema) {
Schema.SchemaType type = schema.getType();
schema.setType(type);
Boolean max = schema.getExclusiveMaximum();
schema.setExclusiveMaximum(max);
Boolean min = schema.getExclusiveMinimum();
schema.setExclusiveMinimum(min);
Boolean nullable = schema.getNullable();
schema.setNullable(nullable);
return schema;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"openapi" : "3.1.0",
"paths" : {
"/test/echo/{value}" : {
"get" : {
"parameters" : [ {
"name" : "value",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"text/plain" : {
"schema" : {
"type" : "string"
}
}
}
}
}
}
}
},
"info" : {
"title" : "Test application",
"description" : "This is my test application description",
"version" : "1.0"
},
"servers" : [ {
"url" : "/test"
} ]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright The WildFly Authors
~ SPDX-License-Identifier: Apache-2.0
-->
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
</web-app>

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
rulesPath: ../eapxp_microprofile_openapi_4.0.mta.yaml
providers:
- name: java
dataPath: ./data/eapxp_microprofile_openapi_4.0
- name: builtin
dataPath: ./data/eapxp_microprofile_openapi_4.0
tests:
- ruleID: eapxp_microprofile_openapi_4.0-00001
testCases:
- name: MP-OpenAPI-Schema-1
hasIncidents:
exactly: 2
- ruleID: eapxp_microprofile_openapi_4.0-00002
testCases:
- name: MP-OpenAPI-Schema-2
hasIncidents:
exactly: 2
- ruleID: eapxp_microprofile_openapi_4.0-00003
testCases:
- name: MP-OpenAPI-Schema-3
hasIncidents:
exactly: 4
- ruleID: eapxp_microprofile_openapi_4.0-00004
testCases:
- name: MP-OpenAPI-RequestBody-1
hasIncidents:
exactly: 1
- ruleID: eapxp_microprofile_openapi_4.0-00005
testCases:
- name: MP-OpenAPI-Document-1
hasIncidents:
exactly: 1

Loading