generated from konveyor/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[234] Create rules detecting use of MicroProfile OpenAPI to facilitat…
…e EAP XP5->6 migration. Signed-off-by: Paul Ferraro <[email protected]>
- Loading branch information
Showing
9 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
default/generated/eapxp6/180-eapxp_microprofile_openapi_4.0.mta.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
50 changes: 50 additions & 0 deletions
50
default/generated/eapxp6/test/data/eapxp_microprofile_openapi_4.0/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
25 changes: 25 additions & 0 deletions
25
...xp6/test/data/eapxp_microprofile_openapi_4.0/src/main/java/org/konveyor/EchoResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
.../test/data/eapxp_microprofile_openapi_4.0/src/main/java/org/konveyor/TestApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
||
} | ||
|
26 changes: 26 additions & 0 deletions
26
...apxp6/test/data/eapxp_microprofile_openapi_4.0/src/main/java/org/konveyor/TestFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
|
38 changes: 38 additions & 0 deletions
38
...ated/eapxp6/test/data/eapxp_microprofile_openapi_4.0/src/main/webapp/WEB-INF/openapi.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} ] | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
...generated/eapxp6/test/data/eapxp_microprofile_openapi_4.0/src/main/webapp/WEB-INF/web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
33 changes: 33 additions & 0 deletions
33
default/generated/eapxp6/test/eapxp_microprofile_openapi_4.0.test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|