diff --git a/README.md b/README.md index 003a7a3..b35e5e3 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,41 @@ # Quarkus Restlint -[![Version](https://img.shields.io/maven-central/v/io.quarkiverse/quarkus-restlint?logo=apache-maven&style=flat-square)](https://central.sonatype.com/artifact/io.quarkiverse/quarkus-restlint-parent) +This extension was created for the 18th JUG Vale event. -## Welcome to Quarkiverse! +Title: [Desbravando o Quarkus Criando extensōes para sua aplicação nativa de nuvem](https://docs.google.com/presentation/d/1ntc2m3EO6DRYGSkz6vOETGDPLXo2FWGi/edit#slide=id.p4) -Congratulations and thank you for creating a new Quarkus extension project in Quarkiverse! +![img.png](jug-vale.png) -Feel free to replace this content with the proper description of your new project and necessary instructions how to use and contribute to it. +The idea is to demonstrate what is possible to create with a Quarkus extensions. -You can find the basic info, Quarkiverse policies and conventions in [the Quarkiverse wiki](https://github.com/quarkiverse/quarkiverse/wiki). +The goal of this extension is to evict the developer to allow request body when using a GET verb. -In case you are creating a Quarkus extension project for the first time, please follow [Building My First Extension](https://quarkus.io/guides/building-my-first-extension) guide. +```java +@GET +public Response findByName(Map body) {} +``` -Other useful articles related to Quarkus extension development can be found under the [Writing Extensions](https://quarkus.io/guides/#writing-extensions) guide category on the [Quarkus.io](https://quarkus.io) website. +We want to assert that the developer have to use `@QueryParam`, `@Context` or `@PathParam`annotations. -Thanks again, good luck and have fun! +```java +@GET +public Response findByName(@QueryParam("name") String name) {} +``` -## Documentation +## Features -The documentation for this extension should be maintained as part of this repository and it is stored in the `docs/` directory. +A DevUI page describing what errors has in the source code. -The layout should follow the [Antora's Standard File and Directory Set](https://docs.antora.org/antora/2.3/standard-directories/). +![img.png](dev-ui.png) -Once the docs are ready to be published, please open a PR including this repository in the [Quarkiverse Docs Antora playbook](https://github.com/quarkiverse/quarkiverse-docs/blob/main/antora-playbook.yml#L7). See an example [here](https://github.com/quarkiverse/quarkiverse-docs/pull/1) +The source code responsible for creating this DevUI page can be found [here](./deployment/src/main/java/io/quarkiverse/restlint/deployment/RestlintProcessor.java). -Your documentation will then be published to the website. +## Links + +### Writing extensions + +If you want to learn more about how to create a Quarkus extension see the following links: + +- https://matheuscruz.dev +- https://quarkus.io/guides/writing-extensions +- https://quarkus.io/guides/building-my-first-extension diff --git a/deployment/src/main/java/io/quarkiverse/restlint/deployment/RestlintProcessor.java b/deployment/src/main/java/io/quarkiverse/restlint/deployment/RestlintProcessor.java index f8b3630..1526465 100644 --- a/deployment/src/main/java/io/quarkiverse/restlint/deployment/RestlintProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/restlint/deployment/RestlintProcessor.java @@ -2,7 +2,11 @@ import java.util.List; -import io.quarkus.builder.BuildException; +import org.jboss.jandex.AnnotationInstance; +import org.jboss.jandex.DotName; +import org.jboss.jandex.Index; +import org.jboss.jandex.MethodInfo; +import org.jboss.jandex.MethodParameterInfo; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -10,11 +14,6 @@ import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.devui.spi.page.CardPageBuildItem; import io.quarkus.devui.spi.page.Page; -import org.jboss.jandex.AnnotationInstance; -import org.jboss.jandex.DotName; -import org.jboss.jandex.Index; -import org.jboss.jandex.MethodInfo; -import org.jboss.jandex.MethodParameterInfo; class RestlintProcessor { @@ -39,7 +38,7 @@ CardPageBuildItem devUI(List errors) { } @BuildStep - void verifyBodyOnGet(ApplicationIndexBuildItem index, BuildProducer restErrors) throws BuildException { + void verifyBodyOnGet(ApplicationIndexBuildItem index, BuildProducer restErrors) { Index jandex = index.getIndex(); List annotations = jandex.getAnnotations(DotName.createSimple("jakarta.ws.rs.GET")); diff --git a/dev-ui.png b/dev-ui.png new file mode 100644 index 0000000..f8c0197 Binary files /dev/null and b/dev-ui.png differ diff --git a/integration-tests/src/main/java/io/quarkiverse/restlint/it/RestlintResource.java b/integration-tests/src/main/java/io/quarkiverse/restlint/it/RestlintResource.java index 8c41905..f0b6e87 100644 --- a/integration-tests/src/main/java/io/quarkiverse/restlint/it/RestlintResource.java +++ b/integration-tests/src/main/java/io/quarkiverse/restlint/it/RestlintResource.java @@ -19,8 +19,6 @@ import jakarta.enterprise.context.ApplicationScoped; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.Context; -import jakarta.ws.rs.core.UriInfo; @Path("/restlint") @ApplicationScoped @@ -28,8 +26,8 @@ public class RestlintResource { // add some rest methods here @GET - public String hello(@Context UriInfo uriInfo) { - System.out.println("Hello " + uriInfo.getQueryParameters().get("name").get(0)); - return "Hello restlint"; + public String findByName(String body) { // @QueryParam("name") String name + System.out.println("Name from query param: " + body); + return "Hello %s".formatted(body); } } diff --git a/integration-tests/src/test/java/io/quarkiverse/restlint/it/RestlintResourceTest.java b/integration-tests/src/test/java/io/quarkiverse/restlint/it/RestlintResourceTest.java index 69a631f..eab7593 100644 --- a/integration-tests/src/test/java/io/quarkiverse/restlint/it/RestlintResourceTest.java +++ b/integration-tests/src/test/java/io/quarkiverse/restlint/it/RestlintResourceTest.java @@ -1,7 +1,7 @@ package io.quarkiverse.restlint.it; import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.containsString; import org.junit.jupiter.api.Test; @@ -16,6 +16,6 @@ public void testHelloEndpoint() { .when().get("/restlint") .then() .statusCode(200) - .body(is("Hello restlint")); + .body(containsString("Hello")); } } diff --git a/jug-vale.png b/jug-vale.png new file mode 100644 index 0000000..dd20ee7 Binary files /dev/null and b/jug-vale.png differ