Skip to content

Commit

Permalink
Merge pull request #4 from mcruzdev/updateProject
Browse files Browse the repository at this point in the history
Update documentation and source code
  • Loading branch information
mcruzdev authored Aug 28, 2024
2 parents 5c52b5f + 0dc4836 commit 3541f1f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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<String, Object> 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 <https://docs.quarkiverse.io/> 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

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;
import io.quarkus.deployment.builditem.ApplicationIndexBuildItem;
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 {

Expand All @@ -39,7 +38,7 @@ CardPageBuildItem devUI(List<ErrorBuildItem> errors) {
}

@BuildStep
void verifyBodyOnGet(ApplicationIndexBuildItem index, BuildProducer<ErrorBuildItem> restErrors) throws BuildException {
void verifyBodyOnGet(ApplicationIndexBuildItem index, BuildProducer<ErrorBuildItem> restErrors) {

Index jandex = index.getIndex();
List<AnnotationInstance> annotations = jandex.getAnnotations(DotName.createSimple("jakarta.ws.rs.GET"));
Expand Down
Binary file added dev-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@
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
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);
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -16,6 +16,6 @@ public void testHelloEndpoint() {
.when().get("/restlint")
.then()
.statusCode(200)
.body(is("Hello restlint"));
.body(containsString("Hello"));
}
}
Binary file added jug-vale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3541f1f

Please sign in to comment.